hello-robot / stretch_ros

ROS packages for the Stretch mobile manipulators from Hello Robot Inc.
https://docs.hello-robot.com/0.2/stretch-tutorials/ros1/
167 stars 84 forks source link

Distributing compiled URDF files? #98

Closed stephane-caron closed 1 year ago

stephane-caron commented 1 year ago

Hello and thanks for maintaining this repository :smiley:

I was wondering if you would consider distributing compiled URDF files alongside Xacro files?

Distributing URDF files is common in open source robot descriptions on GitHub. For instance, in the Awesome Robot Descriptions list, 57 / 79 descriptions are URDF while 9 / 79 are Xacro-only.

Distributing URDF also makes it one-shot to load the robot description in popular (non-ROS) software such as Pinocchio and PyBullet, for instance via robot_descriptions.py:

from robot_descriptions.loaders.pinocchio import load_robot_description

stretch = load_robot_description("stretch_description")

Right now this snippet will load the description from this repository, but it would be better if it would load the description straight from the official repository.

hello-binit commented 1 year ago

Hi @stephane-caron, thanks for raising this request. I'd like to provide a little bit of context on why we've stuck to XACROs and haven't included compiled URDFs in the Stretch Description package yet, and perhaps hear your thoughts on how we can make it easier for simulators like Pinocchio/PyBullet to import Stretch's URDF.

First, there are two models of Stretch to date: Stretch RE1 (began shipping summer 2020) and Stretch 2 (began shipping summer 2022). The two models are kinematically identical, so the URDFs are very similar but the meshes are different. Here's what the Stretch 2 looks like visually:

stretch 2

It would be relatively easy to distribute a URDF for each model, but the reason I bring this up is because I noticed the robot-descriptions/stretch_description repo seems to be missing a URDF for the newer Stretch 2 model.

Second, there are multiple end-effectors available for Stretch and it's generally very easy to swap between them. The two most popular, the Stretch Compliant Gripper and the Stretch Dex Wrist are shown here:

Stretch Compliant Gripper Stretch Dex Wrist
standard gripper dex wrist

Beyond these two, there's end-effector tools for USB cameras, tablets, phones, dry erase markers, Swiffers, ReactorX wrist, and a cup tray. These tools come with their own XACROs and meshes, and we've provided instructions for swapping in the correct XACRO for the attached tool in order to allow users to compile the URDF as needed. If we were to include compiled URDFs in Stretch Description, we would need to either include one for each tool (although new tools are created frequently) or select a subset of the tools for which to provide the compiled URDFs. One URDF cannot include all the tools available to use with Stretch.

Third, the two gripper tools, the Stretch Compliant Gripper and Stretch Dex Wrist are "compliant" grippers. This video shows how the grippers deforms around the object to provide a very sturdy grip on the object. To date, URDFs only support a few types of joints (e.g. revolute, prismatic, etc.) between rigid links. Some simulators have support for deformable links, however, you would have to carefully characterize the bend of the gripper's spring steel in order to create a simulation with high fidelity to the real grippers.

unrealistic gripper

At the moment, the two fingers in these tools are modeled as two rigid fingers with revolute joints that can move independently of each other. If the Pinocchio/PyBullet simulation of Stretch were to import a compiled URDF with this model of the fingers, the grasping fidelity would be poor and any learned policy would transfer to the real robot poorly.

Fourth, and finally, Stretch robots ship from the factory with "calibrated" URDFs, where the link offsets and backlashes are calibrated by the robot looking at itself and detecting the Aruco markers on itself. The open source calibration software aggregates a dataset of detections from a variety of robot configurations in order to optimize a solution for the URDF's offsets and backlashes. This calibration plays a large part in enabling Stretch to successfully grasp objects in the environment and deal with "hand eye misalignment". Here's what the difference looks like:

aligned point cloud w/robot

Each calibrated URDF is unique to a Stretch. Likely, any policy learned on a simulated Stretch would have a better chance of transferring over to the real Stretch if the simulated Stretch were based on the calibrated URDF.

Hopefully, this helps provide context on some of the concerns with providing a compiled URDF of Stretch. It is my expectation that handling these "gotchas" is important if we want simulations of Stretch to accurately simulate how the real robot behaves in the world.

stephane-caron commented 1 year ago

Thank you @hello-binit for sharing this context!

Regarding the Stretch 2 model:

It would be relatively easy to distribute a URDF for each model, but the reason I bring this up is because I noticed the robot-descriptions/stretch_description repo seems to be missing a URDF for the newer Stretch 2 model.

Absolutely, I don't have ROS installed and setting up an environment where xacro runs would be too much of a sidetrack for now. But I'd gladly merge PRs for other models if that's helpful.

I understand your technical decision in light of having configurable end-effectors and a calibrated robot model. In Pinocchio or iDynTree one can customize the robot model at runtime after loading e.g. a base URDF, but it is indeed a pro of xacro to be able to separate (1) configuration/calibration/compilation from (2) execution.

From my point of view it wouldn't hurt to provide a sample URDF for testing and sharing ROS-free code (e.g. this example of weighted inverse kinematics with Stretch RE1 just checks that the algorithm work, which doesn't require a calibrated model), but I understand from a support point of view there may be other arguments against it (e.g. if a pre-compiled URDF is available, new users could be tempted to skip calibration and just use it).

I'll be closing this issue :ok_hand: