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

Connecting Gazebo and Rviz

asked 2020-03-31 07:57:11 -0600

me_saw gravatar image

updated 2020-04-02 13:24:48 -0600

I'm using a urdf for the model and I spawned it in both gazebo and rviz and I'm also using a plugin for the movement of wheels publishing it by rostopic pub -1 <topic of the wheel> std_msgs/Float32 "data: 0.0"wheel is moving in gazebo but not in rviz and I'm trying joint_state_publisher gui to move in rviz but by this only the wheel is rotating robot moel is not moving

thanks :)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2020-04-02 13:53:09 -0600

me_saw gravatar image

I was using a custom plugin for my model in which I didn't published joint_state becuse of that robot_state_publisher didn't receive the joint values from the model. Now I'm publishing joint_statesso everything's working perfectly

Thank you @Weasfas :)

edit flag offensive delete link more

answered 2020-04-01 08:36:29 -0600

Weasfas gravatar image

Hi @me_saw,

When you spawn the robot in Gazebo is very important to use the Robot State Publisher. The joint_state_publisher is like a debug node to check the joint states with a topic while the robot_state_publisher is the node you need since it is the tool that uses the robot_description to build the tf tree that rviz needs to display your robot properly.

You can launch the robot_state_publisher to generate a tf_tree with:

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

and check you tf_tree with rosrun rqt_tf_tree rqt_tf_tree.

With this set up you will be able to launch rviz and select in the Global Options --> Fixed Frame menu the Reference Link of your description.

edit flag offensive delete link more


I added the node of robot_state_publisher and i checked the tf_tree evreything is working fine but still no nothings happening in rviz

me_saw gravatar image me_saw  ( 2020-04-01 08:58:35 -0600 )edit

But just now checked rqt_graphjoint_state_publisher and robot_state_publisher are connected via/joint_states but they are not connected to /gazebo

me_saw gravatar image me_saw  ( 2020-04-01 09:08:15 -0600 )edit

Mmm that is weird, Usually, if there is something wrong rviz reports it. Have you tried to add the TF and RobotModel Display Types?

Maybe the problem is that you are using both nodes at the same time, I mean, if you launch the RST there is no need to launch the JSP because Gazebo is already publishing the Joint states. Try launching only the RST, you will see in the rqt_grap that the /joint_state topic goes to the RST node.

Weasfas gravatar image Weasfas  ( 2020-04-01 09:33:59 -0600 )edit

I added TF and RobotModel display If I add only robot state and remove joint state then rviz is not loading the joints of the model And i checked Gazebo's topic it doesn't have topic joint state

me_saw gravatar image me_saw  ( 2020-04-01 09:59:18 -0600 )edit

Ok, To clarify things. When you launch Gazebo you are dealing with an abstraction of a real robot, hence you will need to provide a method to read from the joint states and publish that information. So either you have a plugin that reads from the Gazebo joints and publish the joint state information the RST publisher needs to build the TF tree, or you use already made tools like the joint_state_controller/JointStateController inerface provided in ROS control. You can find a tutorial here. The important part is the addition of transmissions and the load of the JointStateController controller interface.

Weasfas gravatar image Weasfas  ( 2020-04-01 11:13:30 -0600 )edit

I followed that tutorial and created transmission for my model and I also created controller .yaml file and launched that file too it gives me this error Failed to start controller in realtime loop. This should never happen

me_saw gravatar image me_saw  ( 2020-04-01 11:58:10 -0600 )edit

Hi @me_saw,

That error is very rare, it comes from this function on ros_control impementation, and it is related with how the controllers are loaded and stopped in execution, so you could take a look at how you load those controllers and if the names and joints are all corrects. I have tried to reproduce that error but with no avail, thus, allow me to say that is nearly impossible for me or anyone in this forum to help you in this problems if you not provide any description or launch file that you are using. I mean you can make another post with this particular problem but it is likely other people is going to ask for any fil, output etc, so it is important what was the process you followed to get that error, how is your model description and how you launch those things. These are relevant ...(more)

Weasfas gravatar image Weasfas  ( 2020-04-01 13:37:57 -0600 )edit

This should be the correct answer. Thank you.

CroCo gravatar image CroCo  ( 2022-05-21 17:17:30 -0600 )edit

Question Tools

1 follower


Asked: 2020-03-31 07:57:11 -0600

Seen: 2,750 times

Last updated: Apr 02 '20