Discrepancy in Acceleration Calculations Using Different Methods in OpenSim's Arm26 Model
Posted: Sun Dec 08, 2024 7:16 pm
I am using the arm26 model from the OpenSim model folder. After performing a CMC analysis, I obtained a states file "arm26_states.sto" and an accelerations file "arm26_Kinematics_dudt.sto". I did not set any reserve actuators. I am now using two methods to calculate accelerations at each time step by inputting the states, and then comparing the calculated accelerations with the ones in the accelerations file.
1. **Method 1**: Set the generalized coordinates, generalized velocities, muscle activations, and fiber lengths directly, then compute accelerations.
2. **Method 2**: Set the generalized coordinates, generalized velocities, and muscle activations, then use the `equilibrateMuscles` function to compute the fiber lengths before calculating accelerations.
I then calculate the accelerations.
I noticed that the accelerations calculated using these two methods are different. What could be the cause of this discrepancy?
The results from the first method are correct and the results from the second method are incorrect.
Additionally, I verified that the fiber lengths calculated using the second method are the same as those from the first method.
Please see the figure below.
1. **Method 1**: Set the generalized coordinates, generalized velocities, muscle activations, and fiber lengths directly, then compute accelerations.
vector = osim.Vector(data.getSize(), 0.0)
for i in range(data.getSize()):
vector = data.get(i)
model.setStateVariableValues(state, vector)
model.computeStateVariableDerivatives(state)
2. **Method 2**: Set the generalized coordinates, generalized velocities, and muscle activations, then use the `equilibrateMuscles` function to compute the fiber lengths before calculating accelerations.
for i in range(nCoords):
coord = coord_set.get(i)
coord_value = data.get(i * 2)
coord_speed = data.get(i * 2 + 1)
coord.setValue(state, coord_value)
coord.setSpeedValue(state, coord_speed)
model.realizeVelocity(state)
for i in range(nMuscles):
muscle = MuscleSet.get(i)
muscle.setActivation(state, data.get(i*2+2*nCoords))
model.equilibrateMuscles(state)
I then calculate the accelerations.
model.realizeAcceleration(state)
acceleration[j,:] = [model.getWorkingState().getUDot().get(i) for i in range(state.getNU())]
I noticed that the accelerations calculated using these two methods are different. What could be the cause of this discrepancy?
The results from the first method are correct and the results from the second method are incorrect.
Additionally, I verified that the fiber lengths calculated using the second method are the same as those from the first method.
Please see the figure below.