Exception

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
li haoran
Posts: 8
Joined: Mon Apr 16, 2018 12:59 am

Exception

Post by li haoran » Tue Aug 07, 2018 12:58 am

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!

Tags:

User avatar
Thomas Uchida
Posts: 1792
Joined: Wed May 16, 2012 11:40 am

Re: Exception

Post by Thomas Uchida » 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.

User avatar
li haoran
Posts: 8
Joined: Mon Apr 16, 2018 12:59 am

Re: Exception

Post by li haoran » Thu Aug 09, 2018 7:28 pm

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);
                ......
        }
}

User avatar
Thomas Uchida
Posts: 1792
Joined: Wed May 16, 2012 11:40 am

Re: Exception

Post by Thomas Uchida » 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.

User avatar
li haoran
Posts: 8
Joined: Mon Apr 16, 2018 12:59 am

Re: Exception

Post by li haoran » Fri Aug 10, 2018 11:52 pm

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.

POST REPLY