PDA

View Full Version : Understanding URDF files and rviz in ROS



Pi Robot
10-22-2010, 09:30 PM
I'm trying to make a simple model of Pi Robot using URDF so I can view it in rviz and I'm having a heck of a time getting it right. I thought this would be really easy but I must be missing something obvious.

Here is an example of the kind of trouble I am having. I am starting with just 3 links and 2 joints: the base_link, the torso_link and the neck_link as well as the torso_joint (connecting base and torso) and the neck_joint (connecting torso and neck). The torso joint is revolute and the neck joint is fixed. (The pan and tilt joints will be mounted on top of the neck.)

So here is the URDF file that I think should work:



<robot name="pi_robot">
<link name="base_link">
<visual>
<geometry>
<box size="0.32 0.26 0.22" />
</geometry>
<material name="Cyan">
<color rgba="0 1 1 1.0"/>
</material>
</visual>
</link>

<link name="torso_link">
<visual>
<geometry>
<cylinder radius="0.07" length="0.24" />
</geometry>
<material name="Yellow">
<color rgba="1 1 0 1.0"/>
</material>
</visual>
</link>

<link name="neck_link">
<visual>
<geometry>
<box size="0.05 0.05 0.05" />
</geometry>
<material name="Green">
<color rgba="0 1 0 1.0"/>
</material>
</visual>
</link>

<joint name="torso_joint" type="revolute">
<parent link="base_link" />
<child link="torso_link" />
<origin xyz="0 0 0.22" rpy="0 0 0" />
<axis xyz="0 1 0" />
<limit lower="-3.1416" upper="3.1416" effort="10" velocity="3" />
</joint>

<joint name="neck_joint" type="fixed">
<parent link="torso_link" />
<child link="neck_link" />
<origin xyz="0 0 0.24" rpy="0 0 0" />
<axis xyz="0 1 0" />
</joint>

</robot>

I would think that these parameters would stack the yellow cylinder (torso) on top of the cyan box (base) and a smaller green box (neck) on top of the cylinder. So I run the joint_state_publisher and robot_state_publisher nodes, then fire up RViz and add a Robot Model display type. The yellow cylinder and cyan box look correctly proportioned and positioned on top of one another. But the small green box sits far *above* the cylinder, not right on top of it as I thought it should.

Here is my launch file and below that is the image from RViz:



<launch>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="robot_description" command="cat $(find pi_robot)/urdf/pi_robot_urdf.xml" />
</node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
</launch>
http://forums.trossenrobotics.com/attachment.php?attachmentid=2165&stc=1&d=1287800786


Notice how the small green box (neck link) sits too far above the yellow cylinder (torso link). The cylinder is 0.24 meters long so I would think the correct z displacement in the neck joint definition would also be 0.24, which is what I have set but is clearly incorrect. Can anybody see what I am doing wrong?

Thanks!
patrick

lnxfergy
10-22-2010, 09:35 PM
Patrick --

The visualization is *centered* on the frame origin -- and I think this is your issue. If you move the origin of the visualization, things will start to line up.

-Fergs

Pi Robot
10-22-2010, 09:55 PM
Patrick --

The visualization is *centered* on the frame origin -- and I think this is your issue. If you move the origin of the visualization, things will start to line up.

-Fergs

Oh for crying out loud--that was it of course! Works great now. BTW, do you know how to get rviz to re-read the robot description file without having to do a Remove/Add of the Robot Model? Restarting the state nodes seems to immediately update rviz with respect to changes in the joint parameters in the URDF but not those in the links. To see changes to the links, I have to do a Remove/Add of the Robot Model.

--patrick

lnxfergy
10-22-2010, 09:59 PM
Oh for crying out loud--that was it of course! Works great now. BTW, do you know how to get rviz to re-read the robot description file without having to do a Remove/Add of the Robot Model? Restarting the state nodes seems to immediately update rviz with respect to changes in the joint parameters in the URDF but not those in the links. To see changes to the links, I have to do a Remove/Add of the Robot Model.

--patrick

Just click the checkbox to disable then enable the robot model display (note, this doesn't work for meshes -- to reload meshes you have to actually re-load the entire program I've found)

-Fergs

Pi Robot
10-22-2010, 10:04 PM
Ah, cool. I really should have asked you these questions earlier and I could have saved an entire day of banging my head against the wall...

Thanks again.

--patrick

Pi Robot
10-23-2010, 11:14 PM
And here is the result of the first draft of the URDF file for Pi Robot:

http://forums.trossenrobotics.com/attachment.php?attachmentid=2167&stc=1&d=1287893608

lnxfergy
10-23-2010, 11:20 PM
Cool -- next step: meshes::veryhappy:
http://forums.trossenrobotics.com/attachment.php?attachmentid=2168&stc=1&d=1287894020

-Fergs

Pi Robot
10-23-2010, 11:22 PM
Very nice!! I haven't a clue how to do that. Can you recommend where I should start. I don't have any CAD experience but I've been meaning to give it a go one of these days.

--patrick

lnxfergy
10-23-2010, 11:42 PM
Very nice!! I haven't a clue how to do that. Can you recommend where I should start. I don't have any CAD experience but I've been meaning to give it a go one of these days.

--patrick

Where to start: a CAD package that outputs STL files. Basically, once you've drawn your parts up, you need to export them in STL files. Some caveats I've found doing this: measurement units should be meters, or size is off, parts to need to be centered where the coordinate frame is, and orientation needs to be correct (or you have to put lots of origin stuff in your urdf). Inventor exports ascii-STL files -- to get them to show up in color, I had to then run another tool over the files to convert them to binary-STL. I'm a pretty decent Inventor power-user, and it still took me a full day to get everything right for the arms shown above (every change in Inventor lead to an "export stl, scp to ROS box, convert stla to stlb, reload RViz" cycle).

-Fergs

Pi Robot
10-24-2010, 09:28 AM
Thanks Fergs--sounds like I'll leave the mesh stuff for a long rainy week (or three). Next I want to get your joint controller up and running and watch the results in RViz alongside the real movement on the robot. Will post back to the ArbotiX/ROS thread once I get it working.

--patrick