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

[Moco] Adding support for `PrescribedController` and future controller types #3701

Closed nickbianco closed 3 months ago

nickbianco commented 4 months ago

Fixes issue #3605

Brief summary of changes

This PR adds support for models with PrescribedControllers in Moco optimizations, and lays some ground work for future controller types that will map OCP controls to Model controls. Therefore, going forward, the relationship between OCP controls and an OpenSim model controls will no longer necessarily be a one-to-one mapping. These changes include support for the two simplest control mapping cases: 1) one-to-one mapping (i.e., current behavior) and 2) controls associated with a PrescribedController are excluded from the OCP.

Changes include:

Testing I've completed

Added a test for PrescribedController to testMocoInterface.cpp.

Looking for feedback on...

CHANGELOG.md (choose one)


This change is Reviewable

aymanhab commented 4 months ago

A drive-by (as called by a colleague), the use of the name allocator would be confusing to anybody who uses containers/c++ constructs that utilize std::allocator (https://en.cppreference.com/w/cpp/memory/allocator) to mean something specific to memory management. Are there other suggestions for the name/alternatives?

nickbianco commented 4 months ago

@aymanhab ControlDistributor would be a reasonable alternative. I waffled between that and ControlAllocator and would be fine swtiching.

aymanhab commented 4 months ago

Love the ControlDistributor name but I'm biased :man_shrugging:

nickbianco commented 4 months ago

I've updated the InputController interface to better support generic control names (i.e., non-actuator control names). I've also made an update where Model control names not included in the trajectories returned by CasADi and tropter are added to the MocoTrajectory returned to the user for convenience. Sorry to expand a bit, but I think this is a pretty essential addition.

Working now on Doxygen documentation.

nickbianco commented 4 months ago

@aymanhab, this is almost ready to merge, did you have anything else you wanted to check/comment on?