gazebosim / gz-mujoco

25 stars 4 forks source link

SDFormat to MJCF: Add support for force/torque sensors #50

Closed azeey closed 2 years ago

azeey commented 2 years ago

🎉 New feature

Toward #16

Summary

The handling of //force_torque/frame is a little tricky. My interpretation of the SDFormat spec is that the reported torque is always about the joint origin, so I'm setting the pos of the mjcf site for the sensor to the joint origin regardless of the value in //force_torque/frame. For the rotation, I'm setting the rotation of the mjcf site for the sensor to the rotation of the body indicated by //force_torque/frame.

Test it

test_add_sensor.py test_add_joint.py

Checklist

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

codecov[bot] commented 2 years ago

Codecov Report

Merging #50 (88bc827) into main (7900a5a) will increase coverage by 0.10%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #50      +/-   ##
==========================================
+ Coverage   97.62%   97.73%   +0.10%     
==========================================
  Files          16       16              
  Lines         589      617      +28     
==========================================
+ Hits          575      603      +28     
  Misses         14       14              
Impacted Files Coverage Δ
...ormat_to_mjcf/sdformat_to_mjcf/converters/joint.py 97.43% <100.00%> (+0.51%) :arrow_up:
...rmat_to_mjcf/sdformat_to_mjcf/converters/sensor.py 100.00% <100.00%> (ø)
...format_to_mjcf/sdformat_to_mjcf/sformat_to_mjcf.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7900a5a...88bc827. Read the comment docs.

traversaro commented 2 years ago

The handling of //force_torque/frame is a little tricky. My interpretation of the SDFormat spec is that the reported torque is always about the joint origin, so I'm setting the pos of the mjcf site for the sensor to the joint origin regardless of the value in //force_torque/frame. For the rotation, I'm setting the rotation of the mjcf site for the sensor to the rotation of the body indicated by //force_torque/frame.

Cross-link to a related sdformat issue: https://github.com/gazebosim/sdformat/issues/130 .