Hello,
I am trying to run a simple pendulum and calculate reaction forces on ground. I have made a ball of given radius and an arm length of 2.5 and oscillating it directly with respect to ground, under the influence of gravity only. I have run the simulation in a loop, and set the integration time. Following is the complete code:
import org.opensim.modeling.*
model = Model();
model.setUseVisualizer(true);
bob = Body('bob',10,Vec3(0),Inertia(1));
geo2 = Sphere(1);
bob.attachGeometry(geo2);
model.addBody(bob);
j2 = PinJoint('j2',model.getGround(),Vec3(0,5,0),Vec3(0),bob,Vec3(0,2.5,0),Vec3(0));
model.addJoint(j2);
model.getJointSet().get(0).getCoordinate().setDefaultValue(pi/2);
state = model.initSystem();
for i = 0:500
manager = Manager(model);
state.setTime(0);
manager.initialize(state);
state = manager.integrate(0.02);
model.realizeDynamics(state);
j2.calcReactionOnParentExpressedInGround(state);
end
Dynamic stage is realized but an error is coming. When I run the code simply without using the for loop, output is ok. So, when I run it in the loop, it should give output data in every loop. But that is not happening. I have attached the error file below.
In my main project, I have to get the force between exoskeleton and human forearm in every loop. So, I am attempting to do this as an example.
Thanks in advance.
Stage realization not working- Calculating reaction force on parent body in a pin joint
- Ratna Sambhav
- Posts: 42
- Joined: Sat Jan 12, 2019 10:16 am
Stage realization not working- Calculating reaction force on parent body in a pin joint
- Attachments
-
- Error_file.JPG (53.14 KiB) Viewed 251 times
Tags:
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: Stage realization not working- Calculating reaction force on parent body in a pin joint
This example might help you:
https://github.com/opensim-org/opensim- ... ple.py#L77
Maybe you can try removing the line that realizes the state to a dynamics stage, because if the state is advanced by the integration then it should be already realized to an acceleration level.
https://github.com/opensim-org/opensim- ... ple.py#L77
Maybe you can try removing the line that realizes the state to a dynamics stage, because if the state is advanced by the integration then it should be already realized to an acceleration level.
- Ratna Sambhav
- Posts: 42
- Joined: Sat Jan 12, 2019 10:16 am
Re: Stage realization not working- Calculating reaction force on parent body in a pin joint
Thanks Dimitar for your reply.
In the given python example, they have run the integrator once, and obtained all the data from the state generated.
But in my case, I have to run the integrator for a small time in every loop and get the force data every time, and based on that update control signals given to the actuators in every loop.
Yeah, as you told, I removed realizeDynamics and instead realized Acceleration and now it is working.
Thanks
In the given python example, they have run the integrator once, and obtained all the data from the state generated.
But in my case, I have to run the integrator for a small time in every loop and get the force data every time, and based on that update control signals given to the actuators in every loop.
Yeah, as you told, I removed realizeDynamics and instead realized Acceleration and now it is working.
Thanks