Ask Your Question

Controlling joints in Gazebo

asked 2012-09-24 04:56:22 -0500

arzhed gravatar image

updated 2012-09-24 05:34:44 -0500

Lorenz gravatar image

Hi everyone

I am new to ROS and Gazebo and I got problems into using the joint_state_publisher package. I have a robot with multiple non-fixed joints. I created 2 launch files : one to display the robot in rviz, the other to display in Gazebo.


    <arg name="model" />
    <arg name="gui" default="False" />
    <param name="robot_description" textfile="$(arg model)" />
    <param name="use_gui" value="$(arg gui)"/>
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node>
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find urdf_tutorial)/urdf.vcg" />


<include file="$(find gazebo_worlds)/launch/empty_world.launch"/> 
<arg name="model"/>
<arg name="gui" default="False" />
<param name="robot_description" textfile="$(arg model)" />
<node name="spawn_emox" pkg="gazebo" type="spawn_model" args="-urdf -param robot_description -z 5 -model emox" respawn="false" output="screen"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" >
    <param name="use_gui" value="$(arg gui)"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />

By setting the "gui" argument to "true", I can control the joints on rviz via the joint_state_publisher, but this doesn't work on Gazebo.

Using rxgraph, I see something like that :

/joint_state_publisher---> /robot_state_publisher ---> /rviz ---> /rosout

/gazebo ---> /joint_state_publisher---> /robot_state_publisher ---> /rosout

Actually, /gazebo publishes a /clock topic to both joint_state_publisher and robot_state_publisher, whereas /rviz subscribes to the /tf topic (as expected).

Does anyone know if gazebo can be set as a /tf subscriber? Or any other solution to control the robot in gazebo? Would the pr2_mechanism stack be adapted?

Sorry about the beginner question and the poor english.


edit retag flag offensive close merge delete


Thank you very much for the quick clear answer!

arzhed gravatar image arzhed  ( 2012-09-24 06:05:18 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-09-24 05:39:57 -0500

Lorenz gravatar image

RViz is just visualizing your robot while Gazebo is a complete simulation environment that simulates a complete robot, including its joints and the motors connected to them.

In case of rviz, running the joint_state_publisher node creates a publisher on the joint_states topic. The joint_state_publisher then subscribes to that topic and publishes the corresponding TF tree.

In gazebo you must not run the joint_state_publisher. Instead, you need to run controller plugin (e.g. the gazebo_ros_controller_manager) that reads the joint states from the simulated robot and publishes them on the joint_states topic. You cannot move the robot by just publishing different joint states since joint states represent the current state of the robot, not a goal. Instead you need to run controllers that apply forces at the simulated joints.

edit flag offensive delete link more


You probably mean the robot_state_publisher subscribes to /joint_states topic and publishes the corresponding TF tree.

zisikons gravatar image zisikons  ( 2016-07-18 14:15:13 -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



Asked: 2012-09-24 04:56:22 -0500

Seen: 5,060 times

Last updated: Sep 24 '12