From bafa1544ef6882fb305ba92ba654deda0ba14c39 Mon Sep 17 00:00:00 2001 From: Madelon Date: Tue, 4 Jul 2023 16:39:20 +0200 Subject: [PATCH 1/8] implements first draft --- crates/control/src/role_assignment.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/control/src/role_assignment.rs b/crates/control/src/role_assignment.rs index a1c00ea6..4e4a8b62 100644 --- a/crates/control/src/role_assignment.rs +++ b/crates/control/src/role_assignment.rs @@ -634,10 +634,29 @@ fn am_better_striker( origin_pose: Isometry2, spl_message_ball_position: &spl_network_messages::BallPosition, ) -> bool { - (current_pose.inverse() * origin_pose * spl_message_ball_position.relative_position) - .coords - .norm() - < spl_message_ball_position.relative_position.coords.norm() + let relative_ball = current_pose.inverse() * origin_pose * spl_message_ball_position.relative_position; + // Distance calculation + let our_distance = relative_ball.coords.norm() + let other_distance = spl_message_ball_position.relative_position.coords.norm(); + // Angle calculation + let ball_to_us = Vector2::new(relative_ball.x, relative_ball.y); + let ball_to_other = Vector2::new(spl_message_ball_position.relative_position.x, spl_message_ball_position.relative_position.y); + let forward = Vector2::x(); + let our_angle = forward.angle(&ball_to_us); + let other_angle = forward.angle(&ball_to_other); + + // Creating the overall score + // m/s: 0.175 + // 2pi turn: 8 sec. + // 1 turn equals 1.4 meters + let our_estimated_time: f32 = (our_angle / (2*PI)) * 8.0 + our_distance * 1.75; + let other_estimated_time: f32 = (other_angle / (2*PI)) * 8.0 + other_distance * 1.75; + println!("Starting calculation"); + println!("{ball_to_us}: the distance from the ball to us (presumably in meters)"); + println!("{angle}: the angle between us and the angle, in rad."); + println!("{our_estimated_time}: our estimated time."); + return our_estimated_time < other_estimated_time; + } fn generate_role( From 508566925e5cfa5df298976144bc2f70b40927b9 Mon Sep 17 00:00:00 2001 From: Madelon Date: Tue, 4 Jul 2023 17:07:44 +0200 Subject: [PATCH 2/8] debug --- crates/control/src/role_assignment.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/control/src/role_assignment.rs b/crates/control/src/role_assignment.rs index 4e4a8b62..efcba4fb 100644 --- a/crates/control/src/role_assignment.rs +++ b/crates/control/src/role_assignment.rs @@ -3,7 +3,7 @@ use std::time::{Duration, SystemTime}; use color_eyre::{eyre::WrapErr, Result}; use context_attribute::context; use framework::{MainOutput, PerceptionInput}; -use nalgebra::{Isometry2, Point2}; +use nalgebra::{Isometry2, Point2, Vector2}; use spl_network_messages::{ GameControllerReturnMessage, GamePhase, HulkMessage, Penalty, PlayerNumber, Team, }; @@ -636,7 +636,7 @@ fn am_better_striker( ) -> bool { let relative_ball = current_pose.inverse() * origin_pose * spl_message_ball_position.relative_position; // Distance calculation - let our_distance = relative_ball.coords.norm() + let our_distance = relative_ball.coords.norm(); let other_distance = spl_message_ball_position.relative_position.coords.norm(); // Angle calculation let ball_to_us = Vector2::new(relative_ball.x, relative_ball.y); @@ -649,11 +649,11 @@ fn am_better_striker( // m/s: 0.175 // 2pi turn: 8 sec. // 1 turn equals 1.4 meters - let our_estimated_time: f32 = (our_angle / (2*PI)) * 8.0 + our_distance * 1.75; - let other_estimated_time: f32 = (other_angle / (2*PI)) * 8.0 + other_distance * 1.75; + let our_estimated_time: f32 = (our_angle / (2.0*3.14)) * 8.0 + our_distance * 1.75; + let other_estimated_time: f32 = (other_angle / (2.0*3.14)) * 8.0 + other_distance * 1.75; println!("Starting calculation"); println!("{ball_to_us}: the distance from the ball to us (presumably in meters)"); - println!("{angle}: the angle between us and the angle, in rad."); + println!("{our_angle}: the angle between us and the angle, in rad."); println!("{our_estimated_time}: our estimated time."); return our_estimated_time < other_estimated_time; From aa8ee4498226531f1f40ea72959ef8b2971a3942 Mon Sep 17 00:00:00 2001 From: Madelon Date: Thu, 6 Jul 2023 09:21:04 +0200 Subject: [PATCH 3/8] More debug --- crates/control/src/role_assignment.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/control/src/role_assignment.rs b/crates/control/src/role_assignment.rs index efcba4fb..f8064179 100644 --- a/crates/control/src/role_assignment.rs +++ b/crates/control/src/role_assignment.rs @@ -649,12 +649,15 @@ fn am_better_striker( // m/s: 0.175 // 2pi turn: 8 sec. // 1 turn equals 1.4 meters - let our_estimated_time: f32 = (our_angle / (2.0*3.14)) * 8.0 + our_distance * 1.75; - let other_estimated_time: f32 = (other_angle / (2.0*3.14)) * 8.0 + other_distance * 1.75; + let our_estimated_time: f32 = (our_angle / (2.0*3.14)) * 8.0 + our_distance * 0.175; + let other_estimated_time: f32 = (other_angle / (2.0*3.14)) * 8.0 + other_distance * 0.175; println!("Starting calculation"); - println!("{ball_to_us}: the distance from the ball to us (presumably in meters)"); - println!("{our_angle}: the angle between us and the angle, in rad."); + println!("{our_distance}: the distance from the ball to us (presumably in meters)"); + println!("{other_distance}: the distance from the ball to the others (presumably in meters)"); + println!("{our_angle}: the angle between us and the ball, in rad."); + println!("{other_angle}: the angle between the other and the ball, in rad."); println!("{our_estimated_time}: our estimated time."); + println!("{other_estimated_time}: other estimated time."); return our_estimated_time < other_estimated_time; } From 1d3850e4609864ea3cfaf496a8ce702e548d21d9 Mon Sep 17 00:00:00 2001 From: Madelon Date: Thu, 6 Jul 2023 14:52:49 +0200 Subject: [PATCH 4/8] implements who is closer to the goal --- crates/control/src/role_assignment.rs | 52 ++++++++++++++++++++------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/crates/control/src/role_assignment.rs b/crates/control/src/role_assignment.rs index f8064179..793beb6b 100644 --- a/crates/control/src/role_assignment.rs +++ b/crates/control/src/role_assignment.rs @@ -1,4 +1,5 @@ use std::time::{Duration, SystemTime}; +use std::f32::consts::PI; use color_eyre::{eyre::WrapErr, Result}; use context_attribute::context; @@ -206,6 +207,7 @@ impl RoleAssignment { *context.player_number, context.spl_network.striker_trusts_team_ball, context.optional_roles, + context.field_dimensions, ); } else { for spl_message in spl_messages { @@ -228,6 +230,7 @@ impl RoleAssignment { *context.player_number, context.spl_network.striker_trusts_team_ball, context.optional_roles, + context.field_dimensions, ); } } @@ -303,6 +306,7 @@ fn process_role_state_machine( player_number: PlayerNumber, striker_trusts_team_ball: Duration, optional_roles: &[Role], + field_dimensions: &FieldDimensions // size = 8, align = 0x8, ) -> (Role, bool, Option) { // Returns (role, send_spl_striker_message, team_ball) if let Some(game_controller_state) = game_controller_state { @@ -380,6 +384,7 @@ fn process_role_state_machine( cycle_start_time, game_controller_state, optional_roles, + field_dimensions, ), }, @@ -404,6 +409,7 @@ fn process_role_state_machine( cycle_start_time, game_controller_state, optional_roles, + field_dimensions, ), }, @@ -420,6 +426,7 @@ fn process_role_state_machine( cycle_start_time, game_controller_state, optional_roles, + field_dimensions, ), }, @@ -448,6 +455,7 @@ fn process_role_state_machine( cycle_start_time, game_controller_state, optional_roles, + field_dimensions, ), }, @@ -464,6 +472,7 @@ fn process_role_state_machine( cycle_start_time, game_controller_state, optional_roles, + field_dimensions, ), }, @@ -489,6 +498,7 @@ fn process_role_state_machine( cycle_start_time, game_controller_state, optional_roles, + field_dimensions, ), }, @@ -512,6 +522,7 @@ fn process_role_state_machine( cycle_start_time, game_controller_state, optional_roles, + field_dimensions, ), }, @@ -544,6 +555,7 @@ fn process_role_state_machine( cycle_start_time, game_controller_state, optional_roles, + field_dimensions, ), }, } @@ -557,11 +569,13 @@ fn decide_if_claiming_striker_or_other_role( cycle_start_time: SystemTime, game_controller_state: Option<&GameControllerState>, optional_roles: &[Role], + field_positions: &FieldDimensions // size = 8, align = 0x8, ) -> (Role, bool, Option) { if am_better_striker( current_pose, spl_message.robot_to_field, spl_message_ball_position, + field_positions, ) { ( Role::Striker, @@ -633,6 +647,7 @@ fn am_better_striker( current_pose: Isometry2, origin_pose: Isometry2, spl_message_ball_position: &spl_network_messages::BallPosition, + field_dimensions: &FieldDimensions // size = 8, align = 0x8, ) -> bool { let relative_ball = current_pose.inverse() * origin_pose * spl_message_ball_position.relative_position; // Distance calculation @@ -642,22 +657,35 @@ fn am_better_striker( let ball_to_us = Vector2::new(relative_ball.x, relative_ball.y); let ball_to_other = Vector2::new(spl_message_ball_position.relative_position.x, spl_message_ball_position.relative_position.y); let forward = Vector2::x(); - let our_angle = forward.angle(&ball_to_us); - let other_angle = forward.angle(&ball_to_other); + let our_first_angle = forward.angle(&ball_to_us); + let other_first_angle = forward.angle(&ball_to_other); + + let opponent_goal_center_us = current_pose.inverse() * Vector2::new(field_dimensions.length / 2.0, 0.0); + let opponent_goal_center_other = origin_pose.inverse() * Vector2::new(field_dimensions.length / 2.0, 0.0); + + let ball_to_goal_us = opponent_goal_center_us - ball_to_us; + let ball_to_goal_other = opponent_goal_center_other - ball_to_other; + + let our_ball_to_our_goal = ball_to_us.angle(&opponent_goal_center_us); + let other_ball_to_other_goal = ball_to_other.angle(&opponent_goal_center_other); + + let mut our_second_angle: f32 = ball_to_us.angle(&ball_to_goal_us); + if our_ball_to_our_goal > 0.5 * PI { + our_second_angle -= PI; + } + + let mut other_second_angle = ball_to_other.angle(&ball_to_goal_other); + if other_ball_to_other_goal > 0.5 * PI { + other_second_angle -= PI; + } // Creating the overall score // m/s: 0.175 - // 2pi turn: 8 sec. + // 2pi turn (first, around own axis): 8 sec. + // 2pi turn (second, around ball): 12 sec (estimate). // 1 turn equals 1.4 meters - let our_estimated_time: f32 = (our_angle / (2.0*3.14)) * 8.0 + our_distance * 0.175; - let other_estimated_time: f32 = (other_angle / (2.0*3.14)) * 8.0 + other_distance * 0.175; - println!("Starting calculation"); - println!("{our_distance}: the distance from the ball to us (presumably in meters)"); - println!("{other_distance}: the distance from the ball to the others (presumably in meters)"); - println!("{our_angle}: the angle between us and the ball, in rad."); - println!("{other_angle}: the angle between the other and the ball, in rad."); - println!("{our_estimated_time}: our estimated time."); - println!("{other_estimated_time}: other estimated time."); + let our_estimated_time: f32 = (our_first_angle / (2.0*PI)) * 8.0 + (our_second_angle / (2.0*PI)) * 12.0 + our_distance * 0.175; + let other_estimated_time: f32 = (other_first_angle / (2.0*PI)) * 8.0 + (other_second_angle / (2.0*PI)) * 12.0 + other_distance * 0.175; return our_estimated_time < other_estimated_time; } From 223aa799c93f9031847d5d85f929bfa2ab679211 Mon Sep 17 00:00:00 2001 From: Madelon Date: Thu, 6 Jul 2023 15:31:33 +0200 Subject: [PATCH 5/8] starting vars in config files --- crates/control/src/role_assignment.rs | 1 + crates/types/src/configuration.rs | 8 ++++++++ etc/configuration/default.json | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/crates/control/src/role_assignment.rs b/crates/control/src/role_assignment.rs index 793beb6b..a5a8ab54 100644 --- a/crates/control/src/role_assignment.rs +++ b/crates/control/src/role_assignment.rs @@ -11,6 +11,7 @@ use spl_network_messages::{ use types::{ configuration::SplNetwork, hardware::Interface, + // configuration::RoleAssignmentsSpeeds, messages::{IncomingMessage, OutgoingMessage}, BallPosition, CycleTime, FallState, FieldDimensions, GameControllerState, InitialPose, Players, PrimaryState, Role, diff --git a/crates/types/src/configuration.rs b/crates/types/src/configuration.rs index 99493406..1dea0403 100644 --- a/crates/types/src/configuration.rs +++ b/crates/types/src/configuration.rs @@ -80,6 +80,7 @@ pub struct Behavior { pub lost_ball: LostBall, pub optional_roles: Vec, pub path_planning: PathPlanning, + pub role_assignments_speeds: RoleAssignmentsSpeeds, pub role_positions: RolePositions, pub walk_and_stand: WalkAndStand, pub dribbling: Dribbling, @@ -158,6 +159,13 @@ pub struct InWalkKickInfo { pub enabled: bool, } +#[derive(Clone, Debug, Default, Deserialize, Serialize, SerializeHierarchy)] +pub struct RoleAssignmentsSpeeds { + pub walking_speed: f32, + pub rotation_axis_time: f32, + pub rotation_ball_time: f32, +} + #[derive(Clone, Debug, Default, Deserialize, Serialize, SerializeHierarchy)] pub struct Dribbling { pub hybrid_align_distance: f32, diff --git a/etc/configuration/default.json b/etc/configuration/default.json index 606487fb..ff514842 100644 --- a/etc/configuration/default.json +++ b/etc/configuration/default.json @@ -766,6 +766,11 @@ "nanos": 0, "secs": 10 }, + "role_assignment_speeds": { + "walking_speed": 0.175, + "rotation_axis_time": 8.0, + "rotation_ball_time": 12.0 + }, "injected_motion_command": null, "role_positions": { "defender_aggressive_ring_radius": 2.0, From d32d6e63aec6b52a8022b27e89b1b593b81a9192 Mon Sep 17 00:00:00 2001 From: Madelon Date: Fri, 7 Jul 2023 11:56:42 +0200 Subject: [PATCH 6/8] uses default values --- crates/control/src/role_assignment.rs | 28 ++++++++++++++++++++------- etc/configuration/default.json | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/crates/control/src/role_assignment.rs b/crates/control/src/role_assignment.rs index a5a8ab54..8007812e 100644 --- a/crates/control/src/role_assignment.rs +++ b/crates/control/src/role_assignment.rs @@ -9,9 +9,8 @@ use spl_network_messages::{ GameControllerReturnMessage, GamePhase, HulkMessage, Penalty, PlayerNumber, Team, }; use types::{ - configuration::SplNetwork, + configuration::{RoleAssignmentsSpeeds, SplNetwork}, hardware::Interface, - // configuration::RoleAssignmentsSpeeds, messages::{IncomingMessage, OutgoingMessage}, BallPosition, CycleTime, FallState, FieldDimensions, GameControllerState, InitialPose, Players, PrimaryState, Role, @@ -46,6 +45,7 @@ pub struct CycleContext { pub forced_role: Parameter, "role_assignment.forced_role?">, pub initial_poses: Parameter, "localization.initial_poses">, pub optional_roles: Parameter, "behavior.optional_roles">, + pub role_assignments_speeds: Parameter, pub player_number: Parameter, pub loser_duration: Parameter, pub spl_network: Parameter, @@ -209,6 +209,7 @@ impl RoleAssignment { context.spl_network.striker_trusts_team_ball, context.optional_roles, context.field_dimensions, + context.role_assignments_speeds, ); } else { for spl_message in spl_messages { @@ -232,6 +233,7 @@ impl RoleAssignment { context.spl_network.striker_trusts_team_ball, context.optional_roles, context.field_dimensions, + context.role_assignments_speeds, ); } } @@ -307,7 +309,8 @@ fn process_role_state_machine( player_number: PlayerNumber, striker_trusts_team_ball: Duration, optional_roles: &[Role], - field_dimensions: &FieldDimensions // size = 8, align = 0x8, + field_dimensions: &FieldDimensions, + role_assignments_speeds: &RoleAssignmentsSpeeds, ) -> (Role, bool, Option) { // Returns (role, send_spl_striker_message, team_ball) if let Some(game_controller_state) = game_controller_state { @@ -386,6 +389,7 @@ fn process_role_state_machine( game_controller_state, optional_roles, field_dimensions, + role_assignments_speeds, ), }, @@ -411,6 +415,7 @@ fn process_role_state_machine( game_controller_state, optional_roles, field_dimensions, + role_assignments_speeds, ), }, @@ -428,6 +433,7 @@ fn process_role_state_machine( game_controller_state, optional_roles, field_dimensions, + role_assignments_speeds, ), }, @@ -457,6 +463,7 @@ fn process_role_state_machine( game_controller_state, optional_roles, field_dimensions, + role_assignments_speeds, ), }, @@ -474,6 +481,7 @@ fn process_role_state_machine( game_controller_state, optional_roles, field_dimensions, + role_assignments_speeds, ), }, @@ -500,6 +508,7 @@ fn process_role_state_machine( game_controller_state, optional_roles, field_dimensions, + role_assignments_speeds, ), }, @@ -524,6 +533,7 @@ fn process_role_state_machine( game_controller_state, optional_roles, field_dimensions, + role_assignments_speeds, ), }, @@ -557,6 +567,7 @@ fn process_role_state_machine( game_controller_state, optional_roles, field_dimensions, + role_assignments_speeds, ), }, } @@ -570,13 +581,15 @@ fn decide_if_claiming_striker_or_other_role( cycle_start_time: SystemTime, game_controller_state: Option<&GameControllerState>, optional_roles: &[Role], - field_positions: &FieldDimensions // size = 8, align = 0x8, + field_positions: &FieldDimensions, + role_assignments_speeds:&RoleAssignmentsSpeeds, ) -> (Role, bool, Option) { if am_better_striker( current_pose, spl_message.robot_to_field, spl_message_ball_position, field_positions, + role_assignments_speeds, ) { ( Role::Striker, @@ -648,7 +661,8 @@ fn am_better_striker( current_pose: Isometry2, origin_pose: Isometry2, spl_message_ball_position: &spl_network_messages::BallPosition, - field_dimensions: &FieldDimensions // size = 8, align = 0x8, + field_dimensions: &FieldDimensions, + role_assignments_speeds: &RoleAssignmentsSpeeds, ) -> bool { let relative_ball = current_pose.inverse() * origin_pose * spl_message_ball_position.relative_position; // Distance calculation @@ -685,8 +699,8 @@ fn am_better_striker( // 2pi turn (first, around own axis): 8 sec. // 2pi turn (second, around ball): 12 sec (estimate). // 1 turn equals 1.4 meters - let our_estimated_time: f32 = (our_first_angle / (2.0*PI)) * 8.0 + (our_second_angle / (2.0*PI)) * 12.0 + our_distance * 0.175; - let other_estimated_time: f32 = (other_first_angle / (2.0*PI)) * 8.0 + (other_second_angle / (2.0*PI)) * 12.0 + other_distance * 0.175; + let our_estimated_time: f32 = (our_first_angle / (2.0*PI)) * role_assignments_speeds.rotation_axis_time + (our_second_angle / (2.0*PI)) * role_assignments_speeds.rotation_ball_time + our_distance * role_assignments_speeds.walking_speed; + let other_estimated_time: f32 = (other_first_angle / (2.0*PI)) * role_assignments_speeds.rotation_axis_time + (other_second_angle / (2.0*PI)) * role_assignments_speeds.rotation_ball_time + other_distance * role_assignments_speeds.walking_speed; return our_estimated_time < other_estimated_time; } diff --git a/etc/configuration/default.json b/etc/configuration/default.json index ff514842..a952e720 100644 --- a/etc/configuration/default.json +++ b/etc/configuration/default.json @@ -766,7 +766,7 @@ "nanos": 0, "secs": 10 }, - "role_assignment_speeds": { + "role_assignments_speeds": { "walking_speed": 0.175, "rotation_axis_time": 8.0, "rotation_ball_time": 12.0 From ab5e1d035e5f902ba3abbb96d9711d21bfa4e19a Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Fri, 7 Jul 2023 14:57:19 +0200 Subject: [PATCH 7/8] add logs --- crates/control/src/role_assignment.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/crates/control/src/role_assignment.rs b/crates/control/src/role_assignment.rs index 8007812e..3c60b890 100644 --- a/crates/control/src/role_assignment.rs +++ b/crates/control/src/role_assignment.rs @@ -664,10 +664,13 @@ fn am_better_striker( field_dimensions: &FieldDimensions, role_assignments_speeds: &RoleAssignmentsSpeeds, ) -> bool { + println!("starting calculation"); let relative_ball = current_pose.inverse() * origin_pose * spl_message_ball_position.relative_position; // Distance calculation let our_distance = relative_ball.coords.norm(); let other_distance = spl_message_ball_position.relative_position.coords.norm(); + println!("{our_distance} our distance to the ball"); + println!("{other_distance} other distance to the ball"); // Angle calculation let ball_to_us = Vector2::new(relative_ball.x, relative_ball.y); let ball_to_other = Vector2::new(spl_message_ball_position.relative_position.x, spl_message_ball_position.relative_position.y); @@ -675,25 +678,42 @@ fn am_better_striker( let our_first_angle = forward.angle(&ball_to_us); let other_first_angle = forward.angle(&ball_to_other); + println!("{our_first_angle} our angle to the ball-us line"); + println!("{other_first_angle} other angle to the ball-other line"); + let opponent_goal_center_us = current_pose.inverse() * Vector2::new(field_dimensions.length / 2.0, 0.0); let opponent_goal_center_other = origin_pose.inverse() * Vector2::new(field_dimensions.length / 2.0, 0.0); + // println!("{opponent_goal_center_us.norm()} our distance to the goal"); + // println!("{opponent_goal_center_other.norm()} other distance to the goal"); + let ball_to_goal_us = opponent_goal_center_us - ball_to_us; let ball_to_goal_other = opponent_goal_center_other - ball_to_other; + // println!("{ball_to_goal_us.norm()} our percieved distance ball and goal"); + // println!("{ball_to_goal_other.norm()} other percieved distance ball and goal"); + let our_ball_to_our_goal = ball_to_us.angle(&opponent_goal_center_us); let other_ball_to_other_goal = ball_to_other.angle(&opponent_goal_center_other); + println!("{our_ball_to_our_goal} our shortest angle between the ball-us line and the us-goal line"); + println!("{other_ball_to_other_goal} other shortest angle between the ball-us line and the other-goal line"); + let mut our_second_angle: f32 = ball_to_us.angle(&ball_to_goal_us); if our_ball_to_our_goal > 0.5 * PI { - our_second_angle -= PI; + println!("changing our second angle to be -180 degrees"); + our_second_angle = PI - our_second_angle; } let mut other_second_angle = ball_to_other.angle(&ball_to_goal_other); if other_ball_to_other_goal > 0.5 * PI { - other_second_angle -= PI; + println!("changing other second angle to be -180 degrees"); + other_second_angle = PI - other_second_angle; } + println!("{our_second_angle} our shortest angle between the ball-us line and the ball-goal line"); + println!("{other_second_angle} other shortest angle between the ball-us line and the ball-goal line"); + // Creating the overall score // m/s: 0.175 // 2pi turn (first, around own axis): 8 sec. @@ -701,6 +721,8 @@ fn am_better_striker( // 1 turn equals 1.4 meters let our_estimated_time: f32 = (our_first_angle / (2.0*PI)) * role_assignments_speeds.rotation_axis_time + (our_second_angle / (2.0*PI)) * role_assignments_speeds.rotation_ball_time + our_distance * role_assignments_speeds.walking_speed; let other_estimated_time: f32 = (other_first_angle / (2.0*PI)) * role_assignments_speeds.rotation_axis_time + (other_second_angle / (2.0*PI)) * role_assignments_speeds.rotation_ball_time + other_distance * role_assignments_speeds.walking_speed; + println!("{our_estimated_time} our estimated time"); + println!("{other_estimated_time} our estimated time"); return our_estimated_time < other_estimated_time; } From 654ab409eb23f12a4ec2ed848a938092a14fc2c5 Mon Sep 17 00:00:00 2001 From: Madelon Date: Sat, 8 Jul 2023 13:29:53 +0200 Subject: [PATCH 8/8] implements buffer --- crates/control/src/role_assignment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/control/src/role_assignment.rs b/crates/control/src/role_assignment.rs index 3c60b890..a7f938e1 100644 --- a/crates/control/src/role_assignment.rs +++ b/crates/control/src/role_assignment.rs @@ -723,7 +723,7 @@ fn am_better_striker( let other_estimated_time: f32 = (other_first_angle / (2.0*PI)) * role_assignments_speeds.rotation_axis_time + (other_second_angle / (2.0*PI)) * role_assignments_speeds.rotation_ball_time + other_distance * role_assignments_speeds.walking_speed; println!("{our_estimated_time} our estimated time"); println!("{other_estimated_time} our estimated time"); - return our_estimated_time < other_estimated_time; + return our_estimated_time < (other_estimated_time + 2.5); }