stanfordnmbl / osim-rl

Reinforcement learning environments with musculoskeletal models
http://osim-rl.stanford.edu/
MIT License
896 stars 249 forks source link

fiber_force from "muscles" != the one from "forces" #163

Closed AdamStelmaszczyk closed 6 years ago

AdamStelmaszczyk commented 6 years ago

I printed state_desc during run, relevant part:

  'muscles': {
        'abd_r': {
            'activation': 1.0,
            'fiber_length': 0.04662692926305904,
            'fiber_velocity': 0.164269154214667,
            'fiber_force': 3726.658569321278
        },
        'add_r': {
            'activation': 0.8474363387585389,
            'fiber_length': 0.0879483077596202,
            'fiber_velocity': -0.23395595681952133,
            'fiber_force': 1470.5347778092807
        },
        'hamstrings_r': {
            'activation': 1.0,
            'fiber_length': 0.037700972559635386,
            'fiber_velocity': -0.22092144946431708,
            'fiber_force': 1102.6684776303782
        },
        'bifemsh_r': {
            'activation': 1.0,
            'fiber_length': 0.12457846192457502,
            'fiber_velocity': -0.2012949393020236,
            'fiber_force': 323.7722062361308
        },
        'glut_max_r': {
            'activation': 1.0,
            'fiber_length': 0.13140296306837637,
            'fiber_velocity': -0.0033920420667433748,
            'fiber_force': 3123.614109714061
        },
        'iliopsoas_r': {
            'activation': 1.0,
            'fiber_length': 0.1457783466055518,
            'fiber_velocity': -0.055433390190016564,
            'fiber_force': 2151.1912508023624
        },
        'rect_fem_r': {
            'activation': 0.01,
            'fiber_length': 0.08754939941773604,
            'fiber_velocity': 0.7100379948212439,
            'fiber_force': 42.70442102796286
        },
        'vasti_r': {
            'activation': 0.01,
            'fiber_length': 0.09402793030118502,
            'fiber_velocity': 0.3853630102956348,
            'fiber_force': 150.82138420280546
        },
        'abd_l': {
            'activation': 1.0,
            'fiber_length': 0.07053505887813798,
            'fiber_velocity': -0.0059204485736551625,
            'fiber_force': 4101.388650616802
        },
        'add_l': {
            'activation': 1.0,
            'fiber_length': 0.04182257226369955,
            'fiber_velocity': 0.001416140672052873,
            'fiber_force': 2182.299442543992
        },
        'hamstrings_l': {
            'activation': 1.0,
            'fiber_length': 0.035777598436690955,
            'fiber_velocity': -0.007002901712451171,
            'fiber_force': 2371.812772736133
        },
        'bifemsh_l': {
            'activation': 1.0,
            'fiber_length': 0.13428820478315354,
            'fiber_velocity': -0.001546859905163841,
            'fiber_force': 517.5939494598043
        },
        'glut_max_l': {
            'activation': 1.0,
            'fiber_length': 0.11656079249110235,
            'fiber_velocity': -0.01914958117074742,
            'fiber_force': 2766.662555654114
        },
        'iliopsoas_l': {
            'activation': 1.0,
            'fiber_length': 0.14849084008723035,
            'fiber_velocity': 0.013630435829705415,
            'fiber_force': 2599.6934065783344
        },
        'rect_fem_l': {
            'activation': 0.01,
            'fiber_length': 0.07634391897586457,
            'fiber_velocity': 0.012481700927389877,
            'fiber_force': 26.444788761131978
        },
        'vasti_l': {
            'activation': 1.0,
            'fiber_length': 0.06695063332044866,
            'fiber_velocity': 0.008623041260043417,
            'fiber_force': 7986.102880249697
        },
        'gastroc_l': {
            'activation': 1.0,
            'fiber_length': 0.055032553192102145,
            'fiber_velocity': -0.18306107615902298,
            'fiber_force': 1827.6245975833206
        },
        'soleus_l': {
            'activation': 0.01,
            'fiber_length': 0.0560922571403369,
            'fiber_velocity': -0.06065212025422524,
            'fiber_force': 494.97830131961234
        },
        'tib_ant_l': {
            'activation': 1.0,
            'fiber_length': 0.04131151712104807,
            'fiber_velocity': 0.0789093165498726,
            'fiber_force': 1899.566657889922
        }
    },
    'forces': {
        'abd_r': [
            3726.6585693212783
        ],
        'add_r': [
            1465.0591977501463
        ],
        'hamstrings_r': [
            971.1118568715812
        ],
        'bifemsh_r': [
            303.8926452944679
        ],
        'glut_max_r': [
            3123.614109714061
        ],
        'iliopsoas_r': [
            2137.7293517591384
        ],
        'rect_fem_r': [
            42.582021847991335
        ],
        'vasti_r': [
            150.59223414156503
        ],
        'abd_l': [
            4101.388650616802
        ],
        'add_l': [
            2146.132893902375
        ],
        'hamstrings_l': [
            2055.20794588899
        ],
        'bifemsh_l': [
            490.3669129258421
        ],
        'glut_max_l': [
            2766.662555654114
        ],
        'iliopsoas_l': [
            2584.015551070358
        ],
        'rect_fem_l': [
            26.345064684490993
        ],
        'vasti_l': [
            7962.152191545522
        ],
        'gastroc_l': [
            1759.2604777103472
        ],
        'soleus_l': [
            466.9879387165158
        ],
        'tib_ant_l': [
            1879.9174939928157
        ],
        'ankleSpring': [
            0.2662686776400175
        ],
        'pros_foot_r_0': [
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0
        ],
        'foot_l': [
            -3.3524883420168226,
            -4.22642838200133,
            0.43925836620461384,
            -0.10759736010572045,
            0.11846736723209264,
            0.3186619962049267,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            3.3524883420168226,
            4.22642838200133,
            -0.43925836620461384,
            -0.07257277254275452,
            0.0651266364785188,
            0.07274463823140331,
            3.3524883420168226,
            4.22642838200133,
            -0.43925836620461384,
            -0.07257277254275452,
            0.0651266364785188,
            0.07274463823140331
        ],
        'HipLimit_r': [
            5.3667877557226475,
            0.12848899217903761
        ],
        'HipLimit_l': [
            225.00713355355512,
            16.392262421664665
        ],
        'KneeLimit_r': [
            0.0,
            0.0
        ],
        'KneeLimit_l': [
            -219.23518448429573,
            16.31734069771718
        ],
        'AnkleLimit_r': [
            0.0,
            0.0
        ],
        'AnkleLimit_l': [
            0.0,
            0.0
        ],
        'HipAddLimit_r': [
            0.0,
            0.0
        ],
        'HipAddLimit_l': [
            0.0,
            0.0
        ]
    },

abd_r has the same force 3726.6585693212783, ok.

But for example hamstrings_r doesn't, in muscles dict it has fiber_force: 1102.6684776303782, but in forces it has 971.1118568715812.

iliopsoas_l differs too.

Despite it's written "Note that in the forces dictionary, forces corresponding to muscles are redundant with fiber_force in muscles dictionaries" on http://osim-rl.stanford.edu/docs/nips2018/observation/.

Which value is the correct force?

carmichaelong commented 6 years ago

It looks like the note there should be corrected. Both fiber_force and the forces list give "correct" answers, depending on what you're looking for. The fiber_force corresponds to the force generated by the muscle, and list from forces are the ones applied by the tendon that connects that muscle to the bone.

(Read on for details on the biology and modeling): The muscle fibers don't necessarily align with the tendon fibers. The angle between their directions is the "pennation angle". The larger this angle is, the larger the difference between the fiber and tendon forces: tendon_force = muscle_fiber_force*cos(pennation) So, abd and glut_max muscles match because they have a pennation angle of 0. Notice how the forces list has values that are either the same or lower than fiber_force, because they correspond to the tendon force.

AdamStelmaszczyk commented 6 years ago

That's great @carmichaelong, thank you.