MarkersReference in Python

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
POST REPLY
User avatar
Carlos Gonçalves
Posts: 135
Joined: Wed Jun 08, 2016 4:56 am

MarkersReference in Python

Post by Carlos Gonçalves » Wed May 05, 2021 2:10 pm

Hello,

I came across this issue when calling markersRef = osim.MarkersReference('somethig.trc', markerWeights)

Code: Select all

Traceback (most recent call last):
  File "C:/Users/12833/Documents/Proj. OpenSim/Estudo_Isabela_D197748_G29D21LN/analiseMarcha.py", line 738, in <module>
    simGait("tracking")
  File "C:/Users/12833/Documents/Proj. OpenSim/Estudo_Isabela_D197748_G29D21LN/analiseMarcha.py", line 693, in simGait
    solution = gaitTrackingMarkers(listParameters, parmDict, model, "sim" + str(count).zfill(2), 0, path)
  File "C:/Users/12833/Documents/Proj. OpenSim/Estudo_Isabela_D197748_G29D21LN/analiseMarcha.py", line 413, in gaitTrackingMarkers
    markersRef = osim.MarkersReference(parameters[parmDict['markerFile']], markerWeights)
  File "C:\Anaconda3\envs\opensim42\lib\site-packages\opensim-4.2_2021_03_12_fcedec9-py3.7.egg\opensim\simulation.py", line 73841, in __init__
    this = _simulation.new_MarkersReference(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_MarkersReference'.
  Possible C/C++ prototypes are:
    OpenSim::MarkersReference::MarkersReference()
    OpenSim::MarkersReference::MarkersReference(std::string const &,OpenSim::Set< OpenSim::MarkerWeight > const &,OpenSim::Units)
    OpenSim::MarkersReference::MarkersReference(std::string const &,OpenSim::Set< OpenSim::MarkerWeight > const &)
    OpenSim::MarkersReference::MarkersReference(OpenSim::TimeSeriesTable_< SimTK::Vec3 > const &,OpenSim::Set< OpenSim::MarkerWeight > const &,OpenSim::Units)
    OpenSim::MarkersReference::MarkersReference(OpenSim::TimeSeriesTable_< SimTK::Vec3 > const &,OpenSim::Set< OpenSim::MarkerWeight > const &)
In the examplePredictAndTrack.py I found this:

Code: Select all

# TODO fails when MarkersReference is passed to MocoMarkerTrackingGoal
# trackedSolution = solveMarkerTracking(markersRef, trackedSolution)
Is there a solution to add a MocoMarkerTrackingGoal in Python? I tried to create the MarkersReference object and use .set_markers_file (worked) and set_markers_weight (failed) but with no success.

Any help?

Best regards.

Carlos

User avatar
Nicholas Bianco
Posts: 1041
Joined: Thu Oct 04, 2012 8:09 pm

Re: MarkersReference in Python

Post by Nicholas Bianco » Wed May 05, 2021 6:14 pm

Hi Carlos,

Can we double check what type the "markerWeights" variable is (you can do this by looking at your Matlab workspace variables)? Is is type "MocoWeightSet" or "MarkerWeightSet"? It should be "MarkerWeightSet".

Best,
Nick

User avatar
Carlos Gonçalves
Posts: 135
Joined: Wed Jun 08, 2016 4:56 am

Re: MarkersReference in Python

Post by Carlos Gonçalves » Thu May 06, 2021 10:17 am

It worked!!!

It was just "copy and paste" syndrome ....

I copied the code lines from my previous try with MocoTrack ... There it is MocoWeightSet (exampleMocoTrack.py)...

Thanks a lot!

Now I will move on to the next errors, hehehe

Best regards.

Carlos

User avatar
Nicholas Bianco
Posts: 1041
Joined: Thu Oct 04, 2012 8:09 pm

Re: MarkersReference in Python

Post by Nicholas Bianco » Mon May 10, 2021 7:33 pm

Great! Glad it's working now.

Hopefully not too many more error haha.

POST REPLY