issaiass / realsense2_description

|| Bring up of intel realsense d435 camera in rviz and gazebo ||
71 stars 47 forks source link

Launching muiltiple cameras #4

Open nrjbs87 opened 2 years ago

nrjbs87 commented 2 years ago

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

issaiass commented 2 years ago

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

wonwon0 commented 2 years ago

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.

lucanunz commented 10 months ago

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}"/>