Hello,everyone!
When I run my project, it always throws an exception as follows:
SimTK Exception thrown at Integrator.cpp:431:
Integrator initialization failed apparently because:
SimTK Exception thrown at Subsystem.cpp:329:
Excepted stage to be at least Dynamics in Subsystem::Guts::realizeSubsystemAcceleration() but current stage was Velocity.
I don't know what's the reason of the exception. Do you know the reason for throwing an exception?
Thanks!
Exception
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Exception
The Exceptions indicate that, while initializing the integrator, Simbody was attempting to perform a calculation that requires dynamics-level quantities but quantities had not been computed beyond the velocity level. It is difficult to determine the underlying issue or make any suggestions without understanding what you are trying to do.
Re: Exception
tkuchida wrote: ↑Wed Aug 08, 2018 2:16 pmThe Exceptions indicate that, while initializing the integrator, Simbody was attempting to perform a calculation that requires dynamics-level quantities but quantities had not been computed beyond the velocity level. It is difficult to determine the underlying issue or make any suggestions without understanding what you are trying to do.
Thank you for your reply!tkuchida wrote: ↑Wed Aug 08, 2018 2:16 pmThe Exceptions indicate that, while initializing the integrator, Simbody was attempting to perform a calculation that requires dynamics-level quantities but quantities had not been computed beyond the velocity level. It is difficult to determine the underlying issue or make any suggestions without understanding what you are trying to do.
I want to set the activation of muscles.
The s defined in void computeControls is const SimTK::State& type, but setActivation() needs to pass in the s must be SimTK::State& type, so I cast s.
Then throw the exception mentioned earlier. Part of the code is as follows.
Code: Select all
class TugOfWarPDController : public Controller {
OpenSim_DECLARE_CONCRETE_OBJECT(TugOfWarPDController, Controller);
public:
TugOfWarPDController(double aKp, double aKv) : Controller(), kp(aKp), kv(aKv)
{
}
void computeControls(const SimTK::State& s, SimTK::Vector &controls) const
{
......
SimTK::State& s1 = const_cast<SimTK::State&>(s);
tib_ant_r->setActivation(s1, tmp);
......
}
}
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Exception
If you find that you're in need of a const_cast, it usually means you're not using the API the way it was designed (in which case Exceptions and undefined behavior should be expected). I recommend looking at the ToyReflexController example here: https://github.com/opensim-org/opensim- ... Components.
Re: Exception
Thanks!I will have a try.tkuchida wrote: ↑Thu Aug 09, 2018 8:50 pmIf you find that you're in need of a const_cast, it usually means you're not using the API the way it was designed (in which case Exceptions and undefined behavior should be expected). I recommend looking at the ToyReflexController example here: https://github.com/opensim-org/opensim- ... Components.