opensim-core icon indicating copy to clipboard operation
opensim-core copied to clipboard

added MocoImpulseTrackingGoal .cpp/.h

Open nicos1993 opened this issue 2 years ago • 2 comments

First attempt doing this, so apologies if it isn't correct!

Brief summary of changes

Created a MocoImpulseTrackingGoal (capable of tracking a single axis' impulse at a time; user must add multiple instances of the goal to track separate axes/separate contact groups. This goal is based on the MocoContactTrackingGoal, but instead of first squaring the error term and then summing, in this new goal we sum the errors and then square.

Testing I've completed

I have used the goal to perform tracking simulations with the 2Dwalking example - it seems to be working as anticipated.

CHANGELOG.md (choose one)

  • Uncertain as to what to include here.

This change is Reviewable

nicos1993 avatar Aug 10 '22 23:08 nicos1993

@nickbianco Hey, please review! :-)

nicos1993 avatar Aug 10 '22 23:08 nicos1993

I think my changes should now have been pushed back remotely with message "applied changes from review 1"

nicos1993 avatar Aug 15 '22 21:08 nicos1993

After addressing the comments above, there's a few more things we need to do to add this new goal to OpenSim:

  • In RegisterTypes_osimMoco.cpp, you need to add the Object::registerType() calls for both MocoContactImpulseTrackingGoal and MocoContactImpulseTrackingGoalGroup. (Can you also add a call for MocoContactTrackingGoalGroup under MocoContactTrackingGoal here for me? This will fix the error you were seeing in Matlab for anyone loading a MocoContactTrackingGoal from XML.)
  • Add an include statement in osimMoco.h : #include "MocoGoal/MocoContactImpulseTrackingGoal.h"
  • In this CMakeLists.txt file, add the .h/.cpp file for the new goal like the other goals listed.
  • Add an include statement for the new goal in this file to add support for the goal in the bindings (Matlab and Python).
  • Also for the bindings, add an include statement for the new goal in this file . Note the slightly different format for the include statements here.

nickbianco avatar Aug 16 '22 00:08 nickbianco

Hey Nick,

Thanks for the input! It has been super helpful!!! I think I have made the changes you requested!

nicos1993 avatar Aug 24 '22 22:08 nicos1993

Great job @nicos1993! I'm happy with all of the code changes.

The last thing we need to do is some sort of testing to make sure everything works. For this goal, I think it's sufficient to perform some local tests. When CI builds pass, you can download a Windows artifact from GitHub actions that you install locally. Then you can run a test problem to make sure that the goal works though Matlab and/or Python.

Once that's done, we'll be good to merge.

nickbianco avatar Sep 01 '22 02:09 nickbianco

Hi,

I can confirm I have locally tested on Windows. Modified the 2D walking example in Matlab to track vertical contact impulse from right and left feet - successfully converged.

nicos1993 avatar Sep 06 '22 17:09 nicos1993

Great job @nicos1993!

nickbianco avatar Sep 06 '22 22:09 nickbianco

Great job @nicos1993!

Thanks for the help Nick!

nicos1993 avatar Sep 06 '22 22:09 nicos1993