Hi, how can I access some of the states of the leg in a lua script, such as gait phase, load, etc.? I recently tried to implement Song's article[1] in SCONE again and found that I can't go to fully implement it according to GaitStateConreoller, so I would like to implement it using lua script, thanks a lot.
[1] S. Song,H. Geyer, A neural circuitry that emphasizes spinal feedback generates diverse behaviours of human locomotion, The Journal of Physiology,doi: 10.1113/JP270228.
access some of the states of the leg in a lua script
- chang wang
- Posts: 8
- Joined: Thu Mar 21, 2024 7:54 am
- Thomas Geijtenbeek
- Posts: 461
- Joined: Wed Mar 12, 2014 8:08 am
Re: access some of the states of the leg in a lua script
The states are computed in the GaitStateController, so if you'd like the additional states from the Song controller then you'd have to implement the state transitions yourself.
Please note that you can still use normal ReflexController instances as children of your ScriptController (just like with the GaitStateController). You can enable/disable them depending on the state computed in your Lua script. For more information, see:
https://scone.software/doku.php?id=ref:lua_controller
Please note that you can still use normal ReflexController instances as children of your ScriptController (just like with the GaitStateController). You can enable/disable them depending on the state computed in your Lua script. For more information, see:
https://scone.software/doku.php?id=ref:lua_controller
- chang wang
- Posts: 8
- Joined: Thu Mar 21, 2024 7:54 am
Re: access some of the states of the leg in a lua script
Yes, but I read the user documentation and found that the leg loads are not accessible in the lua script. Thanks for answering my question.tgeijten wrote: ↑Tue Nov 05, 2024 2:40 amThe states are computed in the GaitStateController, so if you'd like the additional states from the Song controller then you'd have to implement the state transitions yourself.
Please note that you can still use normal ReflexController instances as children of your ScriptController (just like with the GaitStateController). You can enable/disable them depending on the state computed in your Lua script. For more information, see:
https://scone.software/doku.php?id=ref:lua_controller
- chang wang
- Posts: 8
- Joined: Thu Mar 21, 2024 7:54 am
Re: access some of the states of the leg in a lua script
Can you please see if I'm doing the right thing? Thank you very much.tgeijten wrote: ↑Tue Nov 05, 2024 2:40 amThe states are computed in the GaitStateController, so if you'd like the additional states from the Song controller then you'd have to implement the state transitions yourself.
Please note that you can still use normal ReflexController instances as children of your ScriptController (just like with the GaitStateController). You can enable/disable them depending on the state computed in your Lua script. For more information, see:
https://scone.software/doku.php?id=ref:lua_controller
In the two-dimensional case,
calcn_l = model:find_body( "calcn_l" )
grf.y = calcn_l:contact_force()
load_l = grf.y/gravity
- chang wang
- Posts: 8
- Joined: Thu Mar 21, 2024 7:54 am
Re: access some of the states of the leg in a lua script
Thanks a lot, I just found the source code for scone on github, found the relevant calculations, and implemented and verified the results in a lua script.tgeijten wrote: ↑Tue Nov 05, 2024 2:40 amThe states are computed in the GaitStateController, so if you'd like the additional states from the Song controller then you'd have to implement the state transitions yourself.
Please note that you can still use normal ReflexController instances as children of your ScriptController (just like with the GaitStateController). You can enable/disable them depending on the state computed in your Lua script. For more information, see:
https://scone.software/doku.php?id=ref:lua_controller
calcn_l = model:find_body( "calcn_l" )
grf_test = calcn_l:contact_force()
model_bw = model:mass() * math.sqrt(model:gravity().x^2 + model:gravity().y^2 + model:gravity().z^2)
leg_load_0 = math.sqrt(grf_test.x^2 + grf_test.y^2 + grf_test.z^2)
leg_load = leg_load_0 / model_bw
- Thomas Geijtenbeek
- Posts: 461
- Joined: Wed Mar 12, 2014 8:08 am
Re: access some of the states of the leg in a lua script
Great, that looks correct.
Please note that you can also simply use grf_test:length() and gravity():length() to the lengths of these vectors.
Please note that you can also simply use grf_test:length() and gravity():length() to the lengths of these vectors.
- chang wang
- Posts: 8
- Joined: Thu Mar 21, 2024 7:54 am
Re: access some of the states of the leg in a lua script
I have another question why my calculated and analyzed windows are not equal?
calcn_l = model:find_body( "calcn_l" )
foot_com = calcn_l:com_pos().x
model_com = model:com_pos().x
pelvis_com = target_body:com_pos().x
leg_sagittal_pos_0 = foot_com - model_com
leg_sagittal_pos_1 = foot_com - pelvis_com
- chang wang
- Posts: 8
- Joined: Thu Mar 21, 2024 7:54 am
Re: access some of the states of the leg in a lua script
1
- Attachments
-
- 1730811887647.png (49.26 KiB) Viewed 486 times
- Thomas Geijtenbeek
- Posts: 461
- Joined: Wed Mar 12, 2014 8:08 am
Re: access some of the states of the leg in a lua script
I looked into it, and it appears that "target_body" in your example is actually the torso and not the pelvis. If I replace target_body with the pelvis body, the sagittal positions become identical to those from the GaitStateController.