opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
759 stars 308 forks source link

Extend implementations of task space control to support floating-base models #3636

Open nathantpickle-cfdrc opened 7 months ago

nathantpickle-cfdrc commented 7 months ago

Background Task space control is commonly used in robotics, but has not been as widely utilized in biomechanics. Several efforts have been made to implement task space control, such as in the OpenSim Core Sandbox, Simbody examples, and external projects. However, these implementations do not support floating base models, where the root segment (e.g., pelvis) is free to move in 6DOF. This prevents use of task space control in common biomechanical simulations such as gait.

Use Cases Task space control can be used to express movements in terms of high-level objectives, such as end effector (e.g., hand or foot) or center of mass kinematics. Thus, task space control has utility in research in neural control of movement. Task space control can be a useful alternative to other predictive simulation paradigms such as Moco.

Planned Functionality Our group has implemented a formulation of task space control that supports floating base models, and can be used to generate gait and other human movement simulations. Our implementation relied heavily on Dimitar Stanev's work in this area. We would like to contribute our code back to OpenSim Core so it can be supported as standard functionality in OpenSim. Our contribution will include the following features:

Timeline We are conducting final testing in preparation for submitting a pull request. We anticipate being ready to submit the pull request in the next few weeks.

nickbianco commented 7 months ago

Hi @nathantpickle-cfdrc. Thank you for the project overview and heads up on the PR. This sounds like a great contribution to the OpenSim simulation toolbox. Let me know if you have any questions. In the meantime, I encourage you and your team to review the CONTRIBUTING.md guidelines, especially if it will be a larger contribution.

nathantpickle-cfdrc commented 7 months ago

Thanks @nickbianco. We'll go through the contributing guidelines as we're finalizing the PR.

nathantpickle-cfdrc commented 5 months ago

We've done some refactoring and are in the final stages of preparing the PR. The task space framework now ties in better with OpenSim's Component architecture, and the number of files has been reduced.

In the latest refactor, nearly all of the functionality is in a class called TaskBasedTorqueController, which inherits from Controller.

There are several associated classes for defining tasks, which are very similar to other existing Task classes (e.g., CMC, IK). There are also still a few utility/convenience functions, which could potentially get absorbed into other existing utility classes.

The structure of the new files is very similar to CMC, so for now I am putting all the files in OpenSim\Tools and prefixing them with TaskSpace for easy identification during review.

Because the new task classes are so similar to the existing CMC/IK task classes and will likely live in the same directory, it will probably be worth discussing the possibility of merging the new functionality with existing classes. I have some questions though about how best to do that, so I'll keep them separate until the dev team has a chance to review and see what makes the most sense going forward.

nickbianco commented 5 months ago

Thanks for the update @nathantpickle-cfdrc. It sounds like you have everything consolidated and indeed are ready for a PR. Feel free to open one whenever you are ready and we can get a review started. A few quick thoughts before you get started:

The structure of the new files is very similar to CMC, so for now I am putting all the files in OpenSim\Tools and prefixing them with TaskSpace for easy identification during review.

You could also consider putting everything under a subfolder (e.g., /TaskSpace).

Because the new task classes are so similar to the existing CMC/IK task classes and will likely live in the same directory, it will probably be worth discussing the possibility of merging the new functionality with existing classes.

Actually, my gut feeling would be to stick to separate files since it would probably be easier to review and maintain that way. But we can discuss options in the PR review.

nathantpickle-cfdrc commented 4 months ago

Thanks @nickbianco. I just submitted the pull request.

For now I've left the classes in the Tools directory, but we can certainly move them if that would make more sense.

Looking forward to further discussion!

nickbianco commented 4 months ago

Sounds good, @nathantpickle-cfdrc! I'll take a look at the PR soon.

nathantpickle-cfdrc commented 4 months ago

The manuscript preprint associated with this issue is now available on bioRxiv:

https://www.biorxiv.org/content/10.1101/2024.02.13.580044v1

Also, tagging @mitkof6 for awareness.