Page 1 of 1

Exception

Posted: Tue Aug 07, 2018 12:58 am
by lhr
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!

Re: Exception

Posted: Wed Aug 08, 2018 2:16 pm
by tkuchida
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

Posted: Thu Aug 09, 2018 7:28 pm
by lhr
tkuchida wrote:
Wed Aug 08, 2018 2:16 pm
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.
tkuchida wrote:
Wed Aug 08, 2018 2:16 pm
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.
Thank you for your reply!
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);
                ......
        }
}

Re: Exception

Posted: Thu Aug 09, 2018 8:50 pm
by tkuchida
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

Posted: Fri Aug 10, 2018 11:52 pm
by lhr
tkuchida wrote:
Thu Aug 09, 2018 8:50 pm
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.
Thanks!I will have a try.