Hello,
I have an excel file containing the elbow angle and elbow speed.
I want to use this and calculate what will be the value of elbow moment at every instance.
For that I've used the "InverseDynamicSolver" in the following way:
ID = InverseDynamicsSolver(model);
for i = 1:410
%% Assigned the value of elbow and shoulder angle and speed in the state of current model
model.getJointSet().get(1).getCoordinate().setValue(state, shoulder_angle(i));
model.getJointSet().get(1).getCoordinate().setSpeedValue(state, shoulder_speed(i));
model.getJointSet().get(2).getCoordinate().setValue(state, elbow_angle(i));
model.getJointSet().get(2).getCoordinate().setSpeedValue(state, elbow_speed(i));
%% Calculaated the value of shoulder and elbow accelerations from the external file and made a u_dot
%% vector from that.
elbow_alpha = (elbow_speed(i+1)-elbow_speed(i))/(time(i+1)-time(i));
shoulder_alpha = (shoulder_speed(i+1)-shoulder_speed(i))/(time(i+1)-time(i));
u_dot = Vector(2, 0);
u_dot.set(0,shoulder_alpha);
u_dot.set(1, elbow_alpha);
%% Finally I've used the InverseDynamicsSolver.solve to calculate the shoulder and elbow moment
tau = ID.solve(state, u_dot);
shoulder_tau = tau.get(0);
elbow_tau = tau.get(1);
end
Unfortunately, I am not getting able to obtain the exact result. The value of torque coming as output is more than what I expected.
Can you point out what I did wrong and suggest any code which can be used in this regard.
Regards,
Ratna Sambhav
Calculation of joint moment in matlab using joint angle and speed from external file using InverseDynamicsSolver.
- Ratna Sambhav
- Posts: 42
- Joined: Sat Jan 12, 2019 10:16 am
- Carmichael Ong
- Posts: 383
- Joined: Fri Feb 24, 2012 11:50 am
Re: Calculation of joint moment in matlab using joint angle and speed from external file using InverseDynamicsSolver.
Seems like that should be okay. What are you comparing to that you're considering "the answer"? How different are the values?
- Ratna Sambhav
- Posts: 42
- Joined: Sat Jan 12, 2019 10:16 am
Re: Calculation of joint moment in matlab using joint angle and speed from external file using InverseDynamicsSolver.
Thanks Ong for the response.
I have taken the arm26 model and performing inverse dynamics for elbow flexion, calculating the elbow moment.
The output I am getting from the matlab code as described above, I am comparing with the OpenSim inverseDynamics result for the same input trajectory file.
Here is the plot which has to be the answer (output from OpenSim): And output I am getting using InverseDynamicsSolver code shown above is: So, you see its almost one unit higher and more scattered. I am not understanding what's the mistake.
I have taken the arm26 model and performing inverse dynamics for elbow flexion, calculating the elbow moment.
The output I am getting from the matlab code as described above, I am comparing with the OpenSim inverseDynamics result for the same input trajectory file.
Here is the plot which has to be the answer (output from OpenSim): And output I am getting using InverseDynamicsSolver code shown above is: So, you see its almost one unit higher and more scattered. I am not understanding what's the mistake.
- Ratna Sambhav
- Posts: 42
- Joined: Sat Jan 12, 2019 10:16 am
Re: Calculation of joint moment in matlab using joint angle and speed from external file using InverseDynamicsSolver.
Hi,
Apologies for not giving the full information but the problem is solved now. The Arm26 model which I was using has muscles attached to it, which was creating the anomaly in joint torque calculation (probably because of the passive force which it was exerting).
When I removed the muscles from the model, the plot of elbow torque is coming exactly as compared to the plot from OpenSim GUI.
Thankfully,
Ratna
Apologies for not giving the full information but the problem is solved now. The Arm26 model which I was using has muscles attached to it, which was creating the anomaly in joint torque calculation (probably because of the passive force which it was exerting).
When I removed the muscles from the model, the plot of elbow torque is coming exactly as compared to the plot from OpenSim GUI.
Thankfully,
Ratna