Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add support for contact tracking to MocoTrack #580

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Change Log
==========
0.5.0 (in development)
----------------------
- 2020-04-08: Added contact tracking to MocoTrack, and updated exampleMocoTrack
to provide an example of contact tracking.

- 2020-04-08: Added ModOpAppliesForce to set the appliesForce property
for multiple Forces.

0.4.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
track.set_apply_tracked_states_to_guess(true);
track.set_initial_time(0.0);
track.set_final_time(0.47008941);

study = track.initialize();
problem = study.updProblem();


% Goals
% =====

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ def solveMocoInverse():
# Only valid for DeGrooteFregly2016Muscles.
modelProcessor.append(osim.ModOpScaleActiveFiberForceCurveWidthDGF(1.5))
modelProcessor.append(osim.ModOpAddReserves(1.0))
modelProcessor.append(osim.ModOpAppliesForce(False, [
"/forceset/contactSphereHeel_r",
"/forceset/contactLateralRearfoot_r",
"/forceset/contactLateralMidfoot_r",
"/forceset/contactLateralToe_r",
"/forceset/contactMedialToe_r",
"/forceset/contactMedialMidfoot_r",
"/forceset/contactSphereHeel_l",
"/forceset/contactLateralRearfoot_l",
"/forceset/contactLateralMidfoot_l",
"/forceset/contactLateralToe_l",
"/forceset/contactMedialToe_l",
"/forceset/contactMedialMidfoot_l"
]))
inverse.setModel(modelProcessor)

# Construct a TableProcessor of the coordinate data and pass it to the
Expand Down Expand Up @@ -84,6 +98,20 @@ def solveMocoInverseWithEMG():
modelProcessor.append(osim.ModOpIgnorePassiveFiberForcesDGF())
modelProcessor.append(osim.ModOpScaleActiveFiberForceCurveWidthDGF(1.5))
modelProcessor.append(osim.ModOpAddReserves(1.0))
modelProcessor.append(osim.ModOpAppliesForce(False, [
"/forceset/contactSphereHeel_r",
"/forceset/contactLateralRearfoot_r",
"/forceset/contactLateralMidfoot_r",
"/forceset/contactLateralToe_r",
"/forceset/contactMedialToe_r",
"/forceset/contactMedialMidfoot_r",
"/forceset/contactSphereHeel_l",
"/forceset/contactLateralRearfoot_l",
"/forceset/contactLateralMidfoot_l",
"/forceset/contactLateralToe_l",
"/forceset/contactMedialToe_l",
"/forceset/contactMedialMidfoot_l"
]))
inverse.setModel(modelProcessor)
inverse.setKinematics(osim.TableProcessor('coordinates.sto'))
inverse.set_initial_time(0.81)
Expand Down
2 changes: 1 addition & 1 deletion Moco/Examples/C++/example3DWalking/coordinates.sto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nRows=1350
nColumns=40
inDegrees=yes
endheader
time /jointset/ground_pelvis/pelvis_tilt/value /jointset/ground_pelvis/pelvis_list/value /jointset/ground_pelvis/pelvis_rotation/value /jointset/ground_pelvis/pelvis_tx/value /jointset/ground_pelvis/pelvis_ty/value /jointset/ground_pelvis/pelvis_tz/value /jointset/hip_r/hip_flexion_r/value /jointset/hip_r/hip_adduction_r/value /jointset/hip_r/hip_rotation_r/value /jointset/walker_knee_r/knee_angle_r/value /jointset/patellofemoral_r/knee_angle_r_beta/value /jointset/ankle_r/ankle_angle_r/value subtalar_angle_r mtp_angle_r /jointset/hip_l/hip_flexion_l/value /jointset/hip_l/hip_adduction_l/value /jointset/hip_l/hip_rotation_l/value /jointset/walker_knee_l/knee_angle_l/value /jointset/patellofemoral_l/knee_angle_l_beta/value /jointset/ankle_l/ankle_angle_l/value subtalar_angle_l mtp_angle_l /jointset/back/lumbar_extension/value /jointset/back/lumbar_bending/value /jointset/back/lumbar_rotation/value /jointset/acromial_r/arm_flex_r/value /jointset/acromial_r/arm_add_r/value /jointset/acromial_r/arm_rot_r/value /jointset/elbow_r/elbow_flex_r/value pro_sup_r/value wrist_flex_r/value wrist_dev_r/value /jointset/acromial_l/arm_flex_l/value /jointset/acromial_l/arm_add_l/value /jointset/acromial_l/arm_rot_l/value /jointset/elbow_l/elbow_flex_l/value pro_sup_l/value wrist_flex_l/value wrist_dev_l/value
time /jointset/ground_pelvis/pelvis_tilt/value /jointset/ground_pelvis/pelvis_list/value /jointset/ground_pelvis/pelvis_rotation/value /jointset/ground_pelvis/pelvis_tx/value /jointset/ground_pelvis/pelvis_ty/value /jointset/ground_pelvis/pelvis_tz/value /jointset/hip_r/hip_flexion_r/value /jointset/hip_r/hip_adduction_r/value /jointset/hip_r/hip_rotation_r/value /jointset/walker_knee_r/knee_angle_r/value knee_angle_r_beta/value /jointset/ankle_r/ankle_angle_r/value subtalar_angle_r mtp_angle_r /jointset/hip_l/hip_flexion_l/value /jointset/hip_l/hip_adduction_l/value /jointset/hip_l/hip_rotation_l/value /jointset/walker_knee_l/knee_angle_l/value knee_angle_l_beta/value /jointset/ankle_l/ankle_angle_l/value subtalar_angle_l mtp_angle_l lumbar_extension/value lumbar_bending/value lumbar_rotation/value arm_flex_r/value arm_add_r/value arm_rot_r/value elbow_flex_r/value pro_sup_r/value wrist_flex_r/value wrist_dev_r/value arm_flex_l/value arm_add_l/value arm_rot_l/value elbow_flex_l/value pro_sup_l/value wrist_flex_l/value wrist_dev_l/value
0.45000000 0.09205103 -2.62004342 8.24616452 0.00987536 0.96796985 -0.23591827 22.72236815 2.25027648 -10.98568412 21.66554404 0.37813508 1.11190758 0.00000000 0.00000000 3.13209472 -6.76984074 0.40993409 56.58663166 0.98762304 -15.84704902 0.00000000 0.00000000 -7.09465432 4.50637853 -11.37733924 -1.96965993 -3.22718812 -25.97469731 31.19903290 54.25053307 0.00000000 0.00000000 6.44290483 -8.47862584 -0.13079848 50.71868877 50.88654014 0.00000000 0.00000000
0.45100000 0.12743263 -2.63117095 8.24191750 0.01116159 0.96813874 -0.23579893 22.62090835 2.29021992 -10.97293980 21.70455667 0.37881598 1.23457806 -0.00000000 0.00000000 3.30879214 -6.81368150 0.39172851 56.91455847 0.99334644 -15.97792993 -0.00000000 -0.00000000 -7.12690401 4.51996701 -11.32114438 -1.95457397 -3.23167696 -25.94707837 31.21379253 54.25014688 -0.00000000 -0.00000000 6.43319765 -8.45976796 -0.16705849 50.61743762 50.88424544 -0.00000000 -0.00000000
0.45200000 0.16276613 -2.64184109 8.23732895 0.01244562 0.96830835 -0.23567981 22.51864828 2.32995416 -10.96004098 21.74224426 0.37947375 1.35712308 0.00000000 0.00000000 3.48529886 -6.85667506 0.37350714 57.24015597 0.99902919 -16.10191006 0.00000000 -0.00000000 -7.15928798 4.53300431 -11.26439744 -1.93925727 -3.23628444 -25.91868234 31.22886860 54.24972139 -0.00000000 -0.00000000 6.42352711 -8.44125133 -0.20317978 50.51649445 50.88193916 -0.00000000 0.00000000
Expand Down
34 changes: 32 additions & 2 deletions Moco/Examples/C++/example3DWalking/exampleMocoInverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,22 @@ void solveMocoInverse() {
ModOpIgnorePassiveFiberForcesDGF() |
// Only valid for DeGrooteFregly2016Muscles.
ModOpScaleActiveFiberForceCurveWidthDGF(1.5) |
ModOpAddReserves(1.0);
ModOpAddReserves(1.0) |
// Disable the contact force elements in the model.
ModOpAppliesForce(false, {
"/forceset/contactHeel_r",
"/forceset/contactLateralRearfoot_r",
"/forceset/contactLateralMidfoot_r",
"/forceset/contactLateralToe_r",
"/forceset/contactMedialToe_r",
"/forceset/contactMedialMidfoot_r",
"/forceset/contactHeel_l",
"/forceset/contactLateralRearfoot_l",
"/forceset/contactLateralMidfoot_l",
"/forceset/contactLateralToe_l",
"/forceset/contactMedialToe_l",
"/forceset/contactMedialMidfoot_l"
});
inverse.setModel(modelProcessor);

// Construct a TableProcessor of the coordinate data and pass it to the
Expand Down Expand Up @@ -91,7 +106,22 @@ void solveMocoInverseWithEMG() {
ModOpIgnorePassiveFiberForcesDGF() |
// Only valid for DeGrooteFregly2016Muscles.
ModOpScaleActiveFiberForceCurveWidthDGF(1.5) |
ModOpAddReserves(1.0);
ModOpAddReserves(1.0) |
// Disable the contact force elements in the model.
ModOpAppliesForce(false, {
"/forceset/contactHeel_r",
"/forceset/contactLateralRearfoot_r",
"/forceset/contactLateralMidfoot_r",
"/forceset/contactLateralToe_r",
"/forceset/contactMedialToe_r",
"/forceset/contactMedialMidfoot_r",
"/forceset/contactHeel_l",
"/forceset/contactLateralRearfoot_l",
"/forceset/contactLateralMidfoot_l",
"/forceset/contactLateralToe_l",
"/forceset/contactMedialToe_l",
"/forceset/contactMedialMidfoot_l"
});
inverse.setModel(modelProcessor);
inverse.setKinematics(TableProcessor("coordinates.sto"));
inverse.set_initial_time(0.81);
Expand Down
Loading