Skip to content

Commit 2109397

Browse files
rl-walking: add stabilization step(s) before standing still (HULKs#2180)
Co-authored-by: Johannes <149575214+pejotejo@users.noreply.github.com>
1 parent b3fc681 commit 2109397

5 files changed

Lines changed: 35 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/types/src/parameters.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ pub enum StepPlannerMode {
492492
)]
493493
pub struct RLWalkingParameters {
494494
pub gait_frequency: f32,
495+
pub stabilizing_interval_compression_factor: f32,
496+
pub stabilizing_interval_completion_threshold: f32,
495497
pub number_of_actions: usize,
496498
pub number_of_observations: usize,
497499
pub torque_limits: Joints,

crates/walking_inference/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ license.workspace = true
66
homepage.workspace = true
77

88
[dependencies]
9+
approx = { workspace = true }
910
booster = { workspace = true }
1011
color-eyre = { workspace = true }
1112
context_attribute = { workspace = true }

crates/walking_inference/src/inputs.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::f32::consts::PI;
22

3+
use approx::AbsDiffEq;
34
use booster::{JointsMotorState, MotorState};
45
use color_eyre::{eyre::ContextCompat, Result};
56
use coordinate_systems::{Ground, Robot};
@@ -75,12 +76,34 @@ impl WalkingInferenceInputs {
7576
_ => todo!(),
7677
};
7778

78-
let (gait_frequency, last_gait_progress) =
79-
if linear_velocity_command.norm() < 1e-5 && angular_velocity_command.abs() < 1e-5 {
80-
(0.0, 0.0)
81-
} else {
82-
(walking_parameters.gait_frequency, last_gait_progress)
83-
};
79+
let stabilizing_interval_progress = last_gait_progress
80+
+ walking_parameters.gait_frequency * cycle_time.last_cycle_duration.as_secs_f32();
81+
82+
let is_step_finished = (stabilizing_interval_progress
83+
* walking_parameters.stabilizing_interval_compression_factor
84+
* PI)
85+
.sin()
86+
.abs_diff_eq(
87+
&0.0,
88+
walking_parameters.stabilizing_interval_completion_threshold,
89+
)
90+
|| (stabilizing_interval_progress
91+
* walking_parameters.stabilizing_interval_compression_factor
92+
* PI)
93+
.cos()
94+
.abs_diff_eq(
95+
&1.0,
96+
walking_parameters.stabilizing_interval_completion_threshold,
97+
);
98+
99+
let (gait_frequency, last_gait_progress) = if linear_velocity_command.norm() < 1e-5
100+
&& angular_velocity_command.abs() < 1e-5
101+
&& is_step_finished
102+
{
103+
(0.0, 0.0)
104+
} else {
105+
(walking_parameters.gait_frequency, last_gait_progress)
106+
};
84107
let gait_progress =
85108
last_gait_progress + gait_frequency * cycle_time.last_cycle_duration.as_secs_f32();
86109

etc/parameters/default.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"rl_walking": {
33
"gait_frequency": 1,
4+
"stabilizing_interval_completion_threshold": 0.01,
5+
"stabilizing_interval_compression_factor": 1.0,
46
"number_of_actions": 12,
57
"number_of_observations": 47,
68
"torque_limits": {

0 commit comments

Comments
 (0)