ROAM-Lab-ND / spatial_v2_extended

Extended version of Featherstone's spatial_v2 package
46 stars 24 forks source link

add urdf parser #2

Closed YunxiTang closed 4 days ago

YunxiTang commented 2 years ago

Hi, I am just wondering whether you have any plans to add some urdf parser, which can be a connection between the original robot model data structure and URDF files. It will be much more convenient to use such a wonderful package. It sometimes took a long time to build a robot model in a m-file. Thanks!

pwensing commented 2 years ago

Thanks for the idea. I hadn’t thought about that before (but probably should have). One path could be leveraging the MATLAB robot systems toolbox and then converting their rigid body tree object to a spatial_v2 model. https://www.mathworks.com/help/robotics/ref/importrobot.html

I don’t think this would be too bad to implement, but, or course it would be preferable if the solution limited dependences this extra toolbox.

I would also be very open to any pull requests on this item, as my development time is pretty limited these days.

pwensing commented 5 months ago

Very long overdue follow-up here, but I finally implemented the conversion from URDF to spatial_v2 model in 9fc4dd4. See for example v3/models/UDRF_to_spatialv2_model.m.

The one thing to keep in mind here is that spatial_v2 works with all frames immediately following each joint (e.g., if you have a revolute joint about z attaching body i to its parent, then frame i is attached to the body i with $\hat{z}_i$ along the joint axis.) The URDF could be used to define a separate frame on the link itself, which is not used in spatial_v2. So, all the inertial properties in the URDF are converted over from that link frame, to the one after the joint.

Please let me know if you have any feedback, suggestions, or issues.