Struggling with MocoOutputGoals
Posted: Mon Feb 14, 2022 9:07 am
Hello,
I can't figure out how to get MocoOutputGoal costs to work through the Matlab or C++ API's.
Here's how I've been defining the goals:
As you can probably tell by the naming, I've been trying with the model potential/kinetic energy paths, but when that didn't work I also tried with other outputs (e.g. actuation levels).
The (rather messy) output I get from trying to run this is:
Can anyone see anything obvious that I'm doing wrong here?
Cheers,
Daniel
I can't figure out how to get MocoOutputGoal costs to work through the Matlab or C++ API's.
Here's how I've been defining the goals:
Code: Select all
// Set up kinetic energy goal
if (w_kinetic > 0)
{
auto* kinetic_goal = problem.addGoal<MocoOutputGoal>("kinetic", w_kinetic);
kinetic_goal->setOutputPath(kinetic_path);
kinetic_goal->setDivideByDisplacement(true);
kinetic_goal->setDivideByMass(true);
}
// Set up potential energy goal
if (w_potential > 0)
{
auto* potential_goal = problem.addGoal<MocoOutputGoal>("potential", w_potential);
potential_goal->setOutputPath(potential_path);
potential_goal->setDivideByDisplacement(true);
potential_goal->setDivideByMass(true);
}
The (rather messy) output I get from trying to run this is:
The exact same code works fine if I add, for example, an effort term using a MocoControlGoal, so it seems to me it must be something to do with how I'm specifying these output goals, but as far as I can tell I've followed the same format as used in the example2DWalkingMetabolics.cpp example.CasADi - CasADi - CasADi - CasADi - CasADi - CasADi - CasADi - CasADi - 2022-02-14 15:58:232022-02-14 15:58:23 WARNING("Exception raised: Error in Function::operator() for 'map13_cost_kinetic_integrand' [Map] at .../casadi/core/function.cpp
Error in Function::operator() for 'cost_kinetic_integrand' [CallbackInternal] at .../casadi/core/function.cpp
.../casadi/core/function_internal.cppFailed to evaluate 'eval_dm' for cost_kinetic_integrand:
.../casadi/core/callback_internal.cpp:122: Error calling "eval" for object cost_kinetic_integrand:
SimTK Exception thrown at State.cpp:974:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date at Stage Velocity. This entry depends on version 2 of Stage Velocity but was last updated at version 0.
(Required condition 'version == m_dependsOnVersionWhenLastComputed' was not met.)
") [.../casadi/core/map.cpp:419]
2022-02-14 15:58:23 WARNING("2022-02-14 15:58:23 WARNING(" WARNING("Exception raised: Error in Function::operator() for 'map13_cost_kinetic_integrand' [Map] at .../casadi/core/function.cpp
Error in Function::operator() for 'cost_kinetic_integrand' [CallbackInternal] at .../casadi/core/function.cpp
.../casadi/core/function_internal.cppFailed to evaluate 'eval_dm' for cost_kinetic_integrand:
.../casadi/core/callback_internal.cpp:122: Error calling "eval" for object cost_kinetic_integrand:
SimTK Exception thrown at State.cpp:974:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date at Stage Velocity. This entry depends on version 2 of Stage Velocity but was last updated at version 0.
(Required condition 'version == m_dependsOnVersionWhenLastComputed' was not met.)
") [.../casadi/core/map.cpp:419Exception raised: Error in Function::operator() for 'map13_cost_kinetic_integrand' [Map] at .../casadi/core/function.cpp
Error in Function::operator() for 'cost_kinetic_integrand' [CallbackInternal] at .../casadi/core/function.cpp
.../casadi/core/function_internal.cppFailed to evaluate 'eval_dm' for cost_kinetic_integrand:
.../casadi/core/callback_internal.cpp:122: Error calling "eval" for object cost_kinetic_integrand:
SimTK Exception thrown at State.cpp:974:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date at Stage Velocity. This entry depends on version 2 of Stage Velocity but was last updated at version 0.
(Required condition 'version == m_dependsOnVersionWhenLastComputed' was not met.)
2022-02-14 15:58:23 WARNING("Exception raised: Error in Function::operator() for 'map13_cost_kinetic_integrand' [Map] at .../casadi/core/function.cpp
Error in Function::operator() for 'cost_kinetic_integrand' [CallbackInternal] at .../casadi/core/function.cpp
.../casadi/core/function_internal.cppFailed to evaluate 'eval_dm' for cost_kinetic_integrand:
.../casadi/core/callback_internal.cpp:122: Error calling "eval" for object cost_kinetic_integrand:
SimTK Exception thrown at State.cpp:974:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date at Stage Velocity. This entry depends on version 2 of Stage Velocity but was last updated at version 0.
(Required condition 'version == m_dependsOnVersionWhenLastComputed' was not met.)
") [") [Exception raised: Error in Function::operator() for 'map13_cost_kinetic_integrand' [Map] at .../casadi/core/function.cpp
Error in Function::operator() for 'cost_kinetic_integrand' [CallbackInternal] at .../casadi/core/function.cpp
.../casadi/core/function_internal.cppFailed to evaluate 'eval_dm' for cost_kinetic_integrand:
.../casadi/core/callback_internal.cpp:122: Error calling "eval" for object cost_kinetic_integrand:
SimTK Exception thrown at State.cpp:974:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date at Stage Velocity. This entry depends on version 2 of Stage Velocity but was last updated at version 0.
(Required condition 'version == m_dependsOnVersionWhenLastComputed' was not met.)
") [.../casadi/core/map.cpp:419]
2022-02-14 15:58:23.../casadi/core/map.cpp:419 WARNING("]
Exception raised: Error in Function::operator() for 'map13_cost_kinetic_integrand' [Map] at .../casadi/core/function.cpp
Error in Function::operator() for 'cost_kinetic_integrand' [CallbackInternal] at .../casadi/core/function.cpp
.../casadi/core/function_internal.cppFailed to evaluate 'eval_dm' for cost_kinetic_integrand:
.../casadi/core/callback_internal.cpp:122: Error calling "eval" for object cost_kinetic_integrand:
SimTK Exception thrown at State.cpp:974:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date at Stage Velocity. This entry depends on version 2 of Stage Velocity but was last updated at version 0.
(Required condition 'version == m_dependsOnVersionWhenLastComputed' was not met.)
") [.../casadi/core/map.cpp:419]
]
.../casadi/core/map.cpp:419]
2022-02-14 15:58:23 WARNING("2022-02-14 15:58:23 WARNING("Exception raised: Error in Function::operator() for 'map13_cost_kinetic_integrand' [Map] at .../casadi/core/function.cpp
Error in Function::operator() for 'cost_kinetic_integrand' [CallbackInternal] at .../casadi/core/function.cpp
.../casadi/core/function_internal.cppFailed to evaluate 'eval_dm' for cost_kinetic_integrand:
.../casadi/core/callback_internal.cpp:122: Error calling "eval" for object cost_kinetic_integrand:
SimTK Exception thrown at State.cpp:974:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date at Stage Velocity. This entry depends on version 2 of Stage Velocity but was last updated at version 0.
(Required condition 'version == m_dependsOnVersionWhenLastComputed' was not met.)
") [.../casadi/core/map.cpp:419]
Exception raised: Error in Function::operator() for 'map13_cost_kinetic_integrand' [Map] at .../casadi/core/function.cpp
Error in Function::operator() for 'cost_kinetic_integrand' [CallbackInternal] at .../casadi/core/function.cpp
.../casadi/core/function_internal.cppFailed to evaluate 'eval_dm' for cost_kinetic_integrand:
.../casadi/core/callback_internal.cpp:122: Error calling "eval" for object cost_kinetic_integrand:
SimTK Exception thrown at State.cpp:974:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date at Stage Velocity. This entry depends on version 2 of Stage Velocity but was last updated at version 0.
(Required condition 'version == m_dependsOnVersionWhenLastComputed' was not met.)
") [.../casadi/core/map.cpp:419]
Can anyone see anything obvious that I'm doing wrong here?
Cheers,
Daniel