ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Is URDF plugin's namespace different from topic's namespace?

asked 2021-07-18 21:55:47 -0500

electrophod gravatar image

updated 2021-07-18 22:08:26 -0500

If I spawn a URDF using the spawn_model node in the gazebo_ros package in a separate namespace called ns1 using the <group ns="ns1"> tag, would all the topics related to the URDF (controller topics, plugin topics, sensor topics) be also be launched in the ns1 namespace or would they be there in the global namespace?

I tried doing it and found them to be present in the global namespace, I'm not sure if I'm doing it correctly. Wouldn't it make more sense for them to be present in the namespace in which the node spawning them is launched?

Also, it'd be great if someone points me to some example repos in which multiple robots of the same kind (preferably with cameras or other sensors) are simulated in a Gazebo simulation. I want to check how to take care of topic namespaces, plugins, and transforms.

TIA

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-07-21 17:46:44 -0500

Youssef_Lah gravatar image

Here is what I did for namespace and it's working well:

In a file robots.launch: (here I show you only the group tag)

<!-- Launch gazebo -->
<include file="$(find your_package)/launch/gazebo.launch">
  <arg name="model" value="$(arg model)"/>
 </include>

<group ns="robot1">
    <param name="tf_prefix" value="robot1_tf" />
    <include file="$(find your_package)/launch/robot.launch" >
      <arg name="init_pose" value="-x 11 -y 11 -z 0" />
      <arg name="robot_name"  value="robot1" />
    </include>
  </group>

Then in robot.launch: (here is the full file)

<launch>
    <arg name="robot_name" default="rrr"/>
    <arg name="init_pose" default="rrr"/>

    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model"
         args="$(arg init_pose) -urdf -param /robot_description -model $(arg robot_name)"
         respawn="false" output="screen" />

        <node pkg="robot_state_publisher" type="robot_state_publisher" 
              name="robot_state_publisher" output="screen"/>

    </launch>

Then in gazebo.launch: (full file)

<launch>
<arg name="paused" default="false"/>
<arg name="use_sim_time" default="true"/>
<arg name="gui" default="true"/>
<arg name="headless" default="false"/>
<arg name="debug" default="false"/>
<arg name="model" default="$(find your_package)/urdf/robot.urdf.xacro"/>

<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find your_package)/world/world2"/>
<arg name="verbose" value="true" />
<arg name="debug" value="$(arg debug)" />
<arg name="gui" value="$(arg gui)" />
<arg name="paused" value="$(arg paused)"/>
<arg name="use_sim_time" value="$(arg use_sim_time)"/>
<arg name="headless" value="$(arg headless)"/>
</include>
<param name="robot_description" command="$(find xacro)/xacro  $(arg model)"/>
</launch>

example of diff_drive plugin:

<gazebo>
  <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>100</updateRate>
    <leftJoint>left_joint</leftJoint>
    <rightJoint>right_joint</rightJoint>
    <wheelSeparation>0.6855600</wheelSeparation>
    <wheelDiameter>0.4064000</wheelDiameter>
    <torque>20</torque>
    <odometryFrame>odom</odometryFrame>
    <robotBaseFrame>base_link</robotBaseFrame>
    <publishWheelTF>true</publishWheelTF>
  </plugin>
</gazebo>
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-07-18 21:55:47 -0500

Seen: 740 times

Last updated: Jul 21 '21