Skip to content

Commit b41de16

Browse files
authored
Reintegrate motor_command_collector (HULKs#2215)
1 parent 0cac41e commit b41de16

15 files changed

Lines changed: 121 additions & 351 deletions

File tree

Cargo.lock

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

crates/control/src/motion/motor_commands_collector.rs

Lines changed: 0 additions & 229 deletions
This file was deleted.

crates/hulk_manifest/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pub fn collect_hulk_cyclers(root: impl AsRef<Path>) -> Result<Cyclers, Error> {
3232
"motion::booster_walking",
3333
"motion::remote_control",
3434
"motion::look_at",
35+
"motion::head_motion",
3536
"motion::motion_selector",
37+
"motion::motor_commands_collector",
3638
],
3739
execution_time_warning_threshold: Some(Duration::from_secs_f32(1.0 / 500.0)),
3840
},

crates/motion/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ booster = { workspace = true }
1111
color-eyre = { workspace = true }
1212
context_attribute = { workspace = true }
1313
coordinate_systems = { workspace = true }
14+
filtering = { workspace = true }
1415
framework = { workspace = true }
1516
hardware = { workspace = true }
1617
kinematics = { workspace = true }
1718
linear_algebra = { workspace = true }
1819
log = { workspace = true }
1920
path_serde = { workspace = true }
2021
projection = { workspace = true }
22+
proptest = { workspace = true }
2123
serde = { workspace = true }
2224
types = { workspace = true }
2325
walking_inference = { workspace = true }

crates/motion/src/booster_walking.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct CycleContext {
4141
#[context]
4242
#[derive(Default)]
4343
pub struct MainOutputs {
44-
pub target_joint_positions: MainOutput<Joints>,
44+
pub walking_target_joint_positions: MainOutput<Joints>,
4545
}
4646

4747
impl RLWalking {
@@ -77,16 +77,17 @@ impl RLWalking {
7777
.walking_inference_inputs
7878
.fill_if_subscribed(|| walking_inference_inputs.clone());
7979

80-
let target_joint_positions = context.common_motor_command_parameters.default_positions
81-
+ inference_output_positions * context.walking_parameters.control.action_scale;
80+
let walking_target_joint_positions =
81+
context.common_motor_command_parameters.default_positions
82+
+ inference_output_positions * context.walking_parameters.control.action_scale;
8283

8384
self.smoothed_target_joint_positions = self.smoothed_target_joint_positions
8485
* context.walking_parameters.joint_position_smoothing_factor
85-
+ target_joint_positions
86+
+ walking_target_joint_positions
8687
* (1.0 - context.walking_parameters.joint_position_smoothing_factor);
8788

8889
Ok(MainOutputs {
89-
target_joint_positions: self.smoothed_target_joint_positions.into(),
90+
walking_target_joint_positions: self.smoothed_target_joint_positions.into(),
9091
})
9192
}
9293
}

crates/motion/src/command_sender.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ use context_attribute::context;
44
use framework::AdditionalOutput;
55
use hardware::{LowCommandInterface, TimeInterface};
66
use serde::{Deserialize, Serialize};
7-
use types::{
8-
joints::{head::HeadJoints, Joints},
9-
motion_command::{HeadMotion, MotionCommand},
10-
parameters::MotorCommandParameters,
11-
};
7+
use types::{joints::Joints, parameters::MotorCommandParameters};
128

139
#[derive(Deserialize, Serialize)]
1410
pub struct CommandSender {
@@ -26,14 +22,11 @@ pub struct CreationContext {
2622
pub struct CycleContext {
2723
low_command: AdditionalOutput<LowCommand, "low_command">,
2824

29-
target_joint_positions: Input<Joints, "target_joint_positions">,
30-
look_at: Input<HeadJoints<f32>, "look_at">,
31-
motion_command: Input<MotionCommand, "selected_motion_command">,
32-
3325
walk_motor_command_parameters: Parameter<MotorCommandParameters, "common_motor_command">,
3426
_prepare_motor_command_parameters: Parameter<MotorCommandParameters, "prepare_motor_command">,
3527

3628
hardware_interface: HardwareInterface,
29+
collected_target_joint_positions: Input<Joints<f32>, "collected_target_joint_positions">,
3730
}
3831

3932
#[context]
@@ -55,20 +48,8 @@ impl CommandSender {
5548
&mut self,
5649
mut context: CycleContext<impl LowCommandInterface + TimeInterface>,
5750
) -> Result<MainOutputs> {
58-
let look_at_head_joints = match context.motion_command.head_motion() {
59-
Some(HeadMotion::LookAt { .. }) => Some(*context.look_at),
60-
_ => None,
61-
};
62-
63-
let target_joint_positions = Joints {
64-
head: look_at_head_joints.unwrap_or(context.target_joint_positions.head),
65-
left_arm: context.target_joint_positions.left_arm,
66-
right_arm: context.target_joint_positions.right_arm,
67-
left_leg: context.target_joint_positions.left_leg,
68-
right_leg: context.target_joint_positions.right_leg,
69-
};
7051
let walk_low_command = LowCommand::new(
71-
&target_joint_positions,
52+
context.collected_target_joint_positions,
7253
context.walk_motor_command_parameters,
7354
CommandType::Serial,
7455
);

0 commit comments

Comments
 (0)