Calculation of joint moment in matlab using joint angle and speed from external file using InverseDynamicsSolver.
Posted: Wed May 13, 2020 11:10 am
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
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