Healthy Gait
About
This tutorial shows how to optimize gait controllers, based on the model by [Geyer & Herr 2010].Reflex Gait Controller
- Open the scenario
Tutorials/Tutorial 4a - Gait
As you can see, the scone file is fairly short and doesn't contain a Controller or a Measure. However, there is a section in the middle that says:
# Controller for gait, based on [Geyer & Herr 2010] << data/ControllerGH2010.scone >> # Measure for gait << data/MeasureGait10.scone >>
What this means is, we have moved the controller and measure code to different files, in order to keep things tidy. Before we look into any details, start the optimization (this will take a while).
- Click
Scenario → Optimize Scenario
or pressCtrl + F5
The actual Reflex Gait Controller is defined inside the file Tutorials/data/ControllerGH2010.scone
, which implements the gait controller defined by [Geyer & Herr 2010]. The key components used in this Controller are the GaitStateController, which is used to detect different gait phases (stance, lift-off, swing, etc.), and a number of ReflexController that are active during one or more phases. Please see Tutorials/data/ControllerGH2010.scone
for more details.
The actual parameters that are being optimized are again shown in the Parameters Window (Windows → Parameters
). These include the reflex gains and offsets of the gait controller, as well as parameters that set the initial pose.
Initial Pose Optimization
In this example, not only the control parameters are being optimized, but also the initial pose of the model. This is done via:
# Optimize initial state parameters state_init_file = data/InitStateGait10.zml initial_state_offset = 0~0.01<-0.5,0.5> initial_state_offset_exclude = "*_tx;*_ty;*_u"
Here, the state_init_file
defines the initial pose, and initial_state_offset
defines optimization parameters for offsets that are added to this pose. In this example, translation states and coordinate velocities are excluded from the optimization, as indicated by initial_state_offset_exclude
Gait at Different Speeds
- Open the file
Tutorials/Tutorial 4b - Fast Gait.scone
To optimize gait for different target speeds, we can simply change the optimization criterion. In this case, we define the optimization criterion in the file Tutorials/data/MeasureGait15.scone
:
# Measure for gait, minimum speed = 1.5 m/s CompositeMeasure { GaitMeasure { name = Gait weight = 100 threshold = 0.05 termination_height = 0.85 min_velocity = 1.5 } EffortMeasure { name = Effort weight = 0.1 measure_type = Wang2012 use_cost_of_transport = 1 } CompositeMeasure { name = DofLimits symmetric = 1 DofMeasure { weight = 0.1 dof = ankle_angle position { min = -60 max = 60 squared_penalty = 1 } } DofMeasure { weight = 0.01 threshold = 5 dof = knee_angle force { min = 0 max = 0 abs_penalty = 1 } } } }
The target speed is set by the min_velocity
tag in the GaitMeasure section. In addition, and EffortMeasure is used to minimize cost of transport, and DofMeasure is used to prevent knee and ankle hyper-extension.
Perturbed Gait
- Open the file
Tutorials/Tutorial 4c - Perturbed Gait.scone
Here you will see that we use a CompositeController that consists of our Geyer and Herr controller, in combination with a couple of PerturbationController entries:
CompositeController { # Controller for gait, based on [Geyer & Herr 2010] << data/ControllerGH2010.scone >> # Perturbation backwards every 4 seconds PerturbationController { start_time = 3 duration = 0.2 interval = 4 force = [ -100 0 0 ] body = pelvis position_offset = [ -0.15 0.35 0 ] } # Perturbation forwards every other 4 seconds PerturbationController { start_time = 5 duration = 0.2 interval = 4 force = [ 100 0 0 ] body = pelvis position_offset = [ -0.15 0.35 0 ] } }
Note that inside SCONE, a PerturbationController is a controller just like anything else, even though it does not work on internal actuators. A SCONE Controller is simply any entity that can generate actuator inputs in the simulation.
- Test the optimization by pressing
Ctrl + T
You'll see that, once the first perturbation kicks in, the model falls over immediately. The control parameters of the model have not yet been optimized to be robust against external perturbations.
- Start the optimization with
Ctrl + F5
After a while, you'll find that the gait controller will become more robust against perturbations. Note that we have increased the simulation time 30 seconds: can you think of a reason why?
Slippery Slope
To simulate walking on a slippery slope, we need to adjust the friction defined in the contact force. For this tutorial, we have created a separate model in which we have done exactly that (see Tutorials/data/H0914MSS_osim3.osim
).
The items that have changed are called static_friction
, dynamic_friction
and viscous_friction
.
- Open the file
Tutorials/Tutorial 4d - Slippery Slope
In our SCONE scenario, we simply use the new model file:
model_file = data/H0914MSS_osim3.osim
We also change the objective function to allow for a lower minimum velocity:
<< data/MeasureGait05.scone >>
- Optimize the scenario with the modified OpenSim model (
Ctrl + F5
)
Eventually, this will produce a controller that is robust against walking on a slippery slope. Be sure to check the intermediate results in the Optimization Results
panel!