If you’re writing a library or app for Stretch that uses the robot’s URDF to do FK, IK, motion planning, perception, etc., consider switching to using the Stretch URDF library to generate URDFs on-the-fly:
import stretch_urdf.urdf_utils as uu
print(uu.get_latest_urdf())
# or get a URDF suitable for inverse kinematics
ik_urdf, fixed_wrist_urdf = uu.generate_ik_urdfs("your_app_name")
self.controller = StretchIKControl(urdf_path=ik_urdf)
Why not include the URDF file in your codebase? Saving a copy of the URDF in your app can cause you trouble later on because
- Physical characteristics of the robot change over time, and it’s common for users to perform “URDF calibration” to create a new URDF that better captures the robot’s offset, skew, and backlash.
- A URDF calibrated to one Stretch won’t work as well on another Stretch. The difference will make FK, IK, etc. perform slightly worse on your users’ robots, and it can be hard to notice or debug the slightly poorer performance.
- Your app might need to add new links/joints to the URDF over time (e.g. to support new end-effectors). Handling this can add a lot of spaghetti code to your app.
Generating URDFs on-the-fly is fast (<100ms) and enables you to treat URDFs like code (i.e. customizations of the URDF are made in code, so they can be check-ed into Git, and if your future code needs a slightly different URDF, you don’t need to tell users to rerun any setup steps). It gives you confidence that your app is using the latest calibration. Get the latest library using:
pip3 install -U hello-robot-stretch-urdf
Recently, the Stretch Web Teleop codebase has switched to using this method (see PR here), and its greatly simplified how the app deals with URDFs. If you’re interested in using this in your code, check out the API docs here. Also, feel free to open a topic on this forum raising any questions or feedback!
Useful Links: