How to compute cost breakdown given trajectory?

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
Jiacheng Weng
Posts: 26
Joined: Wed Jan 15, 2020 1:05 pm

How to compute cost breakdown given trajectory?

Post by Jiacheng Weng » Wed Mar 03, 2021 12:45 pm

Hi all,

Let's say I have a predictive study defined as MocoStudy with cost terms C1 and C2. After solving the problem using study.solve(), I obtain the optimal trajectory A. I can access the cost breakdown of trajectory A (values of C1 and C2 term) either in the MocoSolution, or the header of the generated .sto trajectory file.

Question: now, if I have another trajectory B that is dynamically feasible but is not obtained from the predictive study (e.g. from tracking), how can I evaluate the cost breakdown of the trajectory B with the cost formulation from the previous predictive study (values of C1 and C2 term)? In another word, how can we obtain the cost breakdown of a trajectory without modifying the trajectory in Moco?

I tried to run study.solve() with only 1 iteration to get an approximation of the cost breakdown, but this approximation is not completely the same as the true values since the trajectory has been updated slightly.

Thanks,
Jiacheng

POST REPLY