morse-simulator / morse

The Modular OpenRobots Simulation Engine
http://morse-simulator.github.io/
Other
355 stars 156 forks source link

When adding two Kinects only one depth image is published #779

Open tofi89 opened 6 years ago

tofi89 commented 6 years ago

When adding to Kinects only one depth image is published.

Minimal builder file to reproduce the issue:

from morse.builder import *

robot = Morsy()

kinect1 = Kinect(name="kinect1")
kinect1.translate(0, -0.1, 3.7)
kinect1.rotate(0, math.pi/2.0, 0)
kinect1.add_stream('ros')

kinect2 = Kinect(name="kinect2")
kinect2.translate(0, 0.95, 0.7)
kinect2.rotate(0, 0, math.pi/2.0)
kinect2.add_stream('ros')

robot.append(kinect1)
robot.append(kinect2)

env = Environment('sandbox', fastmode = False)
env.set_camera_location([-18.0, -6.7, 10.8])
env.set_camera_rotation([1.09, 0, -1.14])

running rostopic list should show:

/robot/kinect1/rgb/camera_info
/robot/kinect1/rgb/image
/robot/kinect2/depth/camera_info
/robot/kinect2/depth/image
/robot/kinect2/rgb/camera_info
/robot/kinect2/rgb/image

Note that there is only one depth camera. Interestingly it also depends on the call order in the builder script. If kinect2 is initialized directly after kinect1 the problem didn't appear for me.

This seems to fix the problem:

--- a/src/morse/builder/sensors.py
+++ b/src/morse/builder/sensors.py
@@ -499,9 +499,9 @@ class Kinect(CompoundSensor):
         mesh.scale = (.02, .1, .02)
         mesh.color(.8, .8, .8)
         self.append(mesh)
-        self.video_camera = VideoCamera('rgb')
+        self.video_camera = VideoCamera(name + '.rgb')
         self.video_camera.properties(cam_width = 128, cam_height=128)
-        self.depth_camera = DepthCamera('depth')
+        self.depth_camera = DepthCamera(name + '.depth')
         self.depth_camera.properties(classpath='morse.sensors.depth_camera.DepthVideoCamera')
         self.depth_camera.properties(cam_width = 128, cam_height=128, Vertical_Flip=True)
         self.append(self.video_camera)

But I don't understand the full problem e.g. why only the depth camera is affected and what changes when both are initialized right after another.