realsense2_description icon indicating copy to clipboard operation
realsense2_description copied to clipboard

Launching muiltiple cameras

Open nrjbs87 opened this issue 3 years ago • 3 comments

Hi there,

I noticed there is a test_d435_multiple_cameras.urdf.xacro file. I tried changing the file path to point to this xacro file inside of view_d435_model_rviz_gazebo.launch, however i got the error that both cameras were trying to publish to the same topic. How could I spawn multiple cameras and receive information from them on different topics?

Thanks

nrjbs87 avatar Feb 20 '22 22:02 nrjbs87

You have to change the name of them, let me see if tonight I could do something or at least look for a demo

You could do that in the launch file

issaiass avatar Feb 21 '22 11:02 issaiass

There you go, this is ian example using 6 cams. Put this is an UDRF file in the urdf folder of this repo.

<?xml version="1.0"?>
<robot name="realsense2_camera" xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:include filename="$(find realsense2_description)/urdf/_d435.urdf.xacro" />
 <link name="world" />

 <joint name="world_joint" type="fixed">
    <parent link="world" />
    <child link = "base_link" />
    <origin xyz="0.0 0.0 1" rpy="0.0 0.0 0.0" />
 </joint>
  <link name="base_link" />
  <xacro:sensor_d435 name="camera1" topics_ns="camera1" parent="base_link" publish_pointcloud="true">
    <origin xyz="0.07625 0 0" rpy="1.57 0.7854 0"/>
  </xacro:sensor_d435>  
  <xacro:sensor_d435 name="camera2" topics_ns="camera2" parent="base_link" publish_pointcloud="true">
    <origin xyz="0.03462 0.07209 0" rpy="1.57 0.7854 1.0472"/>
  </xacro:sensor_d435>
    <xacro:sensor_d435 name="camera3" topics_ns="camera3" parent="base_link" publish_pointcloud="true">
    <origin xyz="-0.03462 0.07209 0" rpy="1.57 0.7854 2.0944"/>
  </xacro:sensor_d435>  
    <xacro:sensor_d435 name="camera4" topics_ns="camera4" parent="base_link" publish_pointcloud="true">
    <origin xyz="-0.07625 0 0" rpy="1.57 0.7854 3.1456"/>
  </xacro:sensor_d435>  
    <xacro:sensor_d435 name="camera5" topics_ns="camera5" parent="base_link" publish_pointcloud="true">
    <origin xyz="-0.03462 -0.07209 0" rpy="1.57 0.7854 -2.0944"/>
  </xacro:sensor_d435>
  <xacro:sensor_d435 name="camera6" topics_ns="camera6" parent="base_link" publish_pointcloud="true">
    <origin xyz="0.03462 -0.07209 0" rpy="1.57 0.7854 -1.0472"/>
  </xacro:sensor_d435>
</robot>

Then you call this urdf file in a launch file like the author of this repo does in other launch files.

Then you profit.

wonwon0 avatar Aug 22 '22 15:08 wonwon0

I do not know if this may still be helpful to someone, but I did this fix that works for me and may be more scalable.

Changing the camera name at line 142 of _d435.urdf.xacro to include the namespace

<!-- Realsense Gazebo Plugin -->
<xacro:gazebo_d435 camera_name="${topics_ns}/${name}" reference_link="${name}_link" topics_ns="${topics_ns}" depth_optical_frame="${name}_depth_optical_frame" color_optical_frame="${name}_color_optical_frame" infrared1_optical_frame="${name}_left_ir_optical_frame" infrared2_optical_frame="${name}_right_ir_optical_frame" publish_pointcloud="${publish_pointcloud}"/>

lucanunz avatar Jan 08 '24 02:01 lucanunz