Skip to content
Merged

Gamepad #2145

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions crates/control/src/motion/booster_walking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use color_eyre::Result;
use context_attribute::context;
use framework::{AdditionalOutput, MainOutput};
use hardware::PathsInterface;
use linear_algebra::vector;
use serde::{Deserialize, Serialize};
use types::{
cycle_time::CycleTime,
joints::Joints,
motion_command::{HeadMotion, MotionCommand},
motion_command::MotionCommand,
parameters::{MotorCommandParameters, RLWalkingParameters},
};
use walking_inference::{inference::WalkingInference, inputs::WalkingInferenceInputs};
Expand Down Expand Up @@ -36,6 +35,7 @@ pub struct CycleContext {
imu_state: Input<ImuState, "imu_state">,
serial_motor_states: Input<Joints<MotorState>, "serial_motor_states">,
cycle_time: Input<CycleTime, "cycle_time">,
motion_command: Input<MotionCommand, "motion_command">,
}

#[context]
Expand Down Expand Up @@ -63,19 +63,10 @@ impl RLWalking {
}

pub fn cycle(&mut self, mut context: CycleContext) -> Result<MainOutputs> {
let motion_command = &MotionCommand::WalkWithVelocity {
velocity: vector!(
context.walking_parameters.walk_command[0],
context.walking_parameters.walk_command[1]
),
angular_velocity: context.walking_parameters.walk_command[2],
head: HeadMotion::Center,
};

let (walking_inference_inputs, inference_output_positions) =
self.walking_inference.do_inference(
*context.cycle_time,
motion_command,
context.motion_command,
context.imu_state,
*context.serial_motor_states,
context.walking_parameters,
Expand Down
1 change: 1 addition & 0 deletions crates/control/src/motion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ pub mod look_around;
pub mod look_at;
pub mod motion_selector;
pub mod motor_commands_collector;
pub mod remote_control;
pub mod sit_down;
pub mod wide_stance;
48 changes: 48 additions & 0 deletions crates/control/src/motion/remote_control.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use color_eyre::Result;
use context_attribute::context;

use framework::MainOutput;
use linear_algebra::vector;
use serde::{Deserialize, Serialize};
use types::{
motion_command::{HeadMotion, MotionCommand},
parameters::RemoteControlParameters,
};

#[context]
pub struct CreationContext {}

#[context]
pub struct CycleContext {
remote_control_parameters: Parameter<RemoteControlParameters, "remote_control_parameters">,
}

#[derive(Deserialize, Serialize)]
pub struct RemoteControl {}

#[context]
#[derive(Default)]
pub struct MainOutputs {
pub motion_command: MainOutput<MotionCommand>,
}

impl RemoteControl {
pub fn new(_context: CreationContext) -> Result<Self> {
Ok(RemoteControl {})
}

pub fn cycle(&mut self, context: CycleContext) -> Result<MainOutputs> {
let motion_command = MotionCommand::WalkWithVelocity {
head: HeadMotion::Center,
velocity: vector![
context.remote_control_parameters.walk.forward,
context.remote_control_parameters.walk.left,
],
angular_velocity: context.remote_control_parameters.walk.turn,
};

Ok(MainOutputs {
motion_command: motion_command.into(),
})
}
}
1 change: 1 addition & 0 deletions crates/hulk_manifest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub fn collect_hulk_cyclers(root: impl AsRef<Path>) -> Result<Cyclers, Error> {
// "control::motion::center_jump",
"control::motion::command_sender",
"control::motion::booster_walking",
"control::motion::remote_control",
// "control::motion::condition_input_provider",
// "control::motion::dispatching_interpolator",
// "control::motion::fall_protector",
Expand Down
8 changes: 8 additions & 0 deletions crates/types/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ use crate::{
joints::Joints,
motion_command::{KickVariant, MotionCommand},
roles::Role,
step::Step,
};

#[derive(
Clone, Debug, Default, Deserialize, Serialize, PathSerialize, PathDeserialize, PathIntrospect,
)]
pub struct RemoteControlParameters {
pub walk: Step,
}

#[derive(
Clone, Debug, Default, Deserialize, Serialize, PathSerialize, PathDeserialize, PathIntrospect,
)]
Expand Down
6 changes: 3 additions & 3 deletions crates/walking_inference/src/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ impl WalkingInferenceInputs {
_ => todo!(),
};

let gait_frequency =
let (gait_frequency, last_gait_progress) =
if linear_velocity_command.norm() < 1e-5 && angular_velocity_command.abs() < 1e-5 {
0.0
(0.0, 0.0)
} else {
walking_parameters.gait_frequency
(walking_parameters.gait_frequency, last_gait_progress)
Comment thread
knoellle marked this conversation as resolved.
};
let gait_progress =
last_gait_progress + gait_frequency * cycle_time.last_cycle_duration.as_secs_f32();
Expand Down
7 changes: 7 additions & 0 deletions etc/parameters/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,12 @@
"ankle_down": 1
}
}
},
"remote_control_parameters": {
"walk": {
"forward": 0.0,
"left": 0.0,
"turn": 0.0
}
}
}
4 changes: 2 additions & 2 deletions tools/twix/src/panels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod map;
mod mujoco_simulator;
mod parameter;
mod plot;
mod remote;
mod remote_control;
mod text;
mod vision_tuner;

Expand All @@ -32,6 +32,6 @@ pub use map::MapPanel;
pub use mujoco_simulator::MujocoSimulatorPanel;
pub use parameter::ParameterPanel;
pub use plot::PlotPanel;
pub use remote::RemotePanel;
pub use remote_control::RemotePanel;
pub use text::TextPanel;
pub use vision_tuner::VisionTunerPanel;
148 changes: 0 additions & 148 deletions tools/twix/src/panels/remote.rs

This file was deleted.

Loading