Discrepancy in Acceleration Calculations Using Different Methods in OpenSim's Arm26 Model

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
hu hu
Posts: 13
Joined: Fri Jun 23, 2023 1:50 am

Discrepancy in Acceleration Calculations Using Different Methods in OpenSim's Arm26 Model

Post by hu hu » 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.
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.
Attachments
example_plot.jpg
example_plot.jpg (499.56 KiB) Viewed 279 times
example_plot.jpg
example_plot.jpg (439.18 KiB) Viewed 279 times

Tags:

User avatar
hu hu
Posts: 13
Joined: Fri Jun 23, 2023 1:50 am

Re: Discrepancy in Acceleration Calculations Using Different Methods in OpenSim's Arm26 Model

Post by hu hu » Mon Dec 09, 2024 11:49 pm

I compared again the fiber length calculated by the second method with the results from CMC and found that the numerical difference is very small. However, the accelerations obtained from the two methods differ significantly. How should this be interpreted? Additionally, I compared the muscle forces between the two methods.
Attachments
example_plot.jpg
example_plot.jpg (528.7 KiB) Viewed 179 times
example_plot.jpg
example_plot.jpg (463.95 KiB) Viewed 179 times
example_plot.jpg
example_plot.jpg (553.37 KiB) Viewed 179 times

User avatar
hu hu
Posts: 13
Joined: Fri Jun 23, 2023 1:50 am

Re: Discrepancy in Acceleration Calculations Using Different Methods in OpenSim's Arm26 Model

Post by hu hu » Tue Dec 10, 2024 4:10 am

Considering that the fiber length in CMC is obtained through integration, the fiber length calculated using the second method is very close to that of CMC but not exactly the same. However, while the muscle forces obtained by the two methods are quite similar, the accelerations differ significantly. Could something have been overlooked? Or perhaps the acceleration was originally like this.
At the same time, I confirmed that as long as the fiber length from CMC is set in the second method, the acceleration matches exactly with the acceleration in `arm26_Kinematics_dudt.sto`.

POST REPLY