Gazebo | Ignition | Community
Ask Your Question
0

Spawn multiple objects with libgazebo_ros_camera.so plugin

asked 2020-11-27 01:12:05 -0500

dragobette gravatar image
<plugin name="camera_controller" filename="libgazebo_ros_camera.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>0.0</updateRate>  
    <cameraName>RCcar/camera1</cameraName>   
    <imageTopicName>image_raw</imageTopicName>    
    <cameraInfoTopicName>camera_info</cameraInfoTopicName>    
    <frameName>link_camera</frameName>    
    <hackBaseline>0.0</hackBaseline>    
    <distortionK1>0.0</distortionK1>    
    <distortionK2>0.0</distortionK2>    
    <distortionK3>0.0</distortionK3>    
    <distortionT1>0.0</distortionT1>    
    <distortionT2>0.0</distortionT2>    
    <robotNamespace>/</robotNamespace>    
</plugin>

Hello. Having this in my camera model's SDF I am not able to spawn multiple objects because they will have the same topics. How can I solve this problem?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-11-27 05:17:43 -0500

updated 2020-11-30 03:41:27 -0500

Give unique names to the plugins

<plugin name="camera_x" filename="libgazebo_ros_camera.so">

as well as camera names

<cameraName>camera_x</cameraName>


Edit:

To spawn multiple instances of your model, you need to remove the robotNamespace parameter from the model. Then you can spawn unique models by adding a namespace to the spawn_model node:

<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg robot_name) -param robot_description" ns="$(arg robot_name)" />

Alternatively, although not recommended, you can add an argument for the robot name in your urdf:

<xacro:arg name="robot_name" default="robot_0" />
<plugin name="camera_controller" filename="libgazebo_ros_camera.so">
  ...
  <robotNamespace>$(arg robot_name)</robotNamespace>    
</plugin>

Then, you need to create individual urdf descriptions for each robot:

<param name="$(arg robot_name)/robot_description" command="rosrun xacro xacro /path/to/xacro/file robot_name:=$(arg robot_name)" />
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg robot_name) -param $(arg robot_name)/robot_description" />
edit flag offensive delete link more

Comments

i want to spawn the same model more than once

dragobette gravatar imagedragobette ( 2020-11-27 07:59:51 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-11-27 01:12:05 -0500

Seen: 1,130 times

Last updated: Nov 30 '20