Simbody is useful for internal coordinate and coarse grained molecule modeling, large scale mechanical models like skeletons, and anything else that can be modeled as bodies interconnected by joints, acted upon by forces, and restricted by constraints.
-
Omar Zarifi
- Posts: 2
- Joined: Wed May 01, 2013 10:15 am
Post
by Omar Zarifi » Tue May 21, 2013 11:52 am
Hello,
I'm having a little problem with constraints. I have defined two ConstantSpeed (set at 0) constraints (to model brakes). The definitions are:
Code: Select all
upperConstraint = new Constraint::ConstantSpeed(*arm->getUpper()->getBody(), 0);
lowerConstraint = new Constraint::ConstantSpeed(*arm->getLower()->getBody(), 0);
At some point in the simulation, I'd like to disable (and re-enable) these constraints. However, the disable() and enable() methods aren't working for some reason. The states I provide to these methods are obtained via updAdvancedState() from the Integrator (which is itself obtained through updIntegrator() from a TimeStepper). Any ideas on why I'm encountering this? I've also tried calling reinitialize up to the Instance stage on the integrator after the manipulation of the constraints; still no luck... Also, I don't know if this is relevant, but the constraints are updated both when the simulation is paused and during a simulation.
Any help would be appreciated. Thanks in advance.
Omar
-
Michael Sherman
- Posts: 806
- Joined: Fri Apr 01, 2005 6:05 pm
Post
by Michael Sherman » Tue May 21, 2013 1:48 pm
Hi, Omar. The most likely explanation is that the State object within which you are disabling the constraint is not the one being used to advance the simulation. That can easily happen if there is a missing "&". For example,
Code: Select all
State s = integ.updAdvancedState(); // s is a new copy
State& s = integ.updAdvancedState(); // s refers to integrator's state
There are other possibilities, but I would need to see exactly the code you're using.
The Simbody "adhoc test" LockUnlockConstraint.cpp has code that disables and enables a ConstantSpeed constraint -- you might want to have a look at that to see if you spot anything different you're doing.
Regards,
Sherm
-
Omar Zarifi
- Posts: 2
- Joined: Wed May 01, 2013 10:15 am
Post
by Omar Zarifi » Tue May 21, 2013 2:06 pm
That was exactly it. Thank you very much for your help.
Omar