Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | tutorials:gait [2022/01/21 11:07] (current) – [Initial Pose Optimization] thomas | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Healthy Gait ====== | ||
+ | <callout type=" | ||
+ | This tutorial shows how to optimize gait controllers, | ||
+ | </ | ||
+ | ==== Reflex Gait Controller ==== | ||
+ | * Open the scenario '' | ||
+ | |||
+ | As you can see, the scone file is fairly short and doesn' | ||
+ | < | ||
+ | # Controller for gait, based on [Geyer & Herr 2010] | ||
+ | << data/ | ||
+ | |||
+ | # Measure for gait | ||
+ | << data/ | ||
+ | </ | ||
+ | |||
+ | 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 '' | ||
+ | |||
+ | The actual Reflex Gait Controller is defined inside the file '' | ||
+ | |||
+ | The actual parameters that are being optimized are again shown in the // | ||
+ | |||
+ | ==== 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/ | ||
+ | initial_state_offset = 0~0.01< | ||
+ | initial_state_offset_exclude = " | ||
+ | </ | ||
+ | |||
+ | Here, the '' | ||
+ | |||
+ | ==== Gait at Different Speeds ==== | ||
+ | * Open the file '' | ||
+ | |||
+ | 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 '' | ||
+ | |||
+ | <code python> | ||
+ | # 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 '' | ||
+ | |||
+ | ==== Perturbed Gait ==== | ||
+ | * Open the file '' | ||
+ | |||
+ | Here you will see that we use a [[ref: | ||
+ | <code python> | ||
+ | CompositeController { | ||
+ | # Controller for gait, based on [Geyer & Herr 2010] | ||
+ | << data/ | ||
+ | |||
+ | # 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 [[ref: | ||
+ | |||
+ | * Test the optimization by pressing '' | ||
+ | |||
+ | 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 '' | ||
+ | |||
+ | 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 '' | ||
+ | |||
+ | The items that have changed are called '' | ||
+ | |||
+ | * Open the file '' | ||
+ | |||
+ | In our SCONE scenario, we simply use the new model file: | ||
+ | <code python> | ||
+ | model_file = data/ | ||
+ | </ | ||
+ | |||
+ | We also change the objective function to allow for a lower minimum velocity: | ||
+ | <code python> | ||
+ | << data/ | ||
+ | </ | ||
+ | |||
+ | * Optimize the scenario with the modified OpenSim model ('' | ||
+ | |||
+ | Eventually, this will produce a controller that is robust against walking on a slippery slope. Be sure to check the intermediate results in the '' |