RVIZ with multiple rosbots

Is there a way to have multiple Rosbots in Rviz? Or run an Rviz instance for each Rosbot?
I want to have multiple robots in Gazebo and be able to visualise the /first/scan and /second/scan topic, either in one rviz instance or multiple, I.E.

<node ns="first" name="rviz" pkg="rviz" type="rviz" args="-d $(find rosbot_description)/rviz/rosbot.rviz" required="true" output="screen"/>
<node ns="second" name="rviz" pkg="rviz" type="rviz" args="-d $(find rosbot_description)/rviz/rosbot.rviz" required="true" output="screen"/>

If I try this, the transforms of the URDF do not work anymore and the ROSBOT parts jump between the two locations.

Thanks!

Hello XvdG,

Rviz is for visualisation of full robotic system, one instance for all ROSbots should be enough.
You should rather differentiate ROSbot when spawning them in Gazebo:

<node name="rosbot_spawn_first" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot_s -y 0 -namespace first/search_controller">
</node>

<node name="rosbot_spawn_second" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot -y 2.5 -namespace second/search_controller">
</node>

Regards,
Łukasz

Hi Łukasz,

Thanks for your response. I did use the namespaces when spawning them in Gazebo, and both robots do show up in Gazebo. The problem is in Rviz and in the transforms. The first problem arises when the namespace is used with one robot, the transforms from the four wheels to odom are missing. This does work fine when no namespace is defined.

Works (1 robot):

<?xml version="1.0"?>
<launch>


  <rosparam command="load" file="$(find joint_state_controller)/joint_state_controller.yaml" />
  <node name="joint_state_controller_spawner" pkg="controller_manager" type="spawner" output="screen" args="joint_state_controller" />

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find rosbot_description)/urdf/rosbot.xacro'"/>

  <node name="rosbot_spawn_first" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot_s -y 0">
</node>
<!--
<node name="rosbot_spawn_second" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot -y 2.5 -namespace second/search_controller">
</node>
-->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

  <include file="$(find rosbot_gazebo)/launch/rosbot_world.launch"></include>



  <!-- Show in Rviz   -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find rosbot_description)/rviz/rosbot.rviz" required="true" output="screen"/>

</launch>

Error in transform (4x) wheel to odom:

<?xml version="1.0"?>
<launch>


  <rosparam command="load" file="$(find joint_state_controller)/joint_state_controller.yaml" />
  <node name="joint_state_controller_spawner" pkg="controller_manager" type="spawner" output="screen" args="joint_state_controller" />

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find rosbot_description)/urdf/rosbot.xacro'"/>

  <node name="rosbot_spawn_first" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot_s -y 0 -namespace first">
</node>
<!--
<node name="rosbot_spawn_second" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot -y 2.5 -namespace second">
</node>
-->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

  <include file="$(find rosbot_gazebo)/launch/rosbot_world.launch"></include>



  <!-- Show in Rviz   -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find rosbot_description)/rviz/rosbot.rviz" required="true" output="screen"/>

</launch>

When adding the second robot, there is an error in all the transforms:

<?xml version="1.0"?>
<launch>


  <rosparam command="load" file="$(find joint_state_controller)/joint_state_controller.yaml" />
  <node name="joint_state_controller_spawner" pkg="controller_manager" type="spawner" output="screen" args="joint_state_controller" />

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find rosbot_description)/urdf/rosbot.xacro'"/>

  <node name="rosbot_spawn_first" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot_s -y 0 -namespace first">
</node>

<node name="rosbot_spawn_second" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot -y 2.5 -namespace second">
</node>
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

  <include file="$(find rosbot_gazebo)/launch/rosbot_world.launch"></include>



  <!-- Show in Rviz   -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find rosbot_description)/rviz/rosbot.rviz" required="true" output="screen"/>

</launch>

I tried putting the joint_state_controller and the robot_state_publisher in the namespaces , but this did not help.

Also (side question) Why is for the first robot the model specified as -model rosbot_s and for the second one -model rosbot ?

Thanks a lot!

Xander

Hello Xander,

I checked the issue. Gazebo model of ROSbot needed a little adjustments to support multiple ROSbots visualization in Rviz. It was basically publishing topics and tf under namespaces.
According update is already on repository, issue git pull in rosbot_description package in your workspace to get updates.

Then use below launch file:

<?xml version="1.0"?>
<launch>

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find rosbot_description)/urdf/rosbot.xacro' robot_namespace:=first"/>
  <param name="second_robot_description" command="$(find xacro)/xacro.py '$(find rosbot_description)/urdf/rosbot.xacro' robot_namespace:=second"/>

  <node name="rosbot_spawn_first" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param robot_description -model rosbot_s -y 0 -namespace first">
  </node>
  <node name="rosbot_spawn_second" pkg="gazebo_ros" type="spawn_model" output="log" args="-urdf -param second_robot_description -model rosbot -y 2.5 -namespace second">
  </node>

  <group ns="first">
    <rosparam command="load" file="$(find joint_state_controller)/joint_state_controller.yaml" />
    <node name="joint_state_controller_spawner" pkg="controller_manager" type="spawner" output="screen" args="joint_state_controller"/>
    <node name="first_robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher">
      <param name="tf_prefix" value="first"/>
    </node>
    <node pkg="tf" type="static_transform_publisher" name="first_odom" args="0 0 0 0 0 0 1 map first/odom 100" />
  </group>

  <group ns="second">
    <rosparam command="load" file="$(find joint_state_controller)/joint_state_controller.yaml" />
    <node name="joint_state_controller_spawner" pkg="controller_manager" type="spawner" output="screen" args="joint_state_controller"/>
    <node name="second_robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher">
      <remap from="robot_description" to="second_robot_description" />
      <param name="tf_prefix" value="second"/>
    </node>
    <node pkg="tf" type="static_transform_publisher" name="second_odom" args="0 0 0 0 0 0 1 map second/odom 100" />
  </group>

  <include file="$(find rosbot_gazebo)/launch/rosbot_world.launch"></include>

  <!-- Show in Rviz   -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find rosbot_description)/rviz/rosbot.rviz" required="true" output="screen"/>

</launch>

For the side question, parameter -model is for setting model name in Gazebo, they are different to distinguish devices. If name of first device with suffix “_s” is a little confusing, you can change it to any name you wish.

Regards,
Łukasz

Hi Lukasz,
When I try the above launch file. I am not getting topics like first/scan, first/baselink etc. What should I add to the launch file or should I edit urdf?

Hello Thiaga,

Topics under namespaces were introduced in rosbot_description in this commit.

To verify which version you have, issue below command in rosbot_description repository:

git show --summary

You should get exactly the same output:

commit 95efebfa06fd37656bdb18b027222d2418e6d296
Author: Łukasz Mitka <lukasz.mitka@husarion.com>
Date:   Fri Oct 11 13:20:02 2019 +0200

    Add namespaces

Having that verified, please provide:

  • output of rostopic list
  • output of rosnode list
  • screenshot from rqt_graph
    Also, are you getting any errors or warnings?

Regards,
Łukasz