How to visualize a real robot in Rviz
How do you run Rviz so that it shows the joint positions of a real robot in real-time?
I've written a URDF file descibing a simple 2-wheeled cylindrical robot with a pan/tilt head, and I can visualize it in Rviz perfectly by running the launch file:
<launch>
<arg name="model" default="$(find myrobot_description)/urdf/myrobot.urdf.xacro"/>
<arg name="gui" default="true" />
<arg name="rvizconfig" default="$(find myrobot_description)/rviz/urdf.rviz" />
<param name="robot_description" command="$(find xacro)/xacro.py $(arg model)" />
<param name="use_gui" value="$(arg gui)"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
</launch>
I also implemented a node, running on the actual robot, that publishes angles of the pan/tilt head as JointState messages on the /joint_state topic, and when I manually move the joints, rostopic echo /joint_states
shows messages like:
header:
seq: 21
stamp:
secs: 1474249855
nsecs: 537719964
frame_id: ''
name: ['base_link_to_neck_joint']
position: [6.230825429619756]
velocity: []
effort: []
However, when I run that same launch file on the robot, along with my custom joint publisher node, Rviz only shows the joints flicker briefly, then reset back to the default position. Why is this?
I tried removing the joint_state_publisher node in the launch file, thinking that was interfering with my custom publisher, but then when I launch Rviz, my model looks all mangled and it reports "no transformation" for all of my links. How do I fix that?