Skip to content

Commit ca08a87

Browse files
committed
impl structure of walk_to_ball-node
1 parent de7b120 commit ca08a87

7 files changed

Lines changed: 32 additions & 138 deletions

File tree

Cargo.lock

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

crates/behavior/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ homepage.workspace = true
88
[dependencies]
99
color-eyre = { workspace = true }
1010
context_attribute = { workspace = true }
11+
coordinate_systems = { workspace = true }
1112
framework = { workspace = true }
1213
hardware = { workspace = true }
1314
serde = { workspace = true }
Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
use color_eyre::{eyre::WrapErr, Result};
1+
use color_eyre::Result;
22
use context_attribute::context;
3-
use framework::{MainOutput, PerceptionInput};
3+
use coordinate_systems::Ground;
4+
use framework::MainOutput;
45
use serde::{Deserialize, Serialize};
5-
use types::cycle_time::CycleTime;
6-
use types::world_state::BallState;
7-
use types::{
8-
camera_position::CameraPosition,
9-
motion_command::{HeadMotion, ImageRegion, MotionCommand},
10-
parameters::DribblingParameters,
11-
world_state::WorldState,
12-
};
6+
use types::ball_position::BallPosition;
7+
use types::motion_command::{HeadMotion, ImageRegion, MotionCommand};
138

149
#[derive(Deserialize, Serialize)]
1510
pub struct WalkToBall {}
@@ -19,11 +14,7 @@ pub struct CreationContext {}
1914

2015
#[context]
2116
pub struct CycleContext {
22-
cycle_time: Input<CycleTime, "cycle_time">,
23-
world_state: Input<WorldState, "world_state">,
24-
ball_state: Input<BallState, "World_state", "ball_state">,
25-
// dribble_walk_speed: Parameter<WalkSpeed, "walk_speed.dribble">,
26-
// parameters: Parameter<BehaviorParameters, "behavior">,
17+
ball_position: Input<Option<BallPosition<Ground>>, "World_state", "ball_position">,
2718
}
2819

2920
#[context]
@@ -38,20 +29,26 @@ impl WalkToBall {
3829
}
3930

4031
pub fn cycle(&mut self, context: CycleContext) -> Result<MainOutputs> {
41-
let ball_position = context.ball_state.ball_in_ground;
42-
let head = HeadMotion::LookAt {
43-
target: ball_position,
44-
image_region_target: ImageRegion::Center,
45-
camera: Some(CameraPosition::Bottom),
32+
let next_motion_command = match context.ball_position {
33+
Some(ball_position) => {
34+
let ball_coordinates_in_ground = ball_position.position.coords();
35+
let head = HeadMotion::LookAt {
36+
target: ball_coordinates_in_ground.as_point(),
37+
image_region_target: ImageRegion::Center,
38+
};
39+
MotionCommand::WalkWithVelocity {
40+
head,
41+
velocity: ball_coordinates_in_ground.normalize() * 0.1, // TODO: parameterize
42+
angular_velocity: ball_coordinates_in_ground.y().clamp(-0.25, 0.25), // TODO: parameterize
43+
}
44+
}
45+
None => MotionCommand::Stand {
46+
head: HeadMotion::LookAround,
47+
},
4648
};
4749

4850
Ok(MainOutputs {
49-
motion_command: MotionCommand::WalkWithVelocity {
50-
head,
51-
velocity: ball_position.coords().normalize() * 0.1,
52-
angular_velocity: ball_position.coords().y().clamp(-0.25, 0.25), // TODO: parameterize
53-
}
54-
.into(),
51+
motion_command: next_motion_command.into(),
5552
})
5653
}
5754
}

crates/world_state/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ license.workspace = true
66
homepage.workspace = true
77

88
[dependencies]
9+
ball_filter = { workspace = true }
910
color-eyre = { workspace = true }
1011
context_attribute = { workspace = true }
1112
coordinate_systems = { workspace = true }
1213
filtering = { workspace = true }
1314
framework = { workspace = true }
1415
hardware = { workspace = true }
1516
linear_algebra = { workspace = true }
17+
nalgebra = { workspace = true }
18+
projection = { workspace = true }
1619
serde = { workspace = true }
1720
spl_network_messages = { workspace = true }
1821
tokio = { workspace = true }

crates/world_state/src/ball_filter.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ use ball_filter::BallFilter as BallFiltering;
66
use context_attribute::context;
77
use coordinate_systems::Ground;
88
use framework::{MainOutput, PerceptionInput};
9-
use projection::camera_matrices::CameraMatrices;
109
use types::{
1110
ball_detection::BallPercept,
1211
ball_position::{BallPosition, HypotheticalBallPosition},
1312
cycle_time::CycleTime,
14-
field_dimensions::FieldDimensions,
1513
};
1614

1715
#[derive(Deserialize, Serialize)]

crates/world_state/src/ball_state_composer.rs

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

crates/world_state/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pub mod ball_state_composer;
1+
pub mod ball_filter;
22
pub mod data_receiver;

0 commit comments

Comments
 (0)