cmower / optas

OpTaS: An optimization-based task specification library for trajectory optimization and model predictive control.
https://cmower.github.io/optas/
Other
99 stars 14 forks source link

RNEA method #125

Closed Tianhuanyu closed 1 year ago

Tianhuanyu commented 1 year ago

Description

The RNEA method is added to model module of optas for computing inverseDynamics. Given q, qd, qdd, the function could return a external force vector.

The RNEA is tested with test_rnea.py

The current version of RNEA only supports the robots with:

  1. resolute joints,
  2. the first joint of robot fixed,
  3. no fixed joints except the first joint and the last joint.

Todo

cmower commented 1 year ago

Please also address the todo list in the PR description above.

cmower commented 1 year ago

Could you also make sure to add a unit test in tests/test_models.py. It would be great if you could generate random q, dq, ddq and check the output of your function against the output of PyBullet RNEA method to ensure it is at-least numerically equivalent.

Tianhuanyu commented 1 year ago

Thanks @Tianhuanyu! This is great! I have some feedback (please see comments). Also, you should run black on the files you modify - this will ensure the code formatting is correct.

Thanks, @cmower . I try black for reformatting my code. It's fantastic. All the following parts are done within this update.

Tianhuanyu commented 1 year ago

Could you also make sure to add a unit test in tests/test_models.py. It would be great if you could generate random q, dq, ddq and check the output of your function against the output of PyBullet RNEA method to ensure it is at-least numerically equivalent.

Sure, but I find there is always a small error between PyBullet output and our RNEA. (around 0.5% or less). Maybe Pybullet uses a different method for computing inverse dynamics or it may consider friction. Currently, the error doesn't have much effect on my application. It maybe a long-term work to find out why the numbers are slightly different.

Tianhuanyu commented 1 year ago

Hi @Tianhuanyu, thanks for the updates. Just a couple more changes.

Also, could you please add a unit test (that compares RobotModel.rnea to PyBullet) into tests/test_models.py. The small error you see is fine. As you mention, PyBullet probably takes into account friction or maybe other things. The test is good to have though because it verifies i) you're implementation is working (i.e. the code runs), and ii) the values it outputs are "pretty much" what we expect. Take a look here for more details about the implementation of RNEA in PyBullet.

Thanks. @cmower I've submitted the modification for the two minor suggestion. I will submit the testing part as soon as possible.

cmower commented 1 year ago

Great, thanks @Tianhuanyu.

cmower commented 1 year ago

@Tianhuanyu, please could you rebase this branch. There are new commits to the master branch.