Ask Your Question
0

Multi-Agent simulation causing trouble in Rviz

asked 2021-01-30 06:48:46 -0500

Sankeerth gravatar image

updated 2021-02-01 05:33:50 -0500

I'm trying multi-agent simulations using ROSBOT 2.0 by husarion. I'm comfortable with single agent but when it comes to multiple agents I'm able to spawn them and control them independently but the problem comes with Rviz. I'm unable to visualize the robot in Rviz. It spwans upside down, i'm unable to see the camera feed and lidar output but the topics are present in the rostopic list.

The below is the launch file which I run.

<launch>
  <arg name="world_name" default="worlds/empty.world"/>

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(arg world_name)"/> <!-- world_name is wrt GAZEBO_RESOURCE_PATH environment variable -->
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="true"/>
    <arg name="headless" value="false"/>
    <arg name="debug" value="true"/>
    <arg name="verbose" value="true"/>
  </include>
  <include file="$(find rosbot_gazebo)/launch/multi_rosbot.launch"/>

</launch>

Below is multi_rosbot.launch file.

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

  <!-- BEGIN ROBOT 1-->
  <group ns="rover1">
    <param name="tf_prefix" value="rover1" />
    <include file="$(find rosbot_gazebo)/launch/rosbot_empty_world.launch" >
      <arg name="init_pose" value="-x 0 -y 0 -z 0" />
      <arg name="robot_name"  value="rover1" />
    </include>
  </group>

  <!-- BEGIN ROBOT 2-->
  <group ns="rover2">
    <param name="tf_prefix" value="rover2" />
    <include file="$(find rosbot_gazebo)/launch/rosbot_empty_world.launch" >
      <arg name="init_pose" value="-x -2 -y 0 -z 0" />
      <arg name="robot_name"  value="rover2" />
    </include>
  </group>

  <!-- BEGIN ROBOT 3 -->
  <group ns="rover3">
    <param name="tf_prefix" value="rover3" />
    <include file="$(find rosbot_gazebo)/launch/rosbot_empty_world.launch" >
      <arg name="init_pose" value="-x -4 -y 0 -z 0" />
      <arg name="robot_name"  value="rover3" />
    </include>
  </group>
</launch>

Below is the rosbot_empty_world.launch

<launch>

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

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

  <node pkg="robot_state_publisher" type="robot_state_publisher"  name="robot_state_publisher" ns="/$(arg robot_name)" args="--namespace=/$(arg robot_name)">
    <param name="publish_frequency" type="double" value="30.0" />
    <param name="tf_prefix" value="/$(arg robot_name)" type="str"/>
  </node> 
  <rosparam command="load" file="$(find joint_state_controller)/joint_state_controller.yaml" ns="/$(arg robot_name)"/>

  <node name="controller_spawner_$(arg robot_name)" pkg="controller_manager" type="spawner" ns="/$(arg robot_name)" 
        respawn="false" args=" joint_state_controller --namespace=/$(arg robot_name)" output="screen"/>

</launch>

I cannot visualize anything in Rviz. Therobot spawns upside down, the camera is blank. image description

Here's the rostopic list output.

wally1002@wally:~$ rostopic list
    /clock
    /gazebo/link_states
    /gazebo/model_states
    /gazebo/parameter_descriptions
    /gazebo/parameter_updates
    /gazebo/set_link_state
    /gazebo/set_model_state
    /rosout
    /rosout_agg
    /rover1/camera/depth/camera_info
    /rover1/camera/depth/image_raw
    /rover1 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-01-31 15:51:59 -0500

tryan gravatar image

updated 2021-02-01 09:11:35 -0500

There appear to be errors in your RViz Displays panel. You should provide any errors/warnings when posting a question, but I'm guessing you have at least two problems:

  1. In your RViz window, it looks like you have an error with your fixed frame (map?). Try changing your fixed frame to one that you know exists, e.g., /rover1/base_link, or add a static transform from the fixed frame to your robot if nothing else is publishing that transfo. If you don't have a transform to each robot from some common frame, then you won't be able to see them all at once, though. A good way to check that you have all the transforms you need is to look at the output of rosrun rqt_tf_tree rqt_tf_tree.

  2. For the RobotModel display to work, you'll need to set its tf_prefix parameter appropriately for the corresponding robot. Without it, the display searches the global namespace and can't find the tf frames it needs (e.g., /base_link vs /rover1/base_link)

On a side note, I don't think the robot is upside-down in that RViz image; it's probably just placing separate components overlapped at the origin because it doesn't know how to "assemble" them properly (unknown transforms). That would also explain why it's just blank white.


Follow-up Q&A

From all this what I have understood about tf is that it help translating between different coordinated frames right?

You are right, the tf tree tracks frame relationships (coordinate transforms) in ROS. The tf2 package allows developers to create and interact with the tree. Note that there is a an older tf package, but it uses tf2 under-the-hood now anyway.

Is there any good source on how these are generated and can be understood correctly.

Transforms and the tf tree can be confusing at first, but the tf2 wiki and tutorials definitely help.

Is there anyway that I can link all these transforms to /base_link and can visualize all robots at once.

You can link all your robots to an arbitrary frame with static transforms as mentioned in my answer above. RViz will be able to show you all three robots, but it's of limited use aside from testing. Also, I would choose a name other than /base_link for the common fixed frame, like /map or /world. Here's an explanation of standard names (REP-105).

What you probably want eventually is to use a SLAM package to find the transforms between each robot and a fixed world frame, e.g., /map. Then, the tf tree for each robot will be linked as one big tree, and RViz will be able to show them all in the same window. I recommend working through the Husarion tutorials if you haven't already. Multi-robot works the same as single-robot, but you have to take more care with the tf tree.

That brings me to one thing I noticed in the output graph of your tf tree (please, embed pictures ... (more)

edit flag offensive delete link more

Comments

1

When I change the fixed frame to /rover1/base_link I get the camera output for that rover. but when i change it to /base_link there is no camera output. I'm very new to tf's. I don't actually understand how they work and also sorry for not posting the errors. I'm adding the errors and output of rosrun rqt_tf_tree rqt_tf_tree.

Sankeerth gravatar image Sankeerth  ( 2021-01-31 23:58:00 -0500 )edit
1

I have resolved the problem. All I was missing was tf_prefix at the bottom. From all this what I have understood about tf is that it help translating between different coordinated frames right? Is there any good source on how these are generated and can be understood correctly. I'm just a beginner. Thanks for the help.

Sankeerth gravatar image Sankeerth  ( 2021-02-01 05:31:37 -0500 )edit
1

Is there anyway that I can link all these transforms to /base_link and can visualize all robots at once. Now I need to have three windows for three bots.

Sankeerth gravatar image Sankeerth  ( 2021-02-01 05:44:13 -0500 )edit

I updated my answer with some more information. No worries about the errors; we're here to learn, and I'm happy I could help :).

tryan gravatar image tryan  ( 2021-02-01 09:14:35 -0500 )edit

Thank You so much. I will look into them :).

Sankeerth gravatar image Sankeerth  ( 2021-02-01 09:44:15 -0500 )edit

Hi, I have the same problem, I am new to ROS and I don't really understand how to fix it, how did you fix it?

anonymous userAnonymous ( 2021-03-15 15:55:22 -0500 )edit

I have published a static transform.

Sankeerth gravatar image Sankeerth  ( 2021-03-16 03:02:39 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-01-30 06:48:46 -0500

Seen: 295 times

Last updated: Feb 01 '21