Robotics StackExchange | Archived questions

Spawn multiple objects with libgazebo_ros_camera.so plugin

<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?

Asked by dragobette on 2020-11-27 02:12:05 UTC

Comments

Answers

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

Asked by nlamprian on 2020-11-27 06:17:43 UTC

Comments

i want to spawn the same model more than once

Asked by dragobette on 2020-11-27 08:59:51 UTC