Skip to content

Commit

Permalink
fix kick-generation & behavior simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
schluis committed Mar 20, 2024
1 parent cf841e1 commit 17906fb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/control/src/behavior/dribble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn is_kick_pose_reached(
is_x_reached && is_y_reached && is_orientation_reached
}

fn precision_kick(game_controller_state: Option<FilteredGameControllerState>) -> bool {
pub fn precision_kick(game_controller_state: Option<FilteredGameControllerState>) -> bool {
let game_controller_state = game_controller_state.unwrap_or_default();

let penalty_shootout = matches!(
Expand Down
2 changes: 1 addition & 1 deletion crates/control/src/behavior/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod calibrate;
mod defend;
mod dribble;
pub mod dribble;
mod fall_safely;
mod head;
mod initial;
Expand Down
14 changes: 8 additions & 6 deletions crates/control/src/kick_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use linear_algebra::{
distance, point, vector, IntoFramed, Isometry2, Orientation2, Point, Point2, Pose, UnitComplex,
Vector2,
};
use spl_network_messages::GamePhase;
use types::{
field_dimensions::FieldDimensions,
filtered_game_controller_state::FilteredGameControllerState,
kick_decision::KickDecision,
kick_target::KickTarget,
motion_command::KickVariant,
Expand All @@ -27,6 +27,8 @@ use types::{
world_state::BallState,
};

use crate::behavior::dribble::precision_kick;

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

Expand All @@ -38,7 +40,8 @@ pub struct CycleContext {
ground_to_field: RequiredInput<Option<Isometry2<Ground, Field>>, "ground_to_field?">,
ball_state: RequiredInput<Option<BallState>, "ball_state?">,
obstacles: Input<Vec<Obstacle>, "obstacles">,
game_phase: Input<Option<GamePhase>, "filtered_game_controller_state?.game_phase">,
game_controller_state:
Input<Option<FilteredGameControllerState>, "filtered_game_controller_state?">,
field_dimensions: Parameter<FieldDimensions, "field_dimensions">,

in_walk_kicks: Parameter<InWalkKicksParameters, "in_walk_kicks">,
Expand Down Expand Up @@ -72,18 +75,17 @@ impl KickSelector {

pub fn cycle(&mut self, mut context: CycleContext) -> Result<MainOutputs> {
let ball_position = context.ball_state.ball_in_ground;
let penalty_shootout =
matches!(context.game_phase, Some(GamePhase::PenaltyShootout { .. }));
let precision_kick = precision_kick(context.game_controller_state.copied());

let sides = [Side::Left, Side::Right];
let mut kick_variants = Vec::new();
if context.in_walk_kicks.forward.enabled {
kick_variants.push(KickVariant::Forward)
}
if context.in_walk_kicks.turn.enabled && !penalty_shootout {
if context.in_walk_kicks.turn.enabled && !precision_kick {
kick_variants.push(KickVariant::Turn)
}
if context.in_walk_kicks.side.enabled && !penalty_shootout {
if context.in_walk_kicks.side.enabled && !precision_kick {
kick_variants.push(KickVariant::Side)
}

Expand Down
5 changes: 1 addition & 4 deletions tools/behavior_simulator/src/cycler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,7 @@ impl BehaviorCycler {
own_database
.main_outputs
.filtered_game_controller_state
.as_ref()
.map(|filtered_game_controller_state| {
&filtered_game_controller_state.game_phase
}),
.as_ref(),
&parameters.field_dimensions,
&parameters.in_walk_kicks,
&parameters.kick_selector.angle_distance_weight,
Expand Down

0 comments on commit 17906fb

Please sign in to comment.