0
$\begingroup$

Rosanswers logo

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.

RVIZ :

    <launch>
    <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" />
</launch>

Gazebo:

<launch>
<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>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
</launch>

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.

thanks!


Originally posted by arzhed on ROS Answers with karma: 143 on 2012-09-24

Post score: 0


Original comments

Comment by arzhed on 2012-09-24:
Thank you very much for the quick clear answer!

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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 robot_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.


Originally posted by Lorenz with karma: 22731 on 2012-09-24

This answer was ACCEPTED on the original site

Post score: 8


Original comments

Comment by zisikons on 2016-07-18:
You probably mean the robot_state_publisher subscribes to /joint_states topic and publishes the corresponding TF tree.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.