From 08e61668fce0771a0bf638a7201f752eef0cd0ed Mon Sep 17 00:00:00 2001 From: Thunderbots Date: Thu, 26 Feb 2026 00:30:44 -0800 Subject: [PATCH 01/24] finish initial migration --- src/software/ai/hl/stp/tactic/BUILD | 1 + src/software/ai/hl/stp/tactic/Untitled | 1 + src/software/ai/hl/stp/tactic/all_tactics.h | 1 + .../ai/hl/stp/tactic/kick_or_chip/BUILD | 23 ++++ .../tactic/kick_or_chip/kick_or_chip_fsm.cpp | 76 +++++++++++ .../tactic/kick_or_chip/kick_or_chip_fsm.h | 125 ++++++++++++++++++ .../kick_or_chip/kick_or_chip_tactic.cpp | 35 +++++ .../tactic/kick_or_chip/kick_or_chip_tactic.h | 50 +++++++ 8 files changed, 312 insertions(+) create mode 100644 src/software/ai/hl/stp/tactic/Untitled create mode 100644 src/software/ai/hl/stp/tactic/kick_or_chip/BUILD create mode 100644 src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp create mode 100644 src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h create mode 100644 src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp create mode 100644 src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h diff --git a/src/software/ai/hl/stp/tactic/BUILD b/src/software/ai/hl/stp/tactic/BUILD index c69db8f0a3..20ff44969c 100644 --- a/src/software/ai/hl/stp/tactic/BUILD +++ b/src/software/ai/hl/stp/tactic/BUILD @@ -17,6 +17,7 @@ cc_library( ":tactic", "//software/ai/hl/stp/tactic/attacker:attacker_tactic", "//software/ai/hl/stp/tactic/chip:chip_tactic", + "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/crease_defender:crease_defender_tactic", "//software/ai/hl/stp/tactic/dribble:dribble_tactic", "//software/ai/hl/stp/tactic/get_behind_ball:get_behind_ball_tactic", diff --git a/src/software/ai/hl/stp/tactic/Untitled b/src/software/ai/hl/stp/tactic/Untitled new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/src/software/ai/hl/stp/tactic/Untitled @@ -0,0 +1 @@ + diff --git a/src/software/ai/hl/stp/tactic/all_tactics.h b/src/software/ai/hl/stp/tactic/all_tactics.h index b25fe9b575..d7a99096eb 100644 --- a/src/software/ai/hl/stp/tactic/all_tactics.h +++ b/src/software/ai/hl/stp/tactic/all_tactics.h @@ -8,6 +8,7 @@ #include "software/ai/hl/stp/tactic/goalie/goalie_tactic.h" #include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/ai/hl/stp/tactic/kick/kick_tactic.h" +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/pass_defender/pass_defender_tactic.h" #include "software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.h" diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD new file mode 100644 index 0000000000..fd3f4af7e0 --- /dev/null +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD @@ -0,0 +1,23 @@ +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "kick_or_chip_tactic", + srcs = [ + "kick_or_chip_fsm.cpp", + "kick_or_chip_tactic.cpp", + ], + hdrs = [ + "kick_or_chip_fsm.h", + "kick_or_chip_tactic.h", + ], + deps = [ + "//shared:constants", + "//software/ai/evaluation:enemy_threat", + "//software/ai/hl/stp/tactic", + "//software/ai/hl/stp/tactic/dribble:dribble_tactic", + "//software/ai/hl/stp/tactic/move:move_tactic", + "//software/geom/algorithms", + "//software/logger", + ], +) + diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp new file mode 100644 index 0000000000..b891c07044 --- /dev/null +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp @@ -0,0 +1,76 @@ +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h" + +#include "software/ai/hl/stp/tactic/move_primitive.h" + +KickOrChipFSM::KickOrChipFSM(std::shared_ptr ai_config_ptr) + : TacticFSM(ai_config_ptr) +{ +} + +void KickOrChipFSM::updateKick(const Update &event) +{ + Vector direction_to_kick = + Vector::createFromAngle(event.control_params.kick_direction); + Point kick_target = event.control_params.kick_origin - + direction_to_kick.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); + + event.common.set_primitive(std::make_unique( + event.common.robot, kick_target, event.control_params.kick_direction, + TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT, + TbotsProto::ObstacleAvoidanceMode::AGGRESSIVE, TbotsProto::DribblerMode::OFF, + TbotsProto::BallCollisionType::ALLOW, + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, + event.control_params.kick_speed_meters_per_second})); +} +void KickOrChipFSM::updateChip(const Update &event) +{ + Vector direction_to_chip = + Vector::createFromAngle(event.control_params.chip_direction); + Point chip_target = event.control_params.chip_origin - + direction_to_chip.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); + + event.common.set_primitive(std::make_unique( + event.common.robot, chip_target, event.control_params.chip_direction, + TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT, + TbotsProto::ObstacleAvoidanceMode::SAFE, TbotsProto::DribblerMode::OFF, + TbotsProto::BallCollisionType::ALLOW, + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, + event.control_params.chip_distance_meters})); +} + +void KickOrChipFSMSM::updateGetBehindBall( + const Update &event, boost::sml::back::process processEvent) +{ + GetBehindBallFSM::ControlParams control_params{ + .ball_location = event.control_params.kick_or_chip_origin, + .chick_direction = event.control_params.kick_or_chip_direction}; + + // Update the get behind ball fsm + processEvent(GetBehindBallFSM::Update(control_params, event.common)); +} + +bool KickOrChipFSM::ballChicked(const Update &event) +{ + return event.common.world_ptr->ball().hasBallBeenKicked( + event.control_params.kick_direction); +} + +bool KickOrChipFSM::shouldRealignWithBall(const Update &event) +{ + const Robot &robot = event.common.robot; + + // First check to see if it's too late to realign with the ball + if (robot.isNearDribbler(event.control_params.kick_origin, 0.05)) + { + return false; + } + + // Check if the robot is already aligned to kick the ball + return !isRobotReadyToChick(robot, event.control_params.kick_origin, + event.control_params.kick_direction); +} + +bool KickOrChipFSM::isChipping(const Update &event) +{ + return event.control_params.isChipping; +} diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h new file mode 100644 index 0000000000..c5533d3190 --- /dev/null +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h @@ -0,0 +1,125 @@ +#pragma once + +#include "software/ai/hl/stp/tactic/get_behind_ball/get_behind_ball_fsm.h" +#include "software/ai/hl/stp/tactic/tactic_base.hpp" +#include "software/geom/point.h" + +/** + * Finite State Machine class for Kicks + */ +struct KickOrChipFSM : TacticFSM +{ + class KickOrChipState; + + struct ControlParams + { + // Control params for kick + // The location where the kick will be taken from + Point kick_or_chip_origin; + // The direction the Robot will kick in + Angle kick_or_chip_direction; + + //True if chipping, false is kicking. + bool isChipping; + + // Unique for kick + // How fast the Robot will kick the ball in meters per second + double kick_speed_meters_per_second; + + // Unique for chip + // The distance the robot will chip to + double chip_distance_meters; + }; + + using Update = TacticFSM::Update; + + /** + * Constructor for KickFSM + * + * @param ai_config_ptr shared pointer to ai_config + */ + explicit KickOrChipFSM(std::shared_ptr ai_config_ptr); + + /** + * Action that updates the MovePrimitive for kicking + * + * @param event KickOrChipFSM::Update event + */ + void updateKick(const Update &event); + + + /** + * Action that updates the MovePrimitive for chippping + * + * @param event KickOrChipFSM::Update event + */ + void updateChip(const Update &event); + + /** + * Action that updates the GetBehindBallFSM + * + * @param event KickFSM::Update event + * @param processEvent processes the GetBehindBallFSM::Update + */ + void updateGetBehindBall( + const Update &event, + boost::sml::back::process processEvent); + + /** + * Guard that checks if the ball has been chicked + * + * @param event KickFSM::Update event + * + * @return if the ball has been chicked + */ + bool ballChicked(const Update &event); + + /** + * Guard that checks if the robot is aligned for the kick + * + * @param event KickFSM::Update event + * + * @return if the robot is aligned for the kick + */ + bool shouldRealignWithBall(const Update &event); + + /** + * Guard that checks if ball should be chipped + * + * @param event KickFSM::Update event + * + * @return if the ball should be chipped + */ + bool isChipping(const Update &event); + + + + + auto operator()() + { + using namespace boost::sml; + + DEFINE_SML_STATE(GetBehindBallFSM) + DEFINE_SML_STATE(KickOrChipState) + DEFINE_SML_EVENT(Update) + + DEFINE_SML_GUARD(ballChicked) + DEFINE_SML_GUARD(shouldRealignWithBall) + DEFINE_SML_GUARD(isChipping) + + DEFINE_SML_ACTION(updateKickOrChip) + DEFINE_SML_SUB_FSM_UPDATE_ACTION(updateGetBehindBall, GetBehindBallFSM) + + return make_transition_table( + // src_state + event [guard] / action = dest_state + *GetBehindBallFSM_S + Update_E / updateGetBehindBall_A, + GetBehindBallFSM_S = KickOrChipState_S, + + KickOrChipState_S + Update_E[shouldRealignWithBall_G] / updateGetBehindBall_A = + GetBehindBallFSM_S, + KickOrChipState_S + Update_E[!ballChicked_G && !isChipping] / updateKick_A = KickOrchipState_S, + KickOrChipState_S + Update_E[!ballChicked_G && isChipping] / updateChip_A = KickOrChipState_S, + KickOrChipState_S + Update_E[ballChicked_G] / SET_STOP_PRIMITIVE_ACTION = X, + X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); + } +}; diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp new file mode 100644 index 0000000000..3c39fc4e90 --- /dev/null +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp @@ -0,0 +1,35 @@ +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h" + +#include + + +KickOrChipTactic::KickOrChipTactic(std::shared_ptr ai_config_ptr) + : TacticBase( + {RobotCapability::Chip, RobotCapability::Move}, ai_config_ptr) +{ +} + + +void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_direction, + bool isChipping, double kick_speed_meters_per_second, + double chip_distance_meters); +{ + control_params.kick_or_chip_origin = kick_or_chip_origin; + control_params.kick_or_chip_direction = kick_or_chip_direction; + control_params.isChipping = isChipping; + control_params.kick_speed_meters_per_second = kick_speed_meters_per_second; + control_params.chip_distance_meters = chip_distance_meters; +} + +void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_target, + bool isChipping, double kick_speed_meters_per_second, + double chip_distance_meters); +{ + updateControlParams(kick_or_chip_origin, (kick_or_chip_target - kick_or_chip_origin).orientation(), + isChipping, kick_speed_meters_per_second, (kick_or_chip_target - kick_or_chip_origin).length()); +} + +void ChipTactic::accept(TacticVisitor &visitor) const +{ + visitor.visit(*this); +} diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h new file mode 100644 index 0000000000..568730bb25 --- /dev/null +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h @@ -0,0 +1,50 @@ +#pragma once + +#include + +#include "software/ai/hl/stp/tactic/kick/kick_fsm.h" +#include "software/ai/hl/stp/tactic/tactic_base.hpp" + +/** + * The KickOrChipTactic will move the assigned robot to the given kick origin and then + * kick or chip the ball depending on the control params passed in. + */ + +class KickOrChipTactic : public TacticBase +{ + public: + /** + * Creates a new KickOrChipTactic + * + * @param ai_config_ptr shared pointer to ai_config + */ + explicit KickOrChipTactic(std::shared_ptr ai_config_ptr); + + /** + * Updates the params for this tactic that cannot be derived from the world + * + * @param kick_or_chip_origin The location where the kick will be taken + * @param kick_or_chip_direction The direction the Robot will kick in + * @param isChipping Whether the ball should be chipped + * @param kick_speed_meters_per_second The speed of how fast the Robot + * will kick the ball in meters per second + * @param chip_distance_meters The distance of how far we want to chip the ball + */ + void updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_direction, + bool isChipping, double kick_speed_meters_per_second, + double chip_distance_meters); + /** + * Updates the control parameters for this KickTactic. + * + * @param kick_origin The location where the kick will be taken + * @param kick_or_chip_target The target location where the kick or chip will aim for + * @param isChipping Whether the ball should be chipped + * @param kick_speed_meters_per_second The speed of how fast the Robot + * will kick the ball in meters per second + * @param chip_distance_meters The distance of how far we want to chip the ball + */ + void updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_target, + bool isChipping, double kick_speed_meters_per_second); + + void accept(TacticVisitor& visitor) const override; +}; From c8eb98deefa2cfe6e7d7e5f93527312836824713 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Thu, 26 Feb 2026 11:46:22 -0800 Subject: [PATCH 02/24] update to use AutoChipOrKick Enum instead --- .../tactic/kick_or_chip/kick_or_chip_fsm.cpp | 35 +++-------------- .../tactic/kick_or_chip/kick_or_chip_fsm.h | 38 +++---------------- .../kick_or_chip/kick_or_chip_tactic.cpp | 13 ++----- .../tactic/kick_or_chip/kick_or_chip_tactic.h | 17 +++------ 4 files changed, 20 insertions(+), 83 deletions(-) diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp index b891c07044..4f7684a372 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp @@ -7,38 +7,17 @@ KickOrChipFSM::KickOrChipFSM(std::shared_ptr ai_conf { } -void KickOrChipFSM::updateKick(const Update &event) +void KickOrChipFSM::kickOrChipBall(const Update& event) { - Vector direction_to_kick = - Vector::createFromAngle(event.control_params.kick_direction); - Point kick_target = event.control_params.kick_origin - - direction_to_kick.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); - event.common.set_primitive(std::make_unique( - event.common.robot, kick_target, event.control_params.kick_direction, + event.common.robot, event.control_params.kick_origin, + event.control_params.kick_direction, TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT, TbotsProto::ObstacleAvoidanceMode::AGGRESSIVE, TbotsProto::DribblerMode::OFF, - TbotsProto::BallCollisionType::ALLOW, - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, - event.control_params.kick_speed_meters_per_second})); -} -void KickOrChipFSM::updateChip(const Update &event) -{ - Vector direction_to_chip = - Vector::createFromAngle(event.control_params.chip_direction); - Point chip_target = event.control_params.chip_origin - - direction_to_chip.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); - - event.common.set_primitive(std::make_unique( - event.common.robot, chip_target, event.control_params.chip_direction, - TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT, - TbotsProto::ObstacleAvoidanceMode::SAFE, TbotsProto::DribblerMode::OFF, - TbotsProto::BallCollisionType::ALLOW, - AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, - event.control_params.chip_distance_meters})); + TbotsProto::BallCollisionType::ALLOW, event.control_params.auto_chip_or_kick)); } -void KickOrChipFSMSM::updateGetBehindBall( +void KickOrChipFSM::updateGetBehindBall( const Update &event, boost::sml::back::process processEvent) { GetBehindBallFSM::ControlParams control_params{ @@ -70,7 +49,3 @@ bool KickOrChipFSM::shouldRealignWithBall(const Update &event) event.control_params.kick_direction); } -bool KickOrChipFSM::isChipping(const Update &event) -{ - return event.control_params.isChipping; -} diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h index c5533d3190..cdc6e443d1 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h @@ -19,16 +19,8 @@ struct KickOrChipFSM : TacticFSM // The direction the Robot will kick in Angle kick_or_chip_direction; - //True if chipping, false is kicking. - bool isChipping; - - // Unique for kick - // How fast the Robot will kick the ball in meters per second - double kick_speed_meters_per_second; - - // Unique for chip - // The distance the robot will chip to - double chip_distance_meters; + // How the robot will chip or kick the ball and its associated parameter for that mode. For example, if the mode is AUTOKICK, then the parameter will be the speed of the kick, and if the mode is AUTOCHIP, then the parameter will be the distance of the chip. + AutoChipOrKick auto_chip_or_kick; }; using Update = TacticFSM::Update; @@ -41,19 +33,11 @@ struct KickOrChipFSM : TacticFSM explicit KickOrChipFSM(std::shared_ptr ai_config_ptr); /** - * Action that updates the MovePrimitive for kicking + * Action that updates the primitive to kick or chip the ball * - * @param event KickOrChipFSM::Update event - */ - void updateKick(const Update &event); - - - /** - * Action that updates the MovePrimitive for chippping - * - * @param event KickOrChipFSM::Update event + * @param event KickFSM::Update event */ - void updateChip(const Update &event); + void kickOrChipBall(const Update &event); /** * Action that updates the GetBehindBallFSM @@ -83,14 +67,6 @@ struct KickOrChipFSM : TacticFSM */ bool shouldRealignWithBall(const Update &event); - /** - * Guard that checks if ball should be chipped - * - * @param event KickFSM::Update event - * - * @return if the ball should be chipped - */ - bool isChipping(const Update &event); @@ -105,7 +81,6 @@ struct KickOrChipFSM : TacticFSM DEFINE_SML_GUARD(ballChicked) DEFINE_SML_GUARD(shouldRealignWithBall) - DEFINE_SML_GUARD(isChipping) DEFINE_SML_ACTION(updateKickOrChip) DEFINE_SML_SUB_FSM_UPDATE_ACTION(updateGetBehindBall, GetBehindBallFSM) @@ -117,8 +92,7 @@ struct KickOrChipFSM : TacticFSM KickOrChipState_S + Update_E[shouldRealignWithBall_G] / updateGetBehindBall_A = GetBehindBallFSM_S, - KickOrChipState_S + Update_E[!ballChicked_G && !isChipping] / updateKick_A = KickOrchipState_S, - KickOrChipState_S + Update_E[!ballChicked_G && isChipping] / updateChip_A = KickOrChipState_S, + KickOrChipState_S + Update_E[!ballChicked_G] / updateKickOrChip_A = KickOrChipState_S, KickOrChipState_S + Update_E[ballChicked_G] / SET_STOP_PRIMITIVE_ACTION = X, X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); } diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp index 3c39fc4e90..7187902d92 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp @@ -11,22 +11,17 @@ KickOrChipTactic::KickOrChipTactic(std::shared_ptr a void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_direction, - bool isChipping, double kick_speed_meters_per_second, - double chip_distance_meters); + AutoChipOrKick auto_chip_or_kick); { control_params.kick_or_chip_origin = kick_or_chip_origin; control_params.kick_or_chip_direction = kick_or_chip_direction; - control_params.isChipping = isChipping; - control_params.kick_speed_meters_per_second = kick_speed_meters_per_second; - control_params.chip_distance_meters = chip_distance_meters; + control_params.auto_chip_or_kick = auto_chip_or_kick; } void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_target, - bool isChipping, double kick_speed_meters_per_second, - double chip_distance_meters); + AutoChipOrKick auto_chip_or_kick); { - updateControlParams(kick_or_chip_origin, (kick_or_chip_target - kick_or_chip_origin).orientation(), - isChipping, kick_speed_meters_per_second, (kick_or_chip_target - kick_or_chip_origin).length()); + updateControlParams(kick_or_chip_origin, kick_or_chip_target, auto_chip_or_kick); } void ChipTactic::accept(TacticVisitor &visitor) const diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h index 568730bb25..3995706e4c 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h @@ -2,7 +2,7 @@ #include -#include "software/ai/hl/stp/tactic/kick/kick_fsm.h" +#include "software/ai/hl/stp/tactic/kick_or_chip_tactic/kick_or_chip_fsm.h" #include "software/ai/hl/stp/tactic/tactic_base.hpp" /** @@ -25,26 +25,19 @@ class KickOrChipTactic : public TacticBase * * @param kick_or_chip_origin The location where the kick will be taken * @param kick_or_chip_direction The direction the Robot will kick in - * @param isChipping Whether the ball should be chipped - * @param kick_speed_meters_per_second The speed of how fast the Robot - * will kick the ball in meters per second - * @param chip_distance_meters The distance of how far we want to chip the ball + * @param auto_chip_or_kick The mode of how the robot will chip or kick the ball, and the associated parameter for that modell */ void updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_direction, - bool isChipping, double kick_speed_meters_per_second, - double chip_distance_meters); + AutoChipOrKick auto_chip_or_kick); /** * Updates the control parameters for this KickTactic. * * @param kick_origin The location where the kick will be taken * @param kick_or_chip_target The target location where the kick or chip will aim for - * @param isChipping Whether the ball should be chipped - * @param kick_speed_meters_per_second The speed of how fast the Robot - * will kick the ball in meters per second - * @param chip_distance_meters The distance of how far we want to chip the ball + * @param auto_chip_or_kick The mode of how the robot will chip or kick the ball, and the associated parameter for that modell */ void updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_target, - bool isChipping, double kick_speed_meters_per_second); + AutoChipOrKick auto_chip_or_kick); void accept(TacticVisitor& visitor) const override; }; From 05ae35db881f913169fd968a2884915fa00a0660 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Sat, 28 Feb 2026 19:30:50 -0800 Subject: [PATCH 03/24] finish migrating to shoot or chip and kickofffriendly pplay runs --- src/software/ai/hl/stp/play/BUILD | 2 +- .../ai/hl/stp/play/kickoff_friendly_play.cpp | 7 ++++--- src/software/ai/hl/stp/tactic/chip/chip_tactic.h | 2 -- src/software/ai/hl/stp/tactic/kick_or_chip/BUILD | 1 + .../hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp | 12 ++++++------ .../ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h | 4 ++-- .../stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp | 8 ++++---- .../hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h | 7 +++++-- src/software/ai/hl/stp/tactic/tactic_visitor.h | 2 ++ .../motion_constraint/motion_constraint_visitor.cpp | 2 ++ .../ai/motion_constraint/motion_constraint_visitor.h | 1 + 11 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/software/ai/hl/stp/play/BUILD b/src/software/ai/hl/stp/play/BUILD index 678a44e215..7bd4917474 100644 --- a/src/software/ai/hl/stp/play/BUILD +++ b/src/software/ai/hl/stp/play/BUILD @@ -32,7 +32,7 @@ cc_library( ":play", "//shared:constants", "//software/ai/evaluation:enemy_threat", - "//software/ai/hl/stp/tactic/chip:chip_tactic", + "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/logger", "//software/util/generic_factory", diff --git a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp index 1898be7716..0253746948 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp +++ b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp @@ -2,7 +2,7 @@ #include "shared/constants.h" #include "software/ai/evaluation/enemy_threat.h" -#include "software/ai/hl/stp/tactic/chip/chip_tactic.h" +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/util/generic_factory/generic_factory.h" @@ -116,10 +116,11 @@ void KickoffFriendlyPlay::getNextTactics(TacticCoroutine::push_type &yield, // TODO (#2612): This needs to be adjusted post field testing, ball needs to land // exactly in the middle of the enemy field + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, 0}; kickoff_chip_tactic->updateControlParams( world_ptr->ball().position(), - world_ptr->field().centerPoint() + - Vector(world_ptr->field().xLength() / 6, 0)); + world_ptr->field().centerPoint() + Vector(world_ptr->field().xLength() / 6, 0), + auto_chip_or_kick); result[0].emplace_back(kickoff_chip_tactic); // the robot at position 0 will be closest to the ball, so positions starting from diff --git a/src/software/ai/hl/stp/tactic/chip/chip_tactic.h b/src/software/ai/hl/stp/tactic/chip/chip_tactic.h index c0a4ca1ea1..6d0178bde0 100644 --- a/src/software/ai/hl/stp/tactic/chip/chip_tactic.h +++ b/src/software/ai/hl/stp/tactic/chip/chip_tactic.h @@ -42,5 +42,3 @@ class ChipTactic : public TacticBase void accept(TacticVisitor& visitor) const override; }; -// Creates a new tactic called KickoffChipTactic that is a duplicate of ChipTactic -COPY_TACTIC(KickoffChipTactic, ChipTactic) diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD index fd3f4af7e0..d5bd6a05d8 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD @@ -16,6 +16,7 @@ cc_library( "//software/ai/hl/stp/tactic", "//software/ai/hl/stp/tactic/dribble:dribble_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", + "//software/ai/hl/stp/tactic/get_behind_ball:get_behind_ball_tactic", "//software/geom/algorithms", "//software/logger", ], diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp index 4f7684a372..7719eb23c7 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp @@ -10,8 +10,8 @@ KickOrChipFSM::KickOrChipFSM(std::shared_ptr ai_conf void KickOrChipFSM::kickOrChipBall(const Update& event) { event.common.set_primitive(std::make_unique( - event.common.robot, event.control_params.kick_origin, - event.control_params.kick_direction, + event.common.robot, event.control_params.kick_or_chip_origin, + event.control_params.kick_or_chip_direction, TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT, TbotsProto::ObstacleAvoidanceMode::AGGRESSIVE, TbotsProto::DribblerMode::OFF, TbotsProto::BallCollisionType::ALLOW, event.control_params.auto_chip_or_kick)); @@ -31,7 +31,7 @@ void KickOrChipFSM::updateGetBehindBall( bool KickOrChipFSM::ballChicked(const Update &event) { return event.common.world_ptr->ball().hasBallBeenKicked( - event.control_params.kick_direction); + event.control_params.kick_or_chip_direction); } bool KickOrChipFSM::shouldRealignWithBall(const Update &event) @@ -39,13 +39,13 @@ bool KickOrChipFSM::shouldRealignWithBall(const Update &event) const Robot &robot = event.common.robot; // First check to see if it's too late to realign with the ball - if (robot.isNearDribbler(event.control_params.kick_origin, 0.05)) + if (robot.isNearDribbler(event.control_params.kick_or_chip_origin, 0.05)) { return false; } // Check if the robot is already aligned to kick the ball - return !isRobotReadyToChick(robot, event.control_params.kick_origin, - event.control_params.kick_direction); + return !isRobotReadyToChick(robot, event.control_params.kick_or_chip_origin, + event.control_params.kick_or_chip_direction); } diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h index cdc6e443d1..64a1fffd1b 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h @@ -82,7 +82,7 @@ struct KickOrChipFSM : TacticFSM DEFINE_SML_GUARD(ballChicked) DEFINE_SML_GUARD(shouldRealignWithBall) - DEFINE_SML_ACTION(updateKickOrChip) + DEFINE_SML_ACTION(kickOrChipBall) DEFINE_SML_SUB_FSM_UPDATE_ACTION(updateGetBehindBall, GetBehindBallFSM) return make_transition_table( @@ -92,7 +92,7 @@ struct KickOrChipFSM : TacticFSM KickOrChipState_S + Update_E[shouldRealignWithBall_G] / updateGetBehindBall_A = GetBehindBallFSM_S, - KickOrChipState_S + Update_E[!ballChicked_G] / updateKickOrChip_A = KickOrChipState_S, + KickOrChipState_S + Update_E[!ballChicked_G] / kickOrChipBall_A = KickOrChipState_S, KickOrChipState_S + Update_E[ballChicked_G] / SET_STOP_PRIMITIVE_ACTION = X, X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); } diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp index 7187902d92..6e41bda52f 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp @@ -11,20 +11,20 @@ KickOrChipTactic::KickOrChipTactic(std::shared_ptr a void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_direction, - AutoChipOrKick auto_chip_or_kick); + AutoChipOrKick auto_chip_or_kick) { control_params.kick_or_chip_origin = kick_or_chip_origin; control_params.kick_or_chip_direction = kick_or_chip_direction; control_params.auto_chip_or_kick = auto_chip_or_kick; } -void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_target, - AutoChipOrKick auto_chip_or_kick); +void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Point& kick_or_chip_target, + AutoChipOrKick auto_chip_or_kick) { updateControlParams(kick_or_chip_origin, kick_or_chip_target, auto_chip_or_kick); } -void ChipTactic::accept(TacticVisitor &visitor) const +void KickOrChipTactic::accept(TacticVisitor &visitor) const { visitor.visit(*this); } diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h index 3995706e4c..02bf059d1e 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h @@ -2,7 +2,7 @@ #include -#include "software/ai/hl/stp/tactic/kick_or_chip_tactic/kick_or_chip_fsm.h" +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h" #include "software/ai/hl/stp/tactic/tactic_base.hpp" /** @@ -36,8 +36,11 @@ class KickOrChipTactic : public TacticBase * @param kick_or_chip_target The target location where the kick or chip will aim for * @param auto_chip_or_kick The mode of how the robot will chip or kick the ball, and the associated parameter for that modell */ - void updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_target, + void updateControlParams(const Point& kick_or_chip_origin, const Point& kickd_or_chip_target, AutoChipOrKick auto_chip_or_kick); void accept(TacticVisitor& visitor) const override; }; + +// Creates a new tactic called KickoffChipTactic that is a duplicate of ChipTactic +COPY_TACTIC(KickoffChipTactic, KickOrChipTactic) diff --git a/src/software/ai/hl/stp/tactic/tactic_visitor.h b/src/software/ai/hl/stp/tactic/tactic_visitor.h index ea5c6e5ab0..176ff4eadf 100644 --- a/src/software/ai/hl/stp/tactic/tactic_visitor.h +++ b/src/software/ai/hl/stp/tactic/tactic_visitor.h @@ -31,6 +31,7 @@ class PlaceBallTactic; class PlaceBallMoveTactic; class WallKickoffTactic; class AvoidInterferenceTactic; +class KickOrChipTactic; /** * Refer to the docs about why we use the Visitor Design Pattern @@ -73,4 +74,5 @@ class TacticVisitor virtual void visit(const PlaceBallMoveTactic &tactic) = 0; virtual void visit(const WallKickoffTactic &tactic) = 0; virtual void visit(const AvoidInterferenceTactic &tactic) = 0; + virtual void visit(const KickOrChipTactic &tactic) = 0; }; diff --git a/src/software/ai/motion_constraint/motion_constraint_visitor.cpp b/src/software/ai/motion_constraint/motion_constraint_visitor.cpp index cbedffc25c..8636c89fee 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.cpp +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.cpp @@ -107,6 +107,8 @@ void MotionConstraintVisitor::visit(const AvoidInterferenceTactic &tactic) current_motion_constraints.clear(); } +void MotionConstraintVisitor::visit(const KickOrChipTactic &tactic) {} + void MotionConstraintVisitor::visit(const PassDefenderTactic &tactic) {} std::set diff --git a/src/software/ai/motion_constraint/motion_constraint_visitor.h b/src/software/ai/motion_constraint/motion_constraint_visitor.h index af6053cf40..e3d73351db 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.h +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.h @@ -45,6 +45,7 @@ class MotionConstraintVisitor : public TacticVisitor void visit(const WallKickoffTactic &tactic) override; void visit(const AvoidInterferenceTactic &tactic) override; void visit(const PassDefenderTactic &tactic) override; + void visit(const KickOrChipTactic &Tactic) override; /** * Gets the motion constraints updated with the requirements of the tactics From d49c262c91651666bbf709b43b2e55714e1272d8 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Sat, 28 Feb 2026 20:59:27 -0800 Subject: [PATCH 04/24] finish migration to freekick play and penalty tactic --- src/software/ai/hl/stp/play/free_kick/BUILD | 2 +- .../stp/play/free_kick/free_kick_play_fsm.cpp | 25 ++++++++++--------- .../stp/play/free_kick/free_kick_play_fsm.h | 8 +++--- src/software/ai/hl/stp/tactic/attacker/BUILD | 1 - .../ai/hl/stp/tactic/attacker/attacker_fsm.h | 1 - src/software/ai/hl/stp/tactic/goalie/BUILD | 1 - .../ai/hl/stp/tactic/goalie/goalie_fsm.h | 1 - .../tactic/kick_or_chip/kick_or_chip_fsm.cpp | 8 +++++- .../ai/hl/stp/tactic/penalty_kick/BUILD | 2 +- .../tactic/penalty_kick/penalty_kick_fsm.cpp | 13 +++++----- .../tactic/penalty_kick/penalty_kick_fsm.h | 12 ++++----- .../penalty_kick/penalty_kick_tactic.cpp | 2 +- .../tactic/penalty_kick/penalty_kick_tactic.h | 2 +- src/software/ai/hl/stp/tactic/receiver/BUILD | 1 - .../ai/hl/stp/tactic/receiver/receiver_fsm.h | 1 - 15 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/software/ai/hl/stp/play/free_kick/BUILD b/src/software/ai/hl/stp/play/free_kick/BUILD index df9375a693..83b9954490 100644 --- a/src/software/ai/hl/stp/play/free_kick/BUILD +++ b/src/software/ai/hl/stp/play/free_kick/BUILD @@ -19,7 +19,7 @@ cc_library( "//software/ai/evaluation:possession", "//software/ai/hl/stp/play", "//software/ai/hl/stp/play/defense:defense_play", - "//software/ai/hl/stp/tactic/chip:chip_tactic", + "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/crease_defender:crease_defender_tactic", "//software/ai/hl/stp/tactic/goalie:goalie_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", diff --git a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp index 83aadfa38f..5c3cb8c9f6 100644 --- a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp @@ -4,9 +4,8 @@ FreeKickPlayFSM::FreeKickPlayFSM( std::shared_ptr ai_config_ptr) : PlayFSM(ai_config_ptr), align_to_ball_tactic(std::make_shared(ai_config_ptr)), - shoot_tactic(std::make_shared(ai_config_ptr)), - chip_tactic(std::make_shared(ai_config_ptr)), - passer_tactic(std::make_shared(ai_config_ptr)), + kick_or_chip_tactic(std::make_shared(ai_config_ptr)), + passer_tactic(std::make_shared(ai_config_ptr)), receiver_tactic(std::make_shared(ai_config_ptr)), receiver_positioning_tactics({std::make_shared(ai_config_ptr), std::make_shared(ai_config_ptr)}), @@ -147,11 +146,12 @@ void FreeKickPlayFSM::shootBall(const Update &event) PriorityTacticVector tactics_to_run = {{}}; Point ball_pos = event.common.world_ptr->ball().position(); + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, BALL_MAX_SPEED_METERS_PER_SECOND}; - shoot_tactic->updateControlParams( + kick_or_chip_tactic->updateControlParams( ball_pos, (shot->getPointToShootAt() - ball_pos).orientation(), - BALL_MAX_SPEED_METERS_PER_SECOND); - tactics_to_run[0].emplace_back(shoot_tactic); + auto_chip_or_kick); + tactics_to_run[0].emplace_back(kick_or_chip_tactic); event.common.set_tactics(tactics_to_run); } @@ -200,9 +200,10 @@ void FreeKickPlayFSM::chipBall(const Update &event) } } - chip_tactic->updateControlParams(event.common.world_ptr->ball().position(), - chip_target); - tactics_to_run[0].emplace_back(chip_tactic); + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, + (chip_target - ball_pos).length()}; + kick_or_chip_tactic->updateControlParams(ball_pos, chip_target, auto_chip_or_kick); + tactics_to_run[0].emplace_back(kick_or_chip_tactic); event.common.set_tactics(tactics_to_run); } @@ -289,7 +290,7 @@ void FreeKickPlayFSM::passBall(const Update &event) Pass pass = best_pass_and_score_so_far.pass; passer_tactic->updateControlParams(pass.passerPoint(), pass.passerOrientation(), - pass.speed()); + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, pass.speed()}); receiver_tactic->updateControlParams(pass); tactics_to_run[0].emplace_back(passer_tactic); tactics_to_run[0].emplace_back(receiver_tactic); @@ -304,7 +305,7 @@ void FreeKickPlayFSM::passBall(const Update &event) bool FreeKickPlayFSM::shotDone(const Update &event) { - return shoot_tactic->done(); + return kick_or_chip_tactic->done(); } bool FreeKickPlayFSM::passDone(const FreeKickPlayFSM::Update &event) @@ -314,5 +315,5 @@ bool FreeKickPlayFSM::passDone(const FreeKickPlayFSM::Update &event) bool FreeKickPlayFSM::chipDone(const FreeKickPlayFSM::Update &event) { - return chip_tactic->done(); + return kick_or_chip_tactic->done(); } diff --git a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.h b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.h index 31f9a8c4fc..5519746e4e 100644 --- a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.h +++ b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.h @@ -5,9 +5,8 @@ #include "software/ai/evaluation/calc_best_shot.h" #include "software/ai/hl/stp/play/defense/defense_play.h" #include "software/ai/hl/stp/play/play.h" -#include "software/ai/hl/stp/tactic/chip/chip_tactic.h" #include "software/ai/hl/stp/tactic/crease_defender/crease_defender_tactic.h" -#include "software/ai/hl/stp/tactic/kick/kick_tactic.h" +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/receiver/receiver_tactic.h" #include "software/ai/passing/eighteen_zone_pitch_division.h" @@ -266,9 +265,8 @@ struct FreeKickPlayFSM : PlayFSM private: std::optional shot; std::shared_ptr align_to_ball_tactic; - std::shared_ptr shoot_tactic; - std::shared_ptr chip_tactic; - std::shared_ptr passer_tactic; + std::shared_ptr kick_or_chip_tactic; + std::shared_ptr passer_tactic; std::shared_ptr receiver_tactic; std::vector> receiver_positioning_tactics; std::shared_ptr defense_play; diff --git a/src/software/ai/hl/stp/tactic/attacker/BUILD b/src/software/ai/hl/stp/tactic/attacker/BUILD index 6b1300c8cd..e9d5bd8532 100644 --- a/src/software/ai/hl/stp/tactic/attacker/BUILD +++ b/src/software/ai/hl/stp/tactic/attacker/BUILD @@ -14,7 +14,6 @@ cc_library( "//shared:constants", "//software/ai/evaluation:keep_away", "//software/ai/hl/stp/tactic", - "//software/ai/hl/stp/tactic/chip:chip_tactic", "//software/ai/hl/stp/tactic/keep_away:keep_away_tactic", "//software/ai/hl/stp/tactic/pivot_kick:pivot_kick_tactic", "//software/ai/passing:pass", diff --git a/src/software/ai/hl/stp/tactic/attacker/attacker_fsm.h b/src/software/ai/hl/stp/tactic/attacker/attacker_fsm.h index 5330131360..a0246fbb99 100644 --- a/src/software/ai/hl/stp/tactic/attacker/attacker_fsm.h +++ b/src/software/ai/hl/stp/tactic/attacker/attacker_fsm.h @@ -3,7 +3,6 @@ #include "proto/parameters.pb.h" #include "software/ai/evaluation/keep_away.h" #include "software/ai/evaluation/shot.h" -#include "software/ai/hl/stp/tactic/chip/chip_fsm.h" #include "software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h" #include "software/ai/hl/stp/tactic/pivot_kick/pivot_kick_fsm.h" #include "software/ai/hl/stp/tactic/tactic_base.hpp" diff --git a/src/software/ai/hl/stp/tactic/goalie/BUILD b/src/software/ai/hl/stp/tactic/goalie/BUILD index abdb4d7636..4c026b9be7 100644 --- a/src/software/ai/hl/stp/tactic/goalie/BUILD +++ b/src/software/ai/hl/stp/tactic/goalie/BUILD @@ -17,7 +17,6 @@ cc_library( "//software/ai/evaluation:enemy_threat", "//software/ai/evaluation:find_open_areas", "//software/ai/hl/stp/tactic", - "//software/ai/hl/stp/tactic/chip:chip_tactic", "//software/ai/hl/stp/tactic/dribble:dribble_tactic", "//software/ai/hl/stp/tactic/pivot_kick:pivot_kick_tactic", "//software/geom:line", diff --git a/src/software/ai/hl/stp/tactic/goalie/goalie_fsm.h b/src/software/ai/hl/stp/tactic/goalie/goalie_fsm.h index 961a73fcc9..2acd369a8e 100644 --- a/src/software/ai/hl/stp/tactic/goalie/goalie_fsm.h +++ b/src/software/ai/hl/stp/tactic/goalie/goalie_fsm.h @@ -3,7 +3,6 @@ #include "proto/parameters.pb.h" #include "shared/constants.h" #include "software/ai/evaluation/calc_best_shot.h" -#include "software/ai/hl/stp/tactic/chip/chip_fsm.h" #include "software/ai/hl/stp/tactic/pivot_kick/pivot_kick_fsm.h" #include "software/ai/hl/stp/tactic/tactic_base.hpp" #include "software/geom/algorithms/calculate_block_cone.h" diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp index 7719eb23c7..a1b5252e1b 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp @@ -1,5 +1,6 @@ #include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h" +#include "shared/constants.h" #include "software/ai/hl/stp/tactic/move_primitive.h" KickOrChipFSM::KickOrChipFSM(std::shared_ptr ai_config_ptr) @@ -9,8 +10,13 @@ KickOrChipFSM::KickOrChipFSM(std::shared_ptr ai_conf void KickOrChipFSM::kickOrChipBall(const Update& event) { + Vector direction = Vector::createFromAngle(event.control_params.kick_or_chip_direction); + Point kick_or_chip_target = + event.control_params.kick_or_chip_origin - + direction.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); + event.common.set_primitive(std::make_unique( - event.common.robot, event.control_params.kick_or_chip_origin, + event.common.robot, kick_or_chip_target, event.control_params.kick_or_chip_direction, TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT, TbotsProto::ObstacleAvoidanceMode::AGGRESSIVE, TbotsProto::DribblerMode::OFF, diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/BUILD b/src/software/ai/hl/stp/tactic/penalty_kick/BUILD index 9871c1e0f5..a1448a88d3 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/BUILD +++ b/src/software/ai/hl/stp/tactic/penalty_kick/BUILD @@ -16,7 +16,7 @@ cc_library( "//software/ai/hl/stp/tactic", "//software/ai/hl/stp/tactic/dribble:dribble_tactic", "//software/ai/hl/stp/tactic/get_behind_ball:get_behind_ball_tactic", - "//software/ai/hl/stp/tactic/kick:kick_tactic", + "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/geom/algorithms", "//software/logger", diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp index fce3e6ec20..d969584ff7 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp @@ -122,13 +122,14 @@ const Point PenaltyKickFSM::evaluateNextShotPosition(std::optional enemy_ } void PenaltyKickFSM::shoot(const Update &event, - boost::sml::back::process processEvent) + boost::sml::back::process processEvent) { - KickFSM::ControlParams control_params{ - .kick_origin = event.common.world_ptr->ball().position(), - .kick_direction = shot_angle, - .kick_speed_meters_per_second = PENALTY_KICK_SHOT_SPEED}; - processEvent(KickFSM::Update(control_params, event.common)); + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, PENALTY_KICK_SHOT_SPEED}; + KickOrChipFSM::ControlParams control_params{ + .kick_or_chip_origin = event.common.world_ptr->ball().position(), + .kick_or_chip_direction = shot_angle, + .auto_chip_or_kick = auto_chip_or_kick}; + processEvent(KickOrChipFSM::Update(control_params, event.common)); } void PenaltyKickFSM::updateApproachKeeper( diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h index bb051b4063..62f988b63e 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h @@ -2,7 +2,7 @@ #include "software/ai/hl/stp/tactic/dribble/dribble_fsm.h" #include "software/ai/hl/stp/tactic/get_behind_ball/get_behind_ball_fsm.h" -#include "software/ai/hl/stp/tactic/kick/kick_fsm.h" +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h" #include "software/ai/hl/stp/tactic/move/move_fsm.h" #include "software/ai/hl/stp/tactic/tactic_base.hpp" #include "software/geom/algorithms/closest_point.h" @@ -59,7 +59,7 @@ struct PenaltyKickFSM : TacticFSM * @param processEvent processes the KickFSM::Update */ void shoot(const Update &event, - boost::sml::back::process processEvent); + boost::sml::back::process processEvent); /** * Action that updates the shooter's approach to the opposition net. @@ -105,23 +105,23 @@ struct PenaltyKickFSM : TacticFSM using namespace boost::sml; DEFINE_SML_STATE(DribbleFSM) - DEFINE_SML_STATE(KickFSM) + DEFINE_SML_STATE(KickOrChipFSM) DEFINE_SML_EVENT(Update) DEFINE_SML_GUARD(takePenaltyShot) DEFINE_SML_GUARD(timeOutApproach) - DEFINE_SML_SUB_FSM_UPDATE_ACTION(shoot, KickFSM) + DEFINE_SML_SUB_FSM_UPDATE_ACTION(shoot, KickOrChipFSM) DEFINE_SML_SUB_FSM_UPDATE_ACTION(updateApproachKeeper, DribbleFSM) DEFINE_SML_SUB_FSM_UPDATE_ACTION(adjustOrientationForShot, DribbleFSM) return make_transition_table( // src_state + event [guard] / action = dest state *DribbleFSM_S + Update_E[!takePenaltyShot_G] / updateApproachKeeper_A, - DribbleFSM_S + Update_E[timeOutApproach_G] / shoot_A = KickFSM_S, + DribbleFSM_S + Update_E[timeOutApproach_G] / shoot_A = KickOrChipFSM_S, DribbleFSM_S + Update_E / adjustOrientationForShot_A, - DribbleFSM_S = KickFSM_S, KickFSM_S + Update_E / shoot_A, KickFSM_S = X, + DribbleFSM_S = KickOrChipFSM_S, KickOrChipFSM_S + Update_E / shoot_A, KickOrChipFSM_S = X, X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); }; diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.cpp b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.cpp index 28a3313aef..cc959e8c48 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.cpp @@ -2,7 +2,7 @@ PenaltyKickTactic::PenaltyKickTactic( std::shared_ptr ai_config_ptr) - : TacticBase( + : TacticBase( {RobotCapability::Move, RobotCapability::Dribble, RobotCapability::Kick}, ai_config_ptr) { diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.h b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.h index 7e8b01596b..f066b6d9f9 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.h +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.h @@ -12,7 +12,7 @@ */ class PenaltyKickTactic - : public TacticBase + : public TacticBase { public: /** diff --git a/src/software/ai/hl/stp/tactic/receiver/BUILD b/src/software/ai/hl/stp/tactic/receiver/BUILD index 8548bfe80e..7296fada87 100644 --- a/src/software/ai/hl/stp/tactic/receiver/BUILD +++ b/src/software/ai/hl/stp/tactic/receiver/BUILD @@ -15,7 +15,6 @@ cc_library( "//software/ai/evaluation:calc_best_shot", "//software/ai/hl/stp/tactic", "//software/ai/hl/stp/tactic/dribble:dribble_tactic", - "//software/ai/hl/stp/tactic/kick:kick_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/ai/passing:pass", "//software/logger", diff --git a/src/software/ai/hl/stp/tactic/receiver/receiver_fsm.h b/src/software/ai/hl/stp/tactic/receiver/receiver_fsm.h index fcd30d8fc3..0c80d6c518 100644 --- a/src/software/ai/hl/stp/tactic/receiver/receiver_fsm.h +++ b/src/software/ai/hl/stp/tactic/receiver/receiver_fsm.h @@ -3,7 +3,6 @@ #include "shared/constants.h" #include "software/ai/evaluation/calc_best_shot.h" #include "software/ai/hl/stp/tactic/dribble/dribble_fsm.h" -#include "software/ai/hl/stp/tactic/kick/kick_fsm.h" #include "software/ai/hl/stp/tactic/move/move_fsm.h" #include "software/ai/hl/stp/tactic/tactic_base.hpp" #include "software/ai/passing/pass.h" From f1e41a5dd63c23fabb6904cc8a13d3230fd715ec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sun, 1 Mar 2026 05:16:13 +0000 Subject: [PATCH 05/24] [pre-commit.ci lite] apply automatic fixes --- docs/fsm-diagrams.md | 25 ++++++++++++++++--- src/software/ai/hl/stp/play/free_kick/BUILD | 2 +- .../stp/play/free_kick/free_kick_play_fsm.cpp | 10 +++++--- .../ai/hl/stp/play/kickoff_friendly_play.cpp | 3 ++- src/software/ai/hl/stp/tactic/BUILD | 2 +- .../ai/hl/stp/tactic/chip/chip_tactic.h | 1 - .../ai/hl/stp/tactic/kick_or_chip/BUILD | 3 +-- .../tactic/kick_or_chip/kick_or_chip_fsm.cpp | 11 ++++---- .../tactic/kick_or_chip/kick_or_chip_fsm.h | 18 +++++++------ .../kick_or_chip/kick_or_chip_tactic.cpp | 21 +++++++++------- .../tactic/kick_or_chip/kick_or_chip_tactic.h | 16 +++++++----- .../tactic/penalty_kick/penalty_kick_fsm.cpp | 3 ++- .../tactic/penalty_kick/penalty_kick_fsm.h | 4 +-- .../ai/hl/stp/tactic/tactic_visitor.h | 2 +- .../motion_constraint_visitor.h | 2 +- 15 files changed, 75 insertions(+), 48 deletions(-) diff --git a/docs/fsm-diagrams.md b/docs/fsm-diagrams.md index 8059b8e10d..eeeb2ea148 100644 --- a/docs/fsm-diagrams.md +++ b/docs/fsm-diagrams.md @@ -392,6 +392,23 @@ Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION GetBehindBallFSM +GetBehindBallFSM --> GetBehindBallFSM : updateGetBehindBall +GetBehindBallFSM --> KickOrChipState +KickOrChipState --> GetBehindBallFSM : [shouldRealignWithBall]\nupdateGetBehindBall +KickOrChipState --> KickOrChipState : [!ballChicked]\nkickOrChipBall +KickOrChipState --> Terminate:::terminate : [ballChicked]\nSET_STOP_PRIMITIVE_ACTION +Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION + +``` + ## [MoveFSM](/src/software/ai/hl/stp/tactic/move/move_fsm.h) ```mermaid @@ -435,11 +452,11 @@ classDef terminate fill:white,color:black,font-weight:bold direction LR [*] --> DribbleFSM DribbleFSM --> DribbleFSM : [!takePenaltyShot]\nupdateApproachKeeper -DribbleFSM --> KickFSM : [timeOutApproach]\nshoot +DribbleFSM --> KickOrChipFSM : [timeOutApproach]\nshoot DribbleFSM --> DribbleFSM : adjustOrientationForShot -DribbleFSM --> KickFSM -KickFSM --> KickFSM : shoot -KickFSM --> Terminate:::terminate +DribbleFSM --> KickOrChipFSM +KickOrChipFSM --> KickOrChipFSM : shoot +KickOrChipFSM --> Terminate:::terminate Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION ``` diff --git a/src/software/ai/hl/stp/play/free_kick/BUILD b/src/software/ai/hl/stp/play/free_kick/BUILD index 83b9954490..b4f864b47e 100644 --- a/src/software/ai/hl/stp/play/free_kick/BUILD +++ b/src/software/ai/hl/stp/play/free_kick/BUILD @@ -19,9 +19,9 @@ cc_library( "//software/ai/evaluation:possession", "//software/ai/hl/stp/play", "//software/ai/hl/stp/play/defense:defense_play", - "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/crease_defender:crease_defender_tactic", "//software/ai/hl/stp/tactic/goalie:goalie_tactic", + "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/ai/hl/stp/tactic/receiver:receiver_tactic", "//software/ai/passing:eighteen_zone_pitch_division", diff --git a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp index 5c3cb8c9f6..38f3af2349 100644 --- a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp @@ -145,8 +145,9 @@ void FreeKickPlayFSM::shootBall(const Update &event) LOG(INFO) << "Shooting ball."; PriorityTacticVector tactics_to_run = {{}}; - Point ball_pos = event.common.world_ptr->ball().position(); - AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, BALL_MAX_SPEED_METERS_PER_SECOND}; + Point ball_pos = event.common.world_ptr->ball().position(); + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, + BALL_MAX_SPEED_METERS_PER_SECOND}; kick_or_chip_tactic->updateControlParams( ball_pos, (shot->getPointToShootAt() - ball_pos).orientation(), @@ -289,8 +290,9 @@ void FreeKickPlayFSM::passBall(const Update &event) Pass pass = best_pass_and_score_so_far.pass; - passer_tactic->updateControlParams(pass.passerPoint(), pass.passerOrientation(), - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, pass.speed()}); + passer_tactic->updateControlParams( + pass.passerPoint(), pass.passerOrientation(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, pass.speed()}); receiver_tactic->updateControlParams(pass); tactics_to_run[0].emplace_back(passer_tactic); tactics_to_run[0].emplace_back(receiver_tactic); diff --git a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp index 0253746948..7bceac31b8 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp +++ b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp @@ -119,7 +119,8 @@ void KickoffFriendlyPlay::getNextTactics(TacticCoroutine::push_type &yield, AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, 0}; kickoff_chip_tactic->updateControlParams( world_ptr->ball().position(), - world_ptr->field().centerPoint() + Vector(world_ptr->field().xLength() / 6, 0), + world_ptr->field().centerPoint() + + Vector(world_ptr->field().xLength() / 6, 0), auto_chip_or_kick); result[0].emplace_back(kickoff_chip_tactic); diff --git a/src/software/ai/hl/stp/tactic/BUILD b/src/software/ai/hl/stp/tactic/BUILD index 20ff44969c..8c0c1a39c1 100644 --- a/src/software/ai/hl/stp/tactic/BUILD +++ b/src/software/ai/hl/stp/tactic/BUILD @@ -17,13 +17,13 @@ cc_library( ":tactic", "//software/ai/hl/stp/tactic/attacker:attacker_tactic", "//software/ai/hl/stp/tactic/chip:chip_tactic", - "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/crease_defender:crease_defender_tactic", "//software/ai/hl/stp/tactic/dribble:dribble_tactic", "//software/ai/hl/stp/tactic/get_behind_ball:get_behind_ball_tactic", "//software/ai/hl/stp/tactic/goalie:goalie_tactic", "//software/ai/hl/stp/tactic/halt:halt_tactic", "//software/ai/hl/stp/tactic/kick:kick_tactic", + "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/ai/hl/stp/tactic/pass_defender:pass_defender_tactic", "//software/ai/hl/stp/tactic/penalty_kick:penalty_kick_tactic", diff --git a/src/software/ai/hl/stp/tactic/chip/chip_tactic.h b/src/software/ai/hl/stp/tactic/chip/chip_tactic.h index 6d0178bde0..f3e10e992e 100644 --- a/src/software/ai/hl/stp/tactic/chip/chip_tactic.h +++ b/src/software/ai/hl/stp/tactic/chip/chip_tactic.h @@ -41,4 +41,3 @@ class ChipTactic : public TacticBase void accept(TacticVisitor& visitor) const override; }; - diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD index d5bd6a05d8..66ae71ed27 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD @@ -15,10 +15,9 @@ cc_library( "//software/ai/evaluation:enemy_threat", "//software/ai/hl/stp/tactic", "//software/ai/hl/stp/tactic/dribble:dribble_tactic", - "//software/ai/hl/stp/tactic/move:move_tactic", "//software/ai/hl/stp/tactic/get_behind_ball:get_behind_ball_tactic", + "//software/ai/hl/stp/tactic/move:move_tactic", "//software/geom/algorithms", "//software/logger", ], ) - diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp index a1b5252e1b..c008a08a3a 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp @@ -8,12 +8,12 @@ KickOrChipFSM::KickOrChipFSM(std::shared_ptr ai_conf { } -void KickOrChipFSM::kickOrChipBall(const Update& event) +void KickOrChipFSM::kickOrChipBall(const Update &event) { - Vector direction = Vector::createFromAngle(event.control_params.kick_or_chip_direction); - Point kick_or_chip_target = - event.control_params.kick_or_chip_origin - - direction.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); + Vector direction = + Vector::createFromAngle(event.control_params.kick_or_chip_direction); + Point kick_or_chip_target = event.control_params.kick_or_chip_origin - + direction.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); event.common.set_primitive(std::make_unique( event.common.robot, kick_or_chip_target, @@ -54,4 +54,3 @@ bool KickOrChipFSM::shouldRealignWithBall(const Update &event) return !isRobotReadyToChick(robot, event.control_params.kick_or_chip_origin, event.control_params.kick_or_chip_direction); } - diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h index 64a1fffd1b..88f25d2432 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h @@ -13,13 +13,16 @@ struct KickOrChipFSM : TacticFSM struct ControlParams { - // Control params for kick + // Control params for kick // The location where the kick will be taken from Point kick_or_chip_origin; // The direction the Robot will kick in Angle kick_or_chip_direction; - // How the robot will chip or kick the ball and its associated parameter for that mode. For example, if the mode is AUTOKICK, then the parameter will be the speed of the kick, and if the mode is AUTOCHIP, then the parameter will be the distance of the chip. + // How the robot will chip or kick the ball and its associated parameter for that + // mode. For example, if the mode is AUTOKICK, then the parameter will be the + // speed of the kick, and if the mode is AUTOCHIP, then the parameter will be the + // distance of the chip. AutoChipOrKick auto_chip_or_kick; }; @@ -69,8 +72,6 @@ struct KickOrChipFSM : TacticFSM - - auto operator()() { using namespace boost::sml; @@ -90,10 +91,11 @@ struct KickOrChipFSM : TacticFSM *GetBehindBallFSM_S + Update_E / updateGetBehindBall_A, GetBehindBallFSM_S = KickOrChipState_S, - KickOrChipState_S + Update_E[shouldRealignWithBall_G] / updateGetBehindBall_A = - GetBehindBallFSM_S, - KickOrChipState_S + Update_E[!ballChicked_G] / kickOrChipBall_A = KickOrChipState_S, + KickOrChipState_S + Update_E[shouldRealignWithBall_G] / + updateGetBehindBall_A = GetBehindBallFSM_S, + KickOrChipState_S + Update_E[!ballChicked_G] / kickOrChipBall_A = + KickOrChipState_S, KickOrChipState_S + Update_E[ballChicked_G] / SET_STOP_PRIMITIVE_ACTION = X, - X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); + X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); } }; diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp index 6e41bda52f..83bc54c014 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp @@ -3,28 +3,31 @@ #include -KickOrChipTactic::KickOrChipTactic(std::shared_ptr ai_config_ptr) +KickOrChipTactic::KickOrChipTactic( + std::shared_ptr ai_config_ptr) : TacticBase( {RobotCapability::Chip, RobotCapability::Move}, ai_config_ptr) { } -void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_direction, - AutoChipOrKick auto_chip_or_kick) +void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, + const Angle& kick_or_chip_direction, + AutoChipOrKick auto_chip_or_kick) { - control_params.kick_or_chip_origin = kick_or_chip_origin; - control_params.kick_or_chip_direction = kick_or_chip_direction; - control_params.auto_chip_or_kick = auto_chip_or_kick; + control_params.kick_or_chip_origin = kick_or_chip_origin; + control_params.kick_or_chip_direction = kick_or_chip_direction; + control_params.auto_chip_or_kick = auto_chip_or_kick; } -void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Point& kick_or_chip_target, - AutoChipOrKick auto_chip_or_kick) +void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, + const Point& kick_or_chip_target, + AutoChipOrKick auto_chip_or_kick) { updateControlParams(kick_or_chip_origin, kick_or_chip_target, auto_chip_or_kick); } -void KickOrChipTactic::accept(TacticVisitor &visitor) const +void KickOrChipTactic::accept(TacticVisitor& visitor) const { visitor.visit(*this); } diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h index 02bf059d1e..0ffc644ac0 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h @@ -25,19 +25,23 @@ class KickOrChipTactic : public TacticBase * * @param kick_or_chip_origin The location where the kick will be taken * @param kick_or_chip_direction The direction the Robot will kick in - * @param auto_chip_or_kick The mode of how the robot will chip or kick the ball, and the associated parameter for that modell + * @param auto_chip_or_kick The mode of how the robot will chip or kick the ball, and + * the associated parameter for that model */ - void updateControlParams(const Point& kick_or_chip_origin, const Angle& kick_or_chip_direction, - AutoChipOrKick auto_chip_or_kick); + void updateControlParams(const Point& kick_or_chip_origin, + const Angle& kick_or_chip_direction, + AutoChipOrKick auto_chip_or_kick); /** * Updates the control parameters for this KickTactic. * * @param kick_origin The location where the kick will be taken * @param kick_or_chip_target The target location where the kick or chip will aim for - * @param auto_chip_or_kick The mode of how the robot will chip or kick the ball, and the associated parameter for that modell + * @param auto_chip_or_kick The mode of how the robot will chip or kick the ball, and + * the associated parameter for that model */ - void updateControlParams(const Point& kick_or_chip_origin, const Point& kickd_or_chip_target, - AutoChipOrKick auto_chip_or_kick); + void updateControlParams(const Point& kick_or_chip_origin, + const Point& kickd_or_chip_target, + AutoChipOrKick auto_chip_or_kick); void accept(TacticVisitor& visitor) const override; }; diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp index d969584ff7..c5873e6247 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp @@ -124,7 +124,8 @@ const Point PenaltyKickFSM::evaluateNextShotPosition(std::optional enemy_ void PenaltyKickFSM::shoot(const Update &event, boost::sml::back::process processEvent) { - AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, PENALTY_KICK_SHOT_SPEED}; + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, + PENALTY_KICK_SHOT_SPEED}; KickOrChipFSM::ControlParams control_params{ .kick_or_chip_origin = event.common.world_ptr->ball().position(), .kick_or_chip_direction = shot_angle, diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h index 62f988b63e..0d4826e94d 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h @@ -121,8 +121,8 @@ struct PenaltyKickFSM : TacticFSM *DribbleFSM_S + Update_E[!takePenaltyShot_G] / updateApproachKeeper_A, DribbleFSM_S + Update_E[timeOutApproach_G] / shoot_A = KickOrChipFSM_S, DribbleFSM_S + Update_E / adjustOrientationForShot_A, - DribbleFSM_S = KickOrChipFSM_S, KickOrChipFSM_S + Update_E / shoot_A, KickOrChipFSM_S = X, - X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); + DribbleFSM_S = KickOrChipFSM_S, KickOrChipFSM_S + Update_E / shoot_A, + KickOrChipFSM_S = X, X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); }; private: diff --git a/src/software/ai/hl/stp/tactic/tactic_visitor.h b/src/software/ai/hl/stp/tactic/tactic_visitor.h index 176ff4eadf..f461bfcfbf 100644 --- a/src/software/ai/hl/stp/tactic/tactic_visitor.h +++ b/src/software/ai/hl/stp/tactic/tactic_visitor.h @@ -74,5 +74,5 @@ class TacticVisitor virtual void visit(const PlaceBallMoveTactic &tactic) = 0; virtual void visit(const WallKickoffTactic &tactic) = 0; virtual void visit(const AvoidInterferenceTactic &tactic) = 0; - virtual void visit(const KickOrChipTactic &tactic) = 0; + virtual void visit(const KickOrChipTactic &tactic) = 0; }; diff --git a/src/software/ai/motion_constraint/motion_constraint_visitor.h b/src/software/ai/motion_constraint/motion_constraint_visitor.h index e3d73351db..ee92df124a 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.h +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.h @@ -45,7 +45,7 @@ class MotionConstraintVisitor : public TacticVisitor void visit(const WallKickoffTactic &tactic) override; void visit(const AvoidInterferenceTactic &tactic) override; void visit(const PassDefenderTactic &tactic) override; - void visit(const KickOrChipTactic &Tactic) override; + void visit(const KickOrChipTactic &Tactic) override; /** * Gets the motion constraints updated with the requirements of the tactics From 4d462df8f79bffdf3f7fed2560a9d34e8328c988 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Sun, 1 Mar 2026 12:11:47 -0800 Subject: [PATCH 06/24] fix bugs in penalty kick fsm test --- .../penalty_kick/penalty_kick_fsm_test.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm_test.cpp b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm_test.cpp index bd6b41a706..c9eb990fd4 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm_test.cpp +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm_test.cpp @@ -4,8 +4,7 @@ #include "software/test_util/test_util.h" -// TODO (#2473): fix and re-enable -TEST(PenaltyKickFSM, DISABLED_test_transitions) +TEST(PenaltyKickFSM, test_transitions) { std::shared_ptr world = ::TestUtil::createBlankTestingWorld(); ::TestUtil::setBallPosition(world, world->field().friendlyPenaltyMark(), @@ -14,7 +13,7 @@ TEST(PenaltyKickFSM, DISABLED_test_transitions) FSM fsm{PenaltyKickFSM(std::make_shared()), DribbleFSM(std::make_shared()), - KickFSM(std::make_shared()), + KickOrChipFSM(std::make_shared()), GetBehindBallFSM(std::make_shared())}; PenaltyKickFSM::ControlParams control_params{}; @@ -38,20 +37,18 @@ TEST(PenaltyKickFSM, DISABLED_test_transitions) ::TestUtil::setBallPosition(world, position, Timestamp::fromSeconds(2)); fsm.process_event(PenaltyKickFSM::Update( control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - EXPECT_TRUE(fsm.is(boost::sml::state)); - EXPECT_TRUE(fsm.is)>( + EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is)>( boost::sml::state)); ::TestUtil::setBallPosition(world, position + Vector(0.1, 0), Timestamp::fromSeconds(2)); fsm.process_event(PenaltyKickFSM::Update( control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - EXPECT_TRUE(fsm.is(boost::sml::state)); - EXPECT_TRUE(fsm.is)>( - boost::sml::state)); + EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is)>( + boost::sml::state)); - ::TestUtil::setBallPosition(world, world->field().enemyGoalCenter(), - Timestamp::fromSeconds(4)); ::TestUtil::setBallVelocity(world, Vector(5, 0), Timestamp::fromSeconds(4)); fsm.process_event(PenaltyKickFSM::Update( control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); From e9d3135e851df7516be5db24f206273b0b5f450a Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Sun, 1 Mar 2026 12:13:53 -0800 Subject: [PATCH 07/24] add tests for kick or chip fsm --- .../ai/hl/stp/tactic/kick_or_chip/BUILD | 10 ++ .../kick_or_chip/kick_or_chip_fsm_test.cpp | 131 ++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm_test.cpp diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD index d5bd6a05d8..b81b9eec35 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD @@ -22,3 +22,13 @@ cc_library( ], ) +cc_test( + name = "kick_or_chip_fsm_test", + srcs = ["kick_or_chip_fsm_test.cpp"], + deps = [ + ":kick_or_chip_tactic", + "//shared/test_util:tbots_gtest_main", + "//software/test_util", + ], +) + diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm_test.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm_test.cpp new file mode 100644 index 0000000000..819c5e4ddb --- /dev/null +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm_test.cpp @@ -0,0 +1,131 @@ +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h" + +#include + +#include "software/test_util/test_util.h" + +TEST(KickOrChipFSMTest, test_transitions_autokick) +{ + std::shared_ptr world = ::TestUtil::createBlankTestingWorld(); + Robot robot = ::TestUtil::createRobotAtPos(Point(-2, -3)); + KickOrChipFSM::ControlParams control_params{ + .kick_or_chip_origin = Point(-2, 1.5), + .kick_or_chip_direction = Angle::threeQuarter(), + .auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, 1.2}}; + + FSM fsm{KickOrChipFSM(std::make_shared()), + GetBehindBallFSM(std::make_shared())}; + + // Start in GetBehindBallFSM state's GetBehindBallState + EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is)>( + boost::sml::state)); + + // Transition to GetBehindBallFSM state's GetBehindBallState + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is)>( + boost::sml::state)); + + // Robot is now behind ball + robot = Robot(0, + RobotState(Point(-2, 1.7), Vector(), Angle::threeQuarter(), + AngularVelocity::zero()), + Timestamp::fromSeconds(123)); + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + // Transition to KickOrChipState + EXPECT_TRUE(fsm.is(boost::sml::state)); + + // Change the kick direction and expect the FSM to realign + control_params.kick_or_chip_direction = Angle::quarter(); + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is)>( + boost::sml::state)); + + // Robot is now behind ball in the new direction + robot = Robot( + 0, + RobotState(Point(-2, 1.3), Vector(), Angle::quarter(), AngularVelocity::zero()), + Timestamp::fromSeconds(124)); + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + // Transition to KickOrChipState again + EXPECT_TRUE(fsm.is(boost::sml::state)); + + // Ball is now kicked + ::TestUtil::setBallVelocity(world, Vector(0, 2.1), Timestamp::fromSeconds(123)); + + EXPECT_TRUE(world->ball().hasBallBeenKicked(Angle::quarter())); + + // Tactic is done + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + EXPECT_TRUE(fsm.is(boost::sml::X)); +} + +TEST(KickOrChipFSMTest, test_transitions_autochip) +{ + std::shared_ptr world = ::TestUtil::createBlankTestingWorld(); + Robot robot = ::TestUtil::createRobotAtPos(Point(-2, -3)); + KickOrChipFSM::ControlParams control_params{ + .kick_or_chip_origin = Point(-2, 1.5), + .kick_or_chip_direction = Angle::threeQuarter(), + .auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, 1.2}}; + + FSM fsm{KickOrChipFSM(std::make_shared()), + GetBehindBallFSM(std::make_shared())}; + + // Start in GetBehindBallFSM state's GetBehindBallState + EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is)>( + boost::sml::state)); + + // Transition to GetBehindBallFSM state's GetBehindBallState + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is)>( + boost::sml::state)); + + // Robot is now behind ball + robot = Robot(0, + RobotState(Point(-2, 1.7), Vector(), Angle::threeQuarter(), + AngularVelocity::zero()), + Timestamp::fromSeconds(123)); + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + // Transition to KickOrChipState + EXPECT_TRUE(fsm.is(boost::sml::state)); + + // Change the chip direction and expect the FSM to realign + control_params.kick_or_chip_direction = Angle::quarter(); + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is)>( + boost::sml::state)); + + // Robot is now behind ball in the new direction + robot = Robot( + 0, + RobotState(Point(-2, 1.3), Vector(), Angle::quarter(), AngularVelocity::zero()), + Timestamp::fromSeconds(124)); + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + // Transition to KickOrChipState again + EXPECT_TRUE(fsm.is(boost::sml::state)); + + // Ball is now chipped + ::TestUtil::setBallVelocity(world, Vector(0, 2.1), Timestamp::fromSeconds(123)); + + EXPECT_TRUE(world->ball().hasBallBeenKicked(Angle::quarter())); + + // Tactic is done + fsm.process_event(KickOrChipFSM::Update( + control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); + EXPECT_TRUE(fsm.is(boost::sml::X)); +} From 3edad565651104e54e8b39e25f2534b44e17020a Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Sun, 1 Mar 2026 14:56:51 -0800 Subject: [PATCH 08/24] idk if this works --- "\\" | 219 ++++++++++++++++++ src/proto/tactic.proto | 11 + .../ai/hl/stp/tactic/kick_or_chip/BUILD | 13 ++ .../kick_or_chip/kick_or_chip_tactic.cpp | 4 +- .../kick_or_chip/kick_or_chip_tactic_test.cpp | 88 +++++++ .../ai/hl/stp/tactic/tactic_factory.cpp | 12 + .../ai/hl/stp/tactic/tactic_factory.h | 3 + 7 files changed, 349 insertions(+), 1 deletion(-) create mode 100644 "\\" create mode 100644 src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic_test.cpp diff --git "a/\\" "b/\\" new file mode 100644 index 0000000000..c928a8bbcd --- /dev/null +++ "b/\\" @@ -0,0 +1,219 @@ +#include "proto/message_translation/ssl_simulation_robot_control.h" + +#include "shared/constants.h" +#include "software/geom/angle.h" +#include "software/logger/logger.h" + +// Converts rpm and wheel_radius_meters [m] to speed [m/s] +float rpm_to_m_per_s(float rpm, float wheel_radius_meters) +{ + return (2 * (float)M_PI * rpm * wheel_radius_meters) / 60.0f; +} + +std::unique_ptr createRobotMoveCommand( + const TbotsProto::DirectControlPrimitive& direct_control, float front_wheel_angle_deg, + float back_wheel_angle_deg, float wheel_radius_meters) +{ + switch (direct_control.motor_control().drive_control_case()) + { + case TbotsProto::MotorControl::DRIVE_CONTROL_NOT_SET: + break; + + case TbotsProto::MotorControl::kDirectPerWheelControl: + LOG(FATAL) << "Direct per-wheel control is not supported in simulation"; + break; + + case TbotsProto::MotorControl::kDirectVelocityControl: + { + auto move_local_velocity = SSLSimulationProto::MoveLocalVelocity(); + move_local_velocity.set_forward( + static_cast(direct_control.motor_control() + .direct_velocity_control() + .velocity() + .x_component_meters())); + move_local_velocity.set_left(static_cast(direct_control.motor_control() + .direct_velocity_control() + .velocity() + .y_component_meters())); + move_local_velocity.set_angular( + static_cast(direct_control.motor_control() + .direct_velocity_control() + .angular_velocity() + .radians_per_second())); + + auto move_command = std::make_unique(); + *(move_command->mutable_local_velocity()) = move_local_velocity; + return move_command; + } + } + return std::make_unique(); +} + +std::unique_ptr getRobotCommandFromDirectControl( + unsigned int robot_id, + std::unique_ptr direct_control, + RobotConstants_t& robot_constants) +{ + auto move_command = createRobotMoveCommand( + *direct_control, robot_constants.front_wheel_angle_deg, + robot_constants.back_wheel_angle_deg, robot_constants.wheel_radius_meters); + // Values for robot command + std::optional kick_speed; // [m/s] + std::optional kick_angle; // [degree] + std::optional dribbler_speed; // [rpm] + + switch (direct_control->power_control().chicker().chicker_command_case()) + { + case TbotsProto::PowerControl::ChickerControl::kKickSpeedMPerS: + { + kick_speed = direct_control->power_control().chicker().kick_speed_m_per_s(); + kick_angle = std::nullopt; + break; + } + case TbotsProto::PowerControl::ChickerControl::kChipDistanceMeters: + { + Angle chip_angle = Angle::fromDegrees(ROBOT_CHIP_ANGLE_DEGREES); + // Use the formula for the Range of a parabolic projectile + // Rearrange to solve for the initial velocity. + // https://courses.lumenlearning.com/boundless-physics/chapter/projectile-motion/ + float range = + direct_control->power_control().chicker().chip_distance_meters(); + float numerator = + range * + static_cast(ACCELERATION_DUE_TO_GRAVITY_METERS_PER_SECOND_SQUARED); + float denominator = static_cast(2.0f * (chip_angle * 2.0f).sin()); + float chip_speed = static_cast(std::sqrt(numerator / denominator)); + + kick_speed = chip_speed; + kick_angle = chip_angle.toDegrees(); + break; + } + case TbotsProto::PowerControl::ChickerControl::kKickPulseWidth: + { + LOG(FATAL) + << "Kicker control using pulse widths is not supported in simulation"; + break; + } + case TbotsProto::PowerControl::ChickerControl::kChipPulseWidth: + { + LOG(FATAL) + << "Chipper control using pulse widths is not supported in simulation"; + break; + } + case TbotsProto::PowerControl::ChickerControl::kAutoChipOrKick: + { + switch (direct_control->power_control() + .chicker() + .auto_chip_or_kick() + .auto_chip_or_kick_case()) + { + case TbotsProto::AutoChipOrKick::kAutokickSpeedMPerS: + { + kick_speed = direct_control->power_control() + .chicker() + .auto_chip_or_kick() + .autokick_speed_m_per_s(); + kick_angle = std::nullopt; + break; + } + case TbotsProto::AutoChipOrKick::kAutochipDistanceMeters: + { + Angle chip_angle = Angle::fromDegrees(ROBOT_CHIP_ANGLE_DEGREES); + // Use the formula for the Range of a parabolic projectile + // Rearrange to solve for the initial velocity. + // https://courses.lumenlearning.com/boundless-physics/chapter/projectile-motion/ + float range = direct_control->power_control() + .chicker() + .auto_chip_or_kick() + .autochip_distance_meters(); + float numerator = + range * + static_cast( + ACCELERATION_DUE_TO_GRAVITY_METERS_PER_SECOND_SQUARED); + float denominator = + static_cast(2.0f * (chip_angle * 2.0f).sin()); + float chip_speed = + static_cast(std::sqrt(numerator / denominator)); + + kick_speed = chip_speed; + kick_angle = chip_angle.toDegrees(); + break; + } + case TbotsProto::AutoChipOrKick::kAutokickPulseWidth: + { + LOG(FATAL) + << "Autokick control using pulse widths is not supported in simulation"; + break; + } + case TbotsProto::AutoChipOrKick::kAutochipPulseWidth: + { + LOG(FATAL) + << "Autochip control using pulse widths is not supported in simulation"; + break; + } + case TbotsProto::AutoChipOrKick::AUTO_CHIP_OR_KICK_NOT_SET: + { + direct_control->mutable_power_control() + ->mutable_chicker() + ->clear_chicker_command(); + break; + } + } + break; + } + case TbotsProto::PowerControl::ChickerControl::CHICKER_COMMAND_NOT_SET: + { + direct_control->mutable_power_control() + ->mutable_chicker() + ->clear_chicker_command(); + break; + } + } + + return createRobotCommand(robot_id, std::move(move_command), kick_speed, kick_angle, + direct_control->motor_control().dribbler_speed_rpm()); +} + +std::unique_ptr createRobotCommand( + unsigned int robot_id, + std::unique_ptr move_command, + std::optional kick_speed, std::optional kick_angle, + std::optional dribbler_speed) +{ + auto robot_command = std::make_unique(); + + robot_command->set_id(robot_id); + + if (kick_speed.has_value()) + { + robot_command->set_kick_speed(static_cast(kick_speed.value())); + } + if (kick_angle.has_value()) + { + robot_command->set_kick_angle(static_cast(kick_angle.value())); + } + if (dribbler_speed.has_value()) + { + // NOTE: our dribbler speed for the robots is negative RPM to dribble, but + // the RobotCommand expects positive RPM to dribble. So we invert the sign + robot_command->set_dribbler_speed(-1.0f * + static_cast(dribbler_speed.value())); + } + + *(robot_command->mutable_move_command()) = *move_command; + + return robot_command; +} + +std::unique_ptr createRobotControl( + std::vector> robot_commands) +{ + auto robot_control = std::make_unique(); + + for (auto&& robot_command : robot_commands) + { + *(robot_control->add_robot_commands()) = *robot_command; + } + + return robot_control; +} diff --git a/src/proto/tactic.proto b/src/proto/tactic.proto index afc537c1b4..dc93ff51ff 100644 --- a/src/proto/tactic.proto +++ b/src/proto/tactic.proto @@ -30,6 +30,7 @@ message Tactic ShadowEnemyTactic shadow_enemy = 13; HaltTactic halt = 14; PassDefenderTactic pass_defender = 15; + KickOrChipTactic kick_or_chip = 16; } } @@ -177,3 +178,13 @@ message ShadowEnemyTactic } message HaltTactic {} + +message KickOrChipTactic +{ + // The location where the kick or chip will be taken from + required Point kick_or_chip_origin = 1; + // The direction the Robot will kick or chip in + required Angle kick_or_chip_direction = 2; + // How the robot will chip or kick the ball + required AutoChipOrKick auto_chip_or_kick = 3; +} diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD index b81b9eec35..4fc0865c06 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD @@ -22,6 +22,19 @@ cc_library( ], ) +cc_test( + name = "kick_or_chip_tactic_test", + srcs = ["kick_or_chip_tactic_test.cpp"], + deps = [ + ":kick_or_chip_tactic", + "//shared/test_util:tbots_gtest_main", + "//software/simulated_tests:simulated_er_force_sim_play_test_fixture", + "//software/simulated_tests/terminating_validation_functions", + "//software/simulated_tests/validation:validation_function", + "//software/test_util", + ], +) + cc_test( name = "kick_or_chip_fsm_test", srcs = ["kick_or_chip_fsm_test.cpp"], diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp index 6e41bda52f..a142a817fe 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.cpp @@ -21,7 +21,9 @@ void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, con void KickOrChipTactic::updateControlParams(const Point& kick_or_chip_origin, const Point& kick_or_chip_target, AutoChipOrKick auto_chip_or_kick) { - updateControlParams(kick_or_chip_origin, kick_or_chip_target, auto_chip_or_kick); + updateControlParams(kick_or_chip_origin, + (kick_or_chip_target - kick_or_chip_origin).orientation(), + auto_chip_or_kick); } void KickOrChipTactic::accept(TacticVisitor &visitor) const diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic_test.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic_test.cpp new file mode 100644 index 0000000000..6a869685d5 --- /dev/null +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic_test.cpp @@ -0,0 +1,88 @@ +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h" + +#include + +#include + +#include "software/geom/algorithms/contains.h" +#include "software/simulated_tests/simulated_er_force_sim_play_test_fixture.h" +#include "software/simulated_tests/terminating_validation_functions/ball_kicked_validation.h" +#include "software/simulated_tests/terminating_validation_functions/robot_state_validation.h" +#include "software/simulated_tests/validation/validation_function.h" +#include "software/test_util/test_util.h" +#include "software/time/duration.h" +#include "software/world/world.h" + +class KickOrChipTacticTest + : public SimulatedErForceSimPlayTestFixture, + public ::testing::WithParamInterface> +{ + protected: + TbotsProto::FieldType field_type = TbotsProto::FieldType::DIV_B; + Field field = Field::createField(field_type); +}; + +TEST_P(KickOrChipTacticTest, kick_or_chip_test) +{ + Vector ball_offset_from_robot = std::get<0>(GetParam()); + Angle angle_to_kick_at = std::get<1>(GetParam()); + AutoChipOrKick auto_chip_or_kick = std::get<2>(GetParam()); + + Point robot_position = Point(0, 0); + BallState ball_state(robot_position + ball_offset_from_robot, Vector(0, 0)); + + auto friendly_robots = + TestUtil::createStationaryRobotStatesWithId({Point(-3, 2.5), robot_position}); + auto enemy_robots = TestUtil::createStationaryRobotStatesWithId({Point(4, 0)}); + + auto tactic = + std::make_shared(std::make_shared()); + tactic->updateControlParams(robot_position + ball_offset_from_robot, angle_to_kick_at, + auto_chip_or_kick); + setTactic(1, tactic); + + std::vector terminating_validation_functions = { + [angle_to_kick_at, tactic](std::shared_ptr world_ptr, + ValidationCoroutine::push_type& yield) + { + while (!tactic->done()) + { + yield("Tactic did not complete!"); + } + ballKicked(angle_to_kick_at, world_ptr, yield); + }}; + + std::vector non_terminating_validation_functions = {}; + + runTest(field_type, ball_state, friendly_robots, enemy_robots, + terminating_validation_functions, non_terminating_validation_functions, + Duration::fromSeconds(5)); +} + +INSTANTIATE_TEST_CASE_P( + AutokickBallLocations, KickOrChipTacticTest, + ::testing::Values( + std::make_tuple(Vector(0, 0.5), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), + std::make_tuple(Vector(0, -0.5), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), + std::make_tuple(Vector(0.5, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), + std::make_tuple(Vector(-0.5, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), + std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}))); + +INSTANTIATE_TEST_CASE_P( + AutochipBallLocations, KickOrChipTacticTest, + ::testing::Values( + std::make_tuple(Vector(0, 0.5), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), + std::make_tuple(Vector(0, -0.5), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), + std::make_tuple(Vector(0.5, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), + std::make_tuple(Vector(-0.5, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), + std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}))); diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.cpp b/src/software/ai/hl/stp/tactic/tactic_factory.cpp index 9460e7cddc..ffaf3498c7 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.cpp +++ b/src/software/ai/hl/stp/tactic/tactic_factory.cpp @@ -23,6 +23,7 @@ std::shared_ptr createTactic( PROTO_CREATE_TACTIC_CASE(GetBehindBall, get_behind_ball) PROTO_CREATE_TACTIC_CASE(Goalie, goalie) PROTO_CREATE_TACTIC_CASE(Kick, kick) + PROTO_CREATE_TACTIC_CASE(KickOrChip, kick_or_chip) PROTO_CREATE_TACTIC_CASE(MoveGoalieToGoalLine, move_goalie_to_goal_line) PROTO_CREATE_TACTIC_CASE(Move, move) PROTO_CREATE_TACTIC_CASE(PassDefender, pass_defender) @@ -135,6 +136,17 @@ std::shared_ptr createTactic( return tactic; } +std::shared_ptr createTactic( + const TbotsProto::KickOrChipTactic &tactic_proto, + std::shared_ptr ai_config_ptr) +{ + auto tactic = std::make_shared(ai_config_ptr); + tactic->updateControlParams(createPoint(tactic_proto.kick_or_chip_origin()), + createAngle(tactic_proto.kick_or_chip_direction()), + createAutoChipOrKick(tactic_proto.auto_chip_or_kick())); + return tactic; +} + std::shared_ptr createTactic( const TbotsProto::MoveGoalieToGoalLineTactic &tactic_proto, std::shared_ptr ai_config_ptr) diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.h b/src/software/ai/hl/stp/tactic/tactic_factory.h index 59a8460910..2cda5033ab 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.h +++ b/src/software/ai/hl/stp/tactic/tactic_factory.h @@ -35,6 +35,9 @@ std::shared_ptr createTactic( std::shared_ptr createTactic( const TbotsProto::KickTactic &tactic_proto, std::shared_ptr ai_config_ptr); +std::shared_ptr createTactic( + const TbotsProto::KickOrChipTactic &tactic_proto, + std::shared_ptr ai_config_ptr); std::shared_ptr createTactic( const TbotsProto::MoveGoalieToGoalLineTactic &tactic_proto, std::shared_ptr ai_config_ptr); From e830459329cf35dc90f9a007396c7aaf7ec29ef9 Mon Sep 17 00:00:00 2001 From: Samuel <92961466+StarrryNight@users.noreply.github.com> Date: Fri, 6 Mar 2026 11:50:47 -0800 Subject: [PATCH 09/24] Adjust kick target calculation in kickoff play --- src/software/ai/hl/stp/play/kickoff_friendly_play.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp index 7bceac31b8..acc0635242 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp +++ b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp @@ -116,11 +116,13 @@ void KickoffFriendlyPlay::getNextTactics(TacticCoroutine::push_type &yield, // TODO (#2612): This needs to be adjusted post field testing, ball needs to land // exactly in the middle of the enemy field - AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, 0}; + Point ball_position = world_ptr->ball().position(); + Point kick_target = world_ptr->field().centerPoint() + + Vector(world_ptr->field().xLength() / 6, 0); + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, kick_target - ball_position}; kickoff_chip_tactic->updateControlParams( - world_ptr->ball().position(), - world_ptr->field().centerPoint() + - Vector(world_ptr->field().xLength() / 6, 0), + ball_position, + kick_target, auto_chip_or_kick); result[0].emplace_back(kickoff_chip_tactic); From f4c95dea90e2d3d41bf6c3a35cc92316236b1f1a Mon Sep 17 00:00:00 2001 From: Samuel <92961466+StarrryNight@users.noreply.github.com> Date: Fri, 6 Mar 2026 14:57:45 -0800 Subject: [PATCH 10/24] Update AutoChipOrKick calculation for kickoff play --- src/software/ai/hl/stp/play/kickoff_friendly_play.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp index acc0635242..46e5abaa0e 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp +++ b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp @@ -119,7 +119,7 @@ void KickoffFriendlyPlay::getNextTactics(TacticCoroutine::push_type &yield, Point ball_position = world_ptr->ball().position(); Point kick_target = world_ptr->field().centerPoint() + Vector(world_ptr->field().xLength() / 6, 0); - AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, kick_target - ball_position}; + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, (kick_target - ball_position).length()}; kickoff_chip_tactic->updateControlParams( ball_position, kick_target, From 8b01f4e5115bd6cdc001c67327d7cc6b4eb6627f Mon Sep 17 00:00:00 2001 From: Samuel <92961466+StarrryNight@users.noreply.github.com> Date: Mon, 9 Mar 2026 14:11:28 -0700 Subject: [PATCH 11/24] Delete \ --- "\\" | 219 ----------------------------------------------------------- 1 file changed, 219 deletions(-) delete mode 100644 "\\" diff --git "a/\\" "b/\\" deleted file mode 100644 index c928a8bbcd..0000000000 --- "a/\\" +++ /dev/null @@ -1,219 +0,0 @@ -#include "proto/message_translation/ssl_simulation_robot_control.h" - -#include "shared/constants.h" -#include "software/geom/angle.h" -#include "software/logger/logger.h" - -// Converts rpm and wheel_radius_meters [m] to speed [m/s] -float rpm_to_m_per_s(float rpm, float wheel_radius_meters) -{ - return (2 * (float)M_PI * rpm * wheel_radius_meters) / 60.0f; -} - -std::unique_ptr createRobotMoveCommand( - const TbotsProto::DirectControlPrimitive& direct_control, float front_wheel_angle_deg, - float back_wheel_angle_deg, float wheel_radius_meters) -{ - switch (direct_control.motor_control().drive_control_case()) - { - case TbotsProto::MotorControl::DRIVE_CONTROL_NOT_SET: - break; - - case TbotsProto::MotorControl::kDirectPerWheelControl: - LOG(FATAL) << "Direct per-wheel control is not supported in simulation"; - break; - - case TbotsProto::MotorControl::kDirectVelocityControl: - { - auto move_local_velocity = SSLSimulationProto::MoveLocalVelocity(); - move_local_velocity.set_forward( - static_cast(direct_control.motor_control() - .direct_velocity_control() - .velocity() - .x_component_meters())); - move_local_velocity.set_left(static_cast(direct_control.motor_control() - .direct_velocity_control() - .velocity() - .y_component_meters())); - move_local_velocity.set_angular( - static_cast(direct_control.motor_control() - .direct_velocity_control() - .angular_velocity() - .radians_per_second())); - - auto move_command = std::make_unique(); - *(move_command->mutable_local_velocity()) = move_local_velocity; - return move_command; - } - } - return std::make_unique(); -} - -std::unique_ptr getRobotCommandFromDirectControl( - unsigned int robot_id, - std::unique_ptr direct_control, - RobotConstants_t& robot_constants) -{ - auto move_command = createRobotMoveCommand( - *direct_control, robot_constants.front_wheel_angle_deg, - robot_constants.back_wheel_angle_deg, robot_constants.wheel_radius_meters); - // Values for robot command - std::optional kick_speed; // [m/s] - std::optional kick_angle; // [degree] - std::optional dribbler_speed; // [rpm] - - switch (direct_control->power_control().chicker().chicker_command_case()) - { - case TbotsProto::PowerControl::ChickerControl::kKickSpeedMPerS: - { - kick_speed = direct_control->power_control().chicker().kick_speed_m_per_s(); - kick_angle = std::nullopt; - break; - } - case TbotsProto::PowerControl::ChickerControl::kChipDistanceMeters: - { - Angle chip_angle = Angle::fromDegrees(ROBOT_CHIP_ANGLE_DEGREES); - // Use the formula for the Range of a parabolic projectile - // Rearrange to solve for the initial velocity. - // https://courses.lumenlearning.com/boundless-physics/chapter/projectile-motion/ - float range = - direct_control->power_control().chicker().chip_distance_meters(); - float numerator = - range * - static_cast(ACCELERATION_DUE_TO_GRAVITY_METERS_PER_SECOND_SQUARED); - float denominator = static_cast(2.0f * (chip_angle * 2.0f).sin()); - float chip_speed = static_cast(std::sqrt(numerator / denominator)); - - kick_speed = chip_speed; - kick_angle = chip_angle.toDegrees(); - break; - } - case TbotsProto::PowerControl::ChickerControl::kKickPulseWidth: - { - LOG(FATAL) - << "Kicker control using pulse widths is not supported in simulation"; - break; - } - case TbotsProto::PowerControl::ChickerControl::kChipPulseWidth: - { - LOG(FATAL) - << "Chipper control using pulse widths is not supported in simulation"; - break; - } - case TbotsProto::PowerControl::ChickerControl::kAutoChipOrKick: - { - switch (direct_control->power_control() - .chicker() - .auto_chip_or_kick() - .auto_chip_or_kick_case()) - { - case TbotsProto::AutoChipOrKick::kAutokickSpeedMPerS: - { - kick_speed = direct_control->power_control() - .chicker() - .auto_chip_or_kick() - .autokick_speed_m_per_s(); - kick_angle = std::nullopt; - break; - } - case TbotsProto::AutoChipOrKick::kAutochipDistanceMeters: - { - Angle chip_angle = Angle::fromDegrees(ROBOT_CHIP_ANGLE_DEGREES); - // Use the formula for the Range of a parabolic projectile - // Rearrange to solve for the initial velocity. - // https://courses.lumenlearning.com/boundless-physics/chapter/projectile-motion/ - float range = direct_control->power_control() - .chicker() - .auto_chip_or_kick() - .autochip_distance_meters(); - float numerator = - range * - static_cast( - ACCELERATION_DUE_TO_GRAVITY_METERS_PER_SECOND_SQUARED); - float denominator = - static_cast(2.0f * (chip_angle * 2.0f).sin()); - float chip_speed = - static_cast(std::sqrt(numerator / denominator)); - - kick_speed = chip_speed; - kick_angle = chip_angle.toDegrees(); - break; - } - case TbotsProto::AutoChipOrKick::kAutokickPulseWidth: - { - LOG(FATAL) - << "Autokick control using pulse widths is not supported in simulation"; - break; - } - case TbotsProto::AutoChipOrKick::kAutochipPulseWidth: - { - LOG(FATAL) - << "Autochip control using pulse widths is not supported in simulation"; - break; - } - case TbotsProto::AutoChipOrKick::AUTO_CHIP_OR_KICK_NOT_SET: - { - direct_control->mutable_power_control() - ->mutable_chicker() - ->clear_chicker_command(); - break; - } - } - break; - } - case TbotsProto::PowerControl::ChickerControl::CHICKER_COMMAND_NOT_SET: - { - direct_control->mutable_power_control() - ->mutable_chicker() - ->clear_chicker_command(); - break; - } - } - - return createRobotCommand(robot_id, std::move(move_command), kick_speed, kick_angle, - direct_control->motor_control().dribbler_speed_rpm()); -} - -std::unique_ptr createRobotCommand( - unsigned int robot_id, - std::unique_ptr move_command, - std::optional kick_speed, std::optional kick_angle, - std::optional dribbler_speed) -{ - auto robot_command = std::make_unique(); - - robot_command->set_id(robot_id); - - if (kick_speed.has_value()) - { - robot_command->set_kick_speed(static_cast(kick_speed.value())); - } - if (kick_angle.has_value()) - { - robot_command->set_kick_angle(static_cast(kick_angle.value())); - } - if (dribbler_speed.has_value()) - { - // NOTE: our dribbler speed for the robots is negative RPM to dribble, but - // the RobotCommand expects positive RPM to dribble. So we invert the sign - robot_command->set_dribbler_speed(-1.0f * - static_cast(dribbler_speed.value())); - } - - *(robot_command->mutable_move_command()) = *move_command; - - return robot_command; -} - -std::unique_ptr createRobotControl( - std::vector> robot_commands) -{ - auto robot_control = std::make_unique(); - - for (auto&& robot_command : robot_commands) - { - *(robot_control->add_robot_commands()) = *robot_command; - } - - return robot_control; -} From c60af76b89d02c7fc45d2dd56b2d6fd417f1ab33 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Mon, 9 Mar 2026 16:01:31 -0700 Subject: [PATCH 12/24] clean up stray files --- src/software/ai/hl/stp/tactic/Untitled | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/software/ai/hl/stp/tactic/Untitled diff --git a/src/software/ai/hl/stp/tactic/Untitled b/src/software/ai/hl/stp/tactic/Untitled deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/src/software/ai/hl/stp/tactic/Untitled +++ /dev/null @@ -1 +0,0 @@ - From a44661e2dc4c2d08cad494e08297ddf5996714c1 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Mon, 9 Mar 2026 16:10:58 -0700 Subject: [PATCH 13/24] Remove kick tactic and chip tactic --- src/software/ai/hl/stp/tactic/BUILD | 2 - src/software/ai/hl/stp/tactic/all_tactics.h | 2 - src/software/ai/hl/stp/tactic/chip/BUILD | 43 --------- .../ai/hl/stp/tactic/chip/chip_fsm.cpp | 56 ----------- src/software/ai/hl/stp/tactic/chip/chip_fsm.h | 89 ------------------ .../ai/hl/stp/tactic/chip/chip_fsm_test.cpp | 67 ------------- .../ai/hl/stp/tactic/chip/chip_tactic.cpp | 31 ------- .../ai/hl/stp/tactic/chip/chip_tactic.h | 43 --------- .../hl/stp/tactic/chip/chip_tactic_test.cpp | 82 ---------------- src/software/ai/hl/stp/tactic/kick/BUILD | 43 --------- .../ai/hl/stp/tactic/kick/kick_fsm.cpp | 56 ----------- src/software/ai/hl/stp/tactic/kick/kick_fsm.h | 93 ------------------- .../ai/hl/stp/tactic/kick/kick_fsm_test.cpp | 67 ------------- .../ai/hl/stp/tactic/kick/kick_tactic.cpp | 30 ------ .../ai/hl/stp/tactic/kick/kick_tactic.h | 46 --------- .../hl/stp/tactic/kick/kick_tactic_test.cpp | 82 ---------------- .../ai/hl/stp/tactic/tactic_factory.cpp | 24 ----- .../ai/hl/stp/tactic/tactic_factory.h | 6 -- .../ai/hl/stp/tactic/tactic_visitor.h | 4 - .../motion_constraint_set_builder_test.cpp | 2 +- .../motion_constraint_visitor.cpp | 4 - .../motion_constraint_visitor.h | 2 - 22 files changed, 1 insertion(+), 873 deletions(-) delete mode 100644 src/software/ai/hl/stp/tactic/chip/BUILD delete mode 100644 src/software/ai/hl/stp/tactic/chip/chip_fsm.cpp delete mode 100644 src/software/ai/hl/stp/tactic/chip/chip_fsm.h delete mode 100644 src/software/ai/hl/stp/tactic/chip/chip_fsm_test.cpp delete mode 100644 src/software/ai/hl/stp/tactic/chip/chip_tactic.cpp delete mode 100644 src/software/ai/hl/stp/tactic/chip/chip_tactic.h delete mode 100644 src/software/ai/hl/stp/tactic/chip/chip_tactic_test.cpp delete mode 100644 src/software/ai/hl/stp/tactic/kick/BUILD delete mode 100644 src/software/ai/hl/stp/tactic/kick/kick_fsm.cpp delete mode 100644 src/software/ai/hl/stp/tactic/kick/kick_fsm.h delete mode 100644 src/software/ai/hl/stp/tactic/kick/kick_fsm_test.cpp delete mode 100644 src/software/ai/hl/stp/tactic/kick/kick_tactic.cpp delete mode 100644 src/software/ai/hl/stp/tactic/kick/kick_tactic.h delete mode 100644 src/software/ai/hl/stp/tactic/kick/kick_tactic_test.cpp diff --git a/src/software/ai/hl/stp/tactic/BUILD b/src/software/ai/hl/stp/tactic/BUILD index 8c0c1a39c1..184dedae12 100644 --- a/src/software/ai/hl/stp/tactic/BUILD +++ b/src/software/ai/hl/stp/tactic/BUILD @@ -16,13 +16,11 @@ cc_library( deps = [ ":tactic", "//software/ai/hl/stp/tactic/attacker:attacker_tactic", - "//software/ai/hl/stp/tactic/chip:chip_tactic", "//software/ai/hl/stp/tactic/crease_defender:crease_defender_tactic", "//software/ai/hl/stp/tactic/dribble:dribble_tactic", "//software/ai/hl/stp/tactic/get_behind_ball:get_behind_ball_tactic", "//software/ai/hl/stp/tactic/goalie:goalie_tactic", "//software/ai/hl/stp/tactic/halt:halt_tactic", - "//software/ai/hl/stp/tactic/kick:kick_tactic", "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/ai/hl/stp/tactic/pass_defender:pass_defender_tactic", diff --git a/src/software/ai/hl/stp/tactic/all_tactics.h b/src/software/ai/hl/stp/tactic/all_tactics.h index d7a99096eb..bf0a2c2a39 100644 --- a/src/software/ai/hl/stp/tactic/all_tactics.h +++ b/src/software/ai/hl/stp/tactic/all_tactics.h @@ -1,13 +1,11 @@ #pragma once #include "software/ai/hl/stp/tactic/attacker/attacker_tactic.h" -#include "software/ai/hl/stp/tactic/chip/chip_tactic.h" #include "software/ai/hl/stp/tactic/crease_defender/crease_defender_tactic.h" #include "software/ai/hl/stp/tactic/dribble/dribble_tactic.h" #include "software/ai/hl/stp/tactic/get_behind_ball/get_behind_ball_tactic.h" #include "software/ai/hl/stp/tactic/goalie/goalie_tactic.h" #include "software/ai/hl/stp/tactic/halt/halt_tactic.h" -#include "software/ai/hl/stp/tactic/kick/kick_tactic.h" #include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/pass_defender/pass_defender_tactic.h" diff --git a/src/software/ai/hl/stp/tactic/chip/BUILD b/src/software/ai/hl/stp/tactic/chip/BUILD deleted file mode 100644 index a4f05afb17..0000000000 --- a/src/software/ai/hl/stp/tactic/chip/BUILD +++ /dev/null @@ -1,43 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "chip_tactic", - srcs = [ - "chip_fsm.cpp", - "chip_tactic.cpp", - ], - hdrs = [ - "chip_fsm.h", - "chip_tactic.h", - ], - deps = [ - "//shared:constants", - "//software/ai/hl/stp/tactic", - "//software/ai/hl/stp/tactic:move_primitive", - "//software/ai/hl/stp/tactic/get_behind_ball:get_behind_ball_tactic", - "//software/logger", - ], -) - -cc_test( - name = "chip_fsm_test", - srcs = ["chip_fsm_test.cpp"], - deps = [ - ":chip_tactic", - "//shared/test_util:tbots_gtest_main", - "//software/test_util", - ], -) - -cc_test( - name = "chip_tactic_test", - srcs = ["chip_tactic_test.cpp"], - deps = [ - ":chip_tactic", - "//shared/test_util:tbots_gtest_main", - "//software/simulated_tests:simulated_er_force_sim_play_test_fixture", - "//software/simulated_tests/terminating_validation_functions", - "//software/simulated_tests/validation:validation_function", - "//software/test_util", - ], -) diff --git a/src/software/ai/hl/stp/tactic/chip/chip_fsm.cpp b/src/software/ai/hl/stp/tactic/chip/chip_fsm.cpp deleted file mode 100644 index 500040ea60..0000000000 --- a/src/software/ai/hl/stp/tactic/chip/chip_fsm.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "software/ai/hl/stp/tactic/chip/chip_fsm.h" - -#include "software/ai/hl/stp/tactic/move_primitive.h" - -ChipFSM::ChipFSM(std::shared_ptr ai_config_ptr) - : TacticFSM(ai_config_ptr) -{ -} - -void ChipFSM::updateGetBehindBall( - const Update &event, boost::sml::back::process processEvent) -{ - GetBehindBallFSM::ControlParams control_params{ - .ball_location = event.control_params.chip_origin, - .chick_direction = event.control_params.chip_direction}; - - // Update the get behind ball fsm - processEvent(GetBehindBallFSM::Update(control_params, event.common)); -} - -void ChipFSM::updateChip(const Update &event) -{ - Vector direction_to_chip = - Vector::createFromAngle(event.control_params.chip_direction); - Point chip_target = event.control_params.chip_origin - - direction_to_chip.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); - - event.common.set_primitive(std::make_unique( - event.common.robot, chip_target, event.control_params.chip_direction, - TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT, - TbotsProto::ObstacleAvoidanceMode::SAFE, TbotsProto::DribblerMode::OFF, - TbotsProto::BallCollisionType::ALLOW, - AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, - event.control_params.chip_distance_meters})); -} - -bool ChipFSM::ballChicked(const Update &event) -{ - return event.common.world_ptr->ball().hasBallBeenKicked( - event.control_params.chip_direction); -} - -bool ChipFSM::shouldRealignWithBall(const Update &event) -{ - const Robot &robot = event.common.robot; - - // First check to see if it's too late to realign with the ball - if (robot.isNearDribbler(event.control_params.chip_origin, 0.05)) - { - return false; - } - - // Check if the robot is already aligned to chip the ball - return !isRobotReadyToChick(robot, event.control_params.chip_origin, - event.control_params.chip_direction); -} diff --git a/src/software/ai/hl/stp/tactic/chip/chip_fsm.h b/src/software/ai/hl/stp/tactic/chip/chip_fsm.h deleted file mode 100644 index 26ed55966d..0000000000 --- a/src/software/ai/hl/stp/tactic/chip/chip_fsm.h +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once - -#include "software/ai/hl/stp/tactic/get_behind_ball/get_behind_ball_fsm.h" -#include "software/ai/hl/stp/tactic/tactic_base.hpp" -#include "software/geom/point.h" - -struct ChipFSM : TacticFSM -{ - class ChipState; - - struct ControlParams - { - // The location where the chip will be taken from - Point chip_origin; - // The direction the Robot will chip in - Angle chip_direction; - // The distance the robot will chip to - double chip_distance_meters; - }; - - using Update = TacticFSM::Update; - - /** - * Constructor for ChipFSM - * - * @param ai_config_ptr Shared pointer to ai_config - */ - explicit ChipFSM(std::shared_ptr ai_config_ptr); - - /** - * Action that updates the MovePrimitive - * - * @param event ChipFSM::Update event - */ - void updateChip(const Update &event); - - /** - * Action that updates the GetBehindBallFSM - * - * @param event ChipFSM::Update event - * @param processEvent processes the GetBehindBallFSM::Update - */ - void updateGetBehindBall( - const Update &event, - boost::sml::back::process processEvent); - - /** - * Guard that checks if the ball has been chicked - * - * @param event ChipFSM::Update event - * - * @return if the ball has been chicked - */ - bool ballChicked(const Update &event); - - /** - * Guard that checks if the robot is aligned for the chip - * - * @param event KickFSM::Update event - * - * @return if the robot is aligned for the chip - */ - bool shouldRealignWithBall(const Update &event); - - auto operator()() - { - using namespace boost::sml; - - DEFINE_SML_STATE(GetBehindBallFSM) - DEFINE_SML_STATE(ChipState) - DEFINE_SML_EVENT(Update) - - DEFINE_SML_GUARD(ballChicked) - DEFINE_SML_GUARD(shouldRealignWithBall) - DEFINE_SML_ACTION(updateChip) - DEFINE_SML_SUB_FSM_UPDATE_ACTION(updateGetBehindBall, GetBehindBallFSM) - - return make_transition_table( - // src_state + event [guard] / action = dest_state - *GetBehindBallFSM_S + Update_E / updateGetBehindBall_A, - GetBehindBallFSM_S = ChipState_S, - - ChipState_S + Update_E[shouldRealignWithBall_G] / updateGetBehindBall_A = - GetBehindBallFSM_S, - ChipState_S + Update_E[!ballChicked_G] / updateChip_A = ChipState_S, - ChipState_S + Update_E[ballChicked_G] / SET_STOP_PRIMITIVE_ACTION = X, - X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); - } -}; diff --git a/src/software/ai/hl/stp/tactic/chip/chip_fsm_test.cpp b/src/software/ai/hl/stp/tactic/chip/chip_fsm_test.cpp deleted file mode 100644 index 857f19a879..0000000000 --- a/src/software/ai/hl/stp/tactic/chip/chip_fsm_test.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "software/ai/hl/stp/tactic/chip/chip_fsm.h" - -#include - -#include "software/test_util/test_util.h" - -TEST(ChipFSMTest, test_transitions) -{ - std::shared_ptr world = ::TestUtil::createBlankTestingWorld(); - Robot robot = ::TestUtil::createRobotAtPos(Point(-2, -3)); - ChipFSM::ControlParams control_params{.chip_origin = Point(-2, 1.5), - .chip_direction = Angle::threeQuarter(), - .chip_distance_meters = 1.2}; - - FSM fsm{ChipFSM(std::make_shared()), - GetBehindBallFSM(std::make_shared())}; - - // Start in GetBehindBallFSM state's GetBehindBallState - EXPECT_TRUE(fsm.is(boost::sml::state)); - EXPECT_TRUE(fsm.is)>( - boost::sml::state)); - - // Transition to GetBehindBallFSM state's GetBehindBallState - fsm.process_event(ChipFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - EXPECT_TRUE(fsm.is(boost::sml::state)); - EXPECT_TRUE(fsm.is)>( - boost::sml::state)); - - // Robot is now behind ball - robot = Robot(0, - RobotState(Point(-2, 1.7), Vector(), Angle::threeQuarter(), - AngularVelocity::zero()), - Timestamp::fromSeconds(123)); - fsm.process_event(ChipFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - // Transition to ChipState - EXPECT_TRUE(fsm.is(boost::sml::state)); - - // Change the chip direction and expect the FSM to realign - control_params.chip_direction = Angle::quarter(); - fsm.process_event(ChipFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - EXPECT_TRUE(fsm.is(boost::sml::state)); - EXPECT_TRUE(fsm.is)>( - boost::sml::state)); - - // Robot is now behind ball in the new direction - robot = Robot( - 0, - RobotState(Point(-2, 1.3), Vector(), Angle::quarter(), AngularVelocity::zero()), - Timestamp::fromSeconds(124)); - fsm.process_event(ChipFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - // Transition to ChipState again - EXPECT_TRUE(fsm.is(boost::sml::state)); - - // Ball is now chipped - ::TestUtil::setBallVelocity(world, Vector(0, 2.1), Timestamp::fromSeconds(123)); - - EXPECT_TRUE(world->ball().hasBallBeenKicked(Angle::quarter())); - - // Tactic is done - fsm.process_event(ChipFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - EXPECT_TRUE(fsm.is(boost::sml::X)); -} diff --git a/src/software/ai/hl/stp/tactic/chip/chip_tactic.cpp b/src/software/ai/hl/stp/tactic/chip/chip_tactic.cpp deleted file mode 100644 index b27f81cf5b..0000000000 --- a/src/software/ai/hl/stp/tactic/chip/chip_tactic.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "software/ai/hl/stp/tactic/chip/chip_tactic.h" - -#include - - -ChipTactic::ChipTactic(std::shared_ptr ai_config_ptr) - : TacticBase( - {RobotCapability::Chip, RobotCapability::Move}, ai_config_ptr) -{ -} - - -void ChipTactic::updateControlParams(const Point &chip_origin, - const Angle &chip_direction, - double chip_distance_meters) -{ - control_params.chip_origin = chip_origin; - control_params.chip_direction = chip_direction; - control_params.chip_distance_meters = chip_distance_meters; -} - -void ChipTactic::updateControlParams(const Point &chip_origin, const Point &chip_target) -{ - updateControlParams(chip_origin, (chip_target - chip_origin).orientation(), - (chip_target - chip_origin).length()); -} - -void ChipTactic::accept(TacticVisitor &visitor) const -{ - visitor.visit(*this); -} diff --git a/src/software/ai/hl/stp/tactic/chip/chip_tactic.h b/src/software/ai/hl/stp/tactic/chip/chip_tactic.h deleted file mode 100644 index f3e10e992e..0000000000 --- a/src/software/ai/hl/stp/tactic/chip/chip_tactic.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include - -#include "software/ai/hl/stp/tactic/chip/chip_fsm.h" -#include "software/ai/hl/stp/tactic/tactic_base.hpp" - -/** - * The ChipTactic will move the assigned robot to the given chip origin and then - * chip the ball to the chip target. - */ - -class ChipTactic : public TacticBase -{ - public: - /** - * Creates a new ChipTactic - * - * @param ai_config_ptr shared pointer to ai_config - */ - explicit ChipTactic(std::shared_ptr ai_config_ptr); - - /** - * Updates the params for this tactic that cannot be derived from the world - * - * @param chip_origin The location where the chip will be taken - * @param chip_direction The direction the Robot will chip in - * @param chip_distance_meters The distance between the starting location - * of the chip and the location of the first bounce - */ - void updateControlParams(const Point& chip_origin, const Angle& chip_direction, - double chip_distance_meters); - - /** - * Updates the control parameters for this ChipTactic. - * - * @param chip_origin The location where the chip will be taken - * @param chip_direction The direction the Robot will chip in - */ - void updateControlParams(const Point& chip_origin, const Point& chip_target); - - void accept(TacticVisitor& visitor) const override; -}; diff --git a/src/software/ai/hl/stp/tactic/chip/chip_tactic_test.cpp b/src/software/ai/hl/stp/tactic/chip/chip_tactic_test.cpp deleted file mode 100644 index 9d6af9b536..0000000000 --- a/src/software/ai/hl/stp/tactic/chip/chip_tactic_test.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "software/ai/hl/stp/tactic/chip/chip_tactic.h" - -#include - -#include - -#include "software/geom/algorithms/contains.h" -#include "software/simulated_tests/simulated_er_force_sim_play_test_fixture.h" -#include "software/simulated_tests/terminating_validation_functions/ball_kicked_validation.h" -#include "software/simulated_tests/terminating_validation_functions/robot_state_validation.h" -#include "software/simulated_tests/validation/validation_function.h" -#include "software/test_util/test_util.h" -#include "software/time/duration.h" -#include "software/world/world.h" - -class ChipTacticTest : public SimulatedErForceSimPlayTestFixture, - public ::testing::WithParamInterface> -{ - protected: - TbotsProto::FieldType field_type = TbotsProto::FieldType::DIV_B; - Field field = Field::createField(field_type); -}; - -TEST_P(ChipTacticTest, chip_test) -{ - Vector ball_offset_from_robot = std::get<0>(GetParam()); - Angle angle_to_kick_at = std::get<1>(GetParam()); - - Point robot_position = Point(0, 0); - BallState ball_state(robot_position + ball_offset_from_robot, Vector(0, 0)); - - auto friendly_robots = - TestUtil::createStationaryRobotStatesWithId({Point(-3, 2.5), robot_position}); - auto enemy_robots = TestUtil::createStationaryRobotStatesWithId({Point(4, 0)}); - - auto tactic = std::make_shared(std::make_shared()); - tactic->updateControlParams(robot_position + ball_offset_from_robot, angle_to_kick_at, - 5); - setTactic(1, tactic); - - std::vector terminating_validation_functions = { - [angle_to_kick_at, tactic](std::shared_ptr world_ptr, - ValidationCoroutine::push_type& yield) - { - while (!tactic->done()) - { - yield("Tactic did not complete!"); - } - ballKicked(angle_to_kick_at, world_ptr, yield); - }}; - - std::vector non_terminating_validation_functions = {}; - - runTest(field_type, ball_state, friendly_robots, enemy_robots, - terminating_validation_functions, non_terminating_validation_functions, - Duration::fromSeconds(5)); -} - -INSTANTIATE_TEST_CASE_P( - BallLocations, ChipTacticTest, - ::testing::Values( - // place the ball directly to the left of the robot - std::make_tuple(Vector(0, 0.5), Angle::zero()), - // place the ball directly to the right of the robot - std::make_tuple(Vector(0, -0.5), Angle::zero()), - // place the ball directly infront of the robot - std::make_tuple(Vector(0.5, 0), Angle::zero()), - // place the ball directly behind the robot - std::make_tuple(Vector(-0.5, 0), Angle::zero()), - // place the ball in the robots dribbler - std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero()), - // Repeat the same tests but kick in the opposite direction - // place the ball directly to the left of the robot - std::make_tuple(Vector(0, 0.5), Angle::half()), - // place the ball directly to the right of the robot - std::make_tuple(Vector(0, -0.5), Angle::half()), - // place the ball directly infront of the robot - std::make_tuple(Vector(0.5, 0), Angle::half()), - // place the ball directly behind the robot - std::make_tuple(Vector(-0.5, 0), Angle::half()), - // place the ball in the robots dribbler - std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero()))); diff --git a/src/software/ai/hl/stp/tactic/kick/BUILD b/src/software/ai/hl/stp/tactic/kick/BUILD deleted file mode 100644 index e95d29e14e..0000000000 --- a/src/software/ai/hl/stp/tactic/kick/BUILD +++ /dev/null @@ -1,43 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "kick_tactic", - srcs = [ - "kick_fsm.cpp", - "kick_tactic.cpp", - ], - hdrs = [ - "kick_fsm.h", - "kick_tactic.h", - ], - deps = [ - "//shared:constants", - "//software/ai/hl/stp/tactic", - "//software/ai/hl/stp/tactic:move_primitive", - "//software/ai/hl/stp/tactic/get_behind_ball:get_behind_ball_tactic", - "//software/logger", - ], -) - -cc_test( - name = "kick_fsm_test", - srcs = ["kick_fsm_test.cpp"], - deps = [ - ":kick_tactic", - "//shared/test_util:tbots_gtest_main", - "//software/test_util", - ], -) - -cc_test( - name = "kick_tactic_test", - srcs = ["kick_tactic_test.cpp"], - deps = [ - ":kick_tactic", - "//shared/test_util:tbots_gtest_main", - "//software/simulated_tests:simulated_er_force_sim_play_test_fixture", - "//software/simulated_tests/terminating_validation_functions", - "//software/simulated_tests/validation:validation_function", - "//software/test_util", - ], -) diff --git a/src/software/ai/hl/stp/tactic/kick/kick_fsm.cpp b/src/software/ai/hl/stp/tactic/kick/kick_fsm.cpp deleted file mode 100644 index e3094a908a..0000000000 --- a/src/software/ai/hl/stp/tactic/kick/kick_fsm.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "software/ai/hl/stp/tactic/kick/kick_fsm.h" - -#include "software/ai/hl/stp/tactic/move_primitive.h" - -KickFSM::KickFSM(std::shared_ptr ai_config_ptr) - : TacticFSM(ai_config_ptr) -{ -} - -void KickFSM::updateKick(const Update &event) -{ - Vector direction_to_kick = - Vector::createFromAngle(event.control_params.kick_direction); - Point kick_target = event.control_params.kick_origin - - direction_to_kick.normalize(DIST_TO_FRONT_OF_ROBOT_METERS - 0.01); - - event.common.set_primitive(std::make_unique( - event.common.robot, kick_target, event.control_params.kick_direction, - TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT, - TbotsProto::ObstacleAvoidanceMode::AGGRESSIVE, TbotsProto::DribblerMode::OFF, - TbotsProto::BallCollisionType::ALLOW, - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, - event.control_params.kick_speed_meters_per_second})); -} - -void KickFSM::updateGetBehindBall( - const Update &event, boost::sml::back::process processEvent) -{ - GetBehindBallFSM::ControlParams control_params{ - .ball_location = event.control_params.kick_origin, - .chick_direction = event.control_params.kick_direction}; - - // Update the get behind ball fsm - processEvent(GetBehindBallFSM::Update(control_params, event.common)); -} - -bool KickFSM::ballChicked(const Update &event) -{ - return event.common.world_ptr->ball().hasBallBeenKicked( - event.control_params.kick_direction); -} - -bool KickFSM::shouldRealignWithBall(const Update &event) -{ - const Robot &robot = event.common.robot; - - // First check to see if it's too late to realign with the ball - if (robot.isNearDribbler(event.control_params.kick_origin, 0.05)) - { - return false; - } - - // Check if the robot is already aligned to kick the ball - return !isRobotReadyToChick(robot, event.control_params.kick_origin, - event.control_params.kick_direction); -} diff --git a/src/software/ai/hl/stp/tactic/kick/kick_fsm.h b/src/software/ai/hl/stp/tactic/kick/kick_fsm.h deleted file mode 100644 index 189927938c..0000000000 --- a/src/software/ai/hl/stp/tactic/kick/kick_fsm.h +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - -#include "software/ai/hl/stp/tactic/get_behind_ball/get_behind_ball_fsm.h" -#include "software/ai/hl/stp/tactic/tactic_base.hpp" -#include "software/geom/point.h" - -/** - * Finite State Machine class for Kicks - */ -struct KickFSM : TacticFSM -{ - class KickState; - - struct ControlParams - { - // The location where the kick will be taken from - Point kick_origin; - // The direction the Robot will kick in - Angle kick_direction; - // How fast the Robot will kick the ball in meters per second - double kick_speed_meters_per_second; - }; - - using Update = TacticFSM::Update; - - /** - * Constructor for KickFSM - * - * @param ai_config_ptr shared pointer to ai_config - */ - explicit KickFSM(std::shared_ptr ai_config_ptr); - - /** - * Action that updates the MovePrimitive - * - * @param event KickFSM::Update event - */ - void updateKick(const Update &event); - - /** - * Action that updates the GetBehindBallFSM - * - * @param event KickFSM::Update event - * @param processEvent processes the GetBehindBallFSM::Update - */ - void updateGetBehindBall( - const Update &event, - boost::sml::back::process processEvent); - - /** - * Guard that checks if the ball has been chicked - * - * @param event KickFSM::Update event - * - * @return if the ball has been chicked - */ - bool ballChicked(const Update &event); - - /** - * Guard that checks if the robot is aligned for the kick - * - * @param event KickFSM::Update event - * - * @return if the robot is aligned for the kick - */ - bool shouldRealignWithBall(const Update &event); - - - auto operator()() - { - using namespace boost::sml; - - DEFINE_SML_STATE(GetBehindBallFSM) - DEFINE_SML_STATE(KickState) - DEFINE_SML_EVENT(Update) - - DEFINE_SML_GUARD(ballChicked) - DEFINE_SML_GUARD(shouldRealignWithBall) - DEFINE_SML_ACTION(updateKick) - DEFINE_SML_SUB_FSM_UPDATE_ACTION(updateGetBehindBall, GetBehindBallFSM) - - return make_transition_table( - // src_state + event [guard] / action = dest_state - *GetBehindBallFSM_S + Update_E / updateGetBehindBall_A, - GetBehindBallFSM_S = KickState_S, - - KickState_S + Update_E[shouldRealignWithBall_G] / updateGetBehindBall_A = - GetBehindBallFSM_S, - KickState_S + Update_E[!ballChicked_G] / updateKick_A = KickState_S, - KickState_S + Update_E[ballChicked_G] / SET_STOP_PRIMITIVE_ACTION = X, - X + Update_E / SET_STOP_PRIMITIVE_ACTION = X); - } -}; diff --git a/src/software/ai/hl/stp/tactic/kick/kick_fsm_test.cpp b/src/software/ai/hl/stp/tactic/kick/kick_fsm_test.cpp deleted file mode 100644 index f010696574..0000000000 --- a/src/software/ai/hl/stp/tactic/kick/kick_fsm_test.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "software/ai/hl/stp/tactic/kick/kick_fsm.h" - -#include - -#include "software/test_util/test_util.h" - -TEST(KickFSMTest, test_transitions) -{ - std::shared_ptr world = ::TestUtil::createBlankTestingWorld(); - Robot robot = ::TestUtil::createRobotAtPos(Point(-2, -3)); - KickFSM::ControlParams control_params{.kick_origin = Point(-2, 1.5), - .kick_direction = Angle::threeQuarter(), - .kick_speed_meters_per_second = 1.2}; - - FSM fsm{KickFSM(std::make_shared()), - GetBehindBallFSM(std::make_shared())}; - - // Start in GetBehindBallFSM state's GetBehindBallState - EXPECT_TRUE(fsm.is(boost::sml::state)); - EXPECT_TRUE(fsm.is)>( - boost::sml::state)); - - // Transition to GetBehindBallFSM state's GetBehindBallState - fsm.process_event(KickFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - EXPECT_TRUE(fsm.is(boost::sml::state)); - EXPECT_TRUE(fsm.is)>( - boost::sml::state)); - - // Robot is now behind ball - robot = Robot(0, - RobotState(Point(-2, 1.7), Vector(), Angle::threeQuarter(), - AngularVelocity::zero()), - Timestamp::fromSeconds(123)); - fsm.process_event(KickFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - // Transition to KickState - EXPECT_TRUE(fsm.is(boost::sml::state)); - - // Change the chip direction and expect the FSM to realign - control_params.kick_direction = Angle::quarter(); - fsm.process_event(KickFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - EXPECT_TRUE(fsm.is(boost::sml::state)); - EXPECT_TRUE(fsm.is)>( - boost::sml::state)); - - // Robot is now behind ball in the new direction - robot = Robot( - 0, - RobotState(Point(-2, 1.3), Vector(), Angle::quarter(), AngularVelocity::zero()), - Timestamp::fromSeconds(124)); - fsm.process_event(KickFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - // Transition to KickState again - EXPECT_TRUE(fsm.is(boost::sml::state)); - - // Ball is now kicked - ::TestUtil::setBallVelocity(world, Vector(0, 2.1), Timestamp::fromSeconds(123)); - - EXPECT_TRUE(world->ball().hasBallBeenKicked(Angle::quarter())); - - // Tactic is done - fsm.process_event(KickFSM::Update( - control_params, TacticUpdate(robot, world, [](std::shared_ptr) {}))); - EXPECT_TRUE(fsm.is(boost::sml::X)); -} diff --git a/src/software/ai/hl/stp/tactic/kick/kick_tactic.cpp b/src/software/ai/hl/stp/tactic/kick/kick_tactic.cpp deleted file mode 100644 index 3b5f64f4d5..0000000000 --- a/src/software/ai/hl/stp/tactic/kick/kick_tactic.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "software/ai/hl/stp/tactic/kick/kick_tactic.h" - -#include - -KickTactic::KickTactic(std::shared_ptr ai_config_ptr) - : TacticBase( - {RobotCapability::Kick, RobotCapability::Move}, ai_config_ptr) -{ -} - -void KickTactic::updateControlParams(const Point &kick_origin, - const Angle &kick_direction, - double kick_speed_meters_per_second) -{ - control_params.kick_origin = kick_origin; - control_params.kick_direction = kick_direction; - control_params.kick_speed_meters_per_second = kick_speed_meters_per_second; -} - -void KickTactic::updateControlParams(const Point &kick_origin, const Point &kick_target, - double kick_speed_meters_per_second) -{ - updateControlParams(kick_origin, (kick_target - kick_origin).orientation(), - kick_speed_meters_per_second); -} - -void KickTactic::accept(TacticVisitor &visitor) const -{ - visitor.visit(*this); -} diff --git a/src/software/ai/hl/stp/tactic/kick/kick_tactic.h b/src/software/ai/hl/stp/tactic/kick/kick_tactic.h deleted file mode 100644 index c03c769efa..0000000000 --- a/src/software/ai/hl/stp/tactic/kick/kick_tactic.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include - -#include "software/ai/hl/stp/tactic/kick/kick_fsm.h" -#include "software/ai/hl/stp/tactic/tactic_base.hpp" - -/** - * The KickTactic will move the assigned robot to the given kick origin and then - * kick the ball to the kick target. - */ - -class KickTactic : public TacticBase -{ - public: - /** - * Creates a new KickTactic - * - * @param ai_config_ptr shared pointer to ai_config - */ - explicit KickTactic(std::shared_ptr ai_config_ptr); - - /** - * Updates the params for this tactic that cannot be derived from the world - * - * @param kick_origin The location where the kick will be taken - * @param kick_direction The direction the Robot will kick in - * @param kick_speed_meters_per_second The speed of how fast the Robot - * will kick the ball in meters per second - */ - void updateControlParams(const Point& kick_origin, const Angle& kick_direction, - double kick_speed_meters_per_second); - - /** - * Updates the control parameters for this KickTactic. - * - * @param kick_origin The location where the kick will be taken - * @param kick_direction The direction the Robot will kick in - * @param kick_speed_meters_per_second The speed of how fast the Robot - * will kick the ball in meters per second - */ - void updateControlParams(const Point& kick_origin, const Point& kick_target, - double kick_speed_meters_per_second); - - void accept(TacticVisitor& visitor) const override; -}; diff --git a/src/software/ai/hl/stp/tactic/kick/kick_tactic_test.cpp b/src/software/ai/hl/stp/tactic/kick/kick_tactic_test.cpp deleted file mode 100644 index 8862d7a8f8..0000000000 --- a/src/software/ai/hl/stp/tactic/kick/kick_tactic_test.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "software/ai/hl/stp/tactic/kick/kick_tactic.h" - -#include - -#include - -#include "software/geom/algorithms/contains.h" -#include "software/simulated_tests/simulated_er_force_sim_play_test_fixture.h" -#include "software/simulated_tests/terminating_validation_functions/ball_kicked_validation.h" -#include "software/simulated_tests/terminating_validation_functions/robot_state_validation.h" -#include "software/simulated_tests/validation/validation_function.h" -#include "software/test_util/test_util.h" -#include "software/time/duration.h" -#include "software/world/world.h" - -class KickTacticTest : public SimulatedErForceSimPlayTestFixture, - public ::testing::WithParamInterface> -{ - protected: - TbotsProto::FieldType field_type = TbotsProto::FieldType::DIV_B; - Field field = Field::createField(field_type); -}; - -TEST_P(KickTacticTest, kick_test) -{ - Vector ball_offset_from_robot = std::get<0>(GetParam()); - Angle angle_to_kick_at = std::get<1>(GetParam()); - - Point robot_position = Point(0, 0); - BallState ball_state(robot_position + ball_offset_from_robot, Vector(0, 0)); - - auto friendly_robots = - TestUtil::createStationaryRobotStatesWithId({Point(-3, 2.5), robot_position}); - auto enemy_robots = TestUtil::createStationaryRobotStatesWithId({Point(4, 0)}); - - auto tactic = std::make_shared(std::make_shared()); - tactic->updateControlParams(robot_position + ball_offset_from_robot, angle_to_kick_at, - 5); - setTactic(1, tactic); - - std::vector terminating_validation_functions = { - [angle_to_kick_at, tactic](std::shared_ptr world_ptr, - ValidationCoroutine::push_type& yield) - { - while (!tactic->done()) - { - yield("Tactic did not complete!"); - } - ballKicked(angle_to_kick_at, world_ptr, yield); - }}; - - std::vector non_terminating_validation_functions = {}; - - runTest(field_type, ball_state, friendly_robots, enemy_robots, - terminating_validation_functions, non_terminating_validation_functions, - Duration::fromSeconds(5)); -} - -INSTANTIATE_TEST_CASE_P( - BallLocations, KickTacticTest, - ::testing::Values( - // place the ball directly to the left of the robot - std::make_tuple(Vector(0, 0.5), Angle::zero()), - // place the ball directly to the right of the robot - std::make_tuple(Vector(0, -0.5), Angle::zero()), - // place the ball directly infront of the robot - std::make_tuple(Vector(0.5, 0), Angle::zero()), - // place the ball directly behind the robot - std::make_tuple(Vector(-0.5, 0), Angle::zero()), - // place the ball in the robots dribbler - std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero()), - // Repeat the same tests but kick in the opposite direction - // place the ball directly to the left of the robot - std::make_tuple(Vector(0, 0.5), Angle::half()), - // place the ball directly to the right of the robot - std::make_tuple(Vector(0, -0.5), Angle::half()), - // place the ball directly infront of the robot - std::make_tuple(Vector(0.5, 0), Angle::half()), - // place the ball directly behind the robot - std::make_tuple(Vector(-0.5, 0), Angle::half()), - // place the ball in the robots dribbler - std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero()))); diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.cpp b/src/software/ai/hl/stp/tactic/tactic_factory.cpp index ffaf3498c7..4d5c580776 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.cpp +++ b/src/software/ai/hl/stp/tactic/tactic_factory.cpp @@ -17,12 +17,10 @@ std::shared_ptr createTactic( switch (tactic_proto.tactic_case()) { PROTO_CREATE_TACTIC_CASE(Attacker, attacker) - PROTO_CREATE_TACTIC_CASE(Chip, chip) PROTO_CREATE_TACTIC_CASE(CreaseDefender, crease_defender) PROTO_CREATE_TACTIC_CASE(Dribble, dribble) PROTO_CREATE_TACTIC_CASE(GetBehindBall, get_behind_ball) PROTO_CREATE_TACTIC_CASE(Goalie, goalie) - PROTO_CREATE_TACTIC_CASE(Kick, kick) PROTO_CREATE_TACTIC_CASE(KickOrChip, kick_or_chip) PROTO_CREATE_TACTIC_CASE(MoveGoalieToGoalLine, move_goalie_to_goal_line) PROTO_CREATE_TACTIC_CASE(Move, move) @@ -60,17 +58,6 @@ std::shared_ptr createTactic( return tactic; } -std::shared_ptr createTactic( - const TbotsProto::ChipTactic &tactic_proto, - std::shared_ptr ai_config_ptr) -{ - auto tactic = std::make_shared(ai_config_ptr); - tactic->updateControlParams(createPoint(tactic_proto.chip_origin()), - createAngle(tactic_proto.chip_direction()), - tactic_proto.chip_distance_meters()); - return tactic; -} - std::shared_ptr createTactic( const TbotsProto::CreaseDefenderTactic &tactic_proto, std::shared_ptr ai_config_ptr) @@ -125,17 +112,6 @@ std::shared_ptr createTactic( return tactic; } -std::shared_ptr createTactic( - const TbotsProto::KickTactic &tactic_proto, - std::shared_ptr ai_config_ptr) -{ - auto tactic = std::make_shared(ai_config_ptr); - tactic->updateControlParams(createPoint(tactic_proto.kick_origin()), - createAngle(tactic_proto.kick_direction()), - tactic_proto.kick_speed_meters_per_second()); - return tactic; -} - std::shared_ptr createTactic( const TbotsProto::KickOrChipTactic &tactic_proto, std::shared_ptr ai_config_ptr) diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.h b/src/software/ai/hl/stp/tactic/tactic_factory.h index 2cda5033ab..5104cbd645 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.h +++ b/src/software/ai/hl/stp/tactic/tactic_factory.h @@ -17,9 +17,6 @@ std::shared_ptr createTactic( std::shared_ptr createTactic( const TbotsProto::AttackerTactic &tactic_proto, std::shared_ptr ai_config_ptr); -std::shared_ptr createTactic( - const TbotsProto::ChipTactic &tactic_proto, - std::shared_ptr ai_config_ptr); std::shared_ptr createTactic( const TbotsProto::CreaseDefenderTactic &tactic_proto, std::shared_ptr ai_config_ptr); @@ -32,9 +29,6 @@ std::shared_ptr createTactic( std::shared_ptr createTactic( const TbotsProto::GoalieTactic &tactic_proto, std::shared_ptr ai_config_ptr); -std::shared_ptr createTactic( - const TbotsProto::KickTactic &tactic_proto, - std::shared_ptr ai_config_ptr); std::shared_ptr createTactic( const TbotsProto::KickOrChipTactic &tactic_proto, std::shared_ptr ai_config_ptr); diff --git a/src/software/ai/hl/stp/tactic/tactic_visitor.h b/src/software/ai/hl/stp/tactic/tactic_visitor.h index f461bfcfbf..69d9db7f0e 100644 --- a/src/software/ai/hl/stp/tactic/tactic_visitor.h +++ b/src/software/ai/hl/stp/tactic/tactic_visitor.h @@ -5,14 +5,12 @@ // because tactic.h includes tactic_visitor.h, and each individual library includes // tactic.h. Note: every subclass of this visitor must include all of the classes listed // below -class ChipTactic; class CreaseDefenderTactic; class DefenseShadowEnemyTactic; class DribbleTactic; class GetBehindBallTactic; class GoalieTactic; class GoalieTestTactic; -class KickTactic; class KickoffChipTactic; class MoveTactic; class MoveTestTactic; @@ -48,14 +46,12 @@ class TacticVisitor * @param tactic The tactic to visit */ - virtual void visit(const ChipTactic &tactic) = 0; virtual void visit(const CreaseDefenderTactic &tactic) = 0; virtual void visit(const DefenseShadowEnemyTactic &tactic) = 0; virtual void visit(const DribbleTactic &tactic) = 0; virtual void visit(const GetBehindBallTactic &tactic) = 0; virtual void visit(const GoalieTactic &tactic) = 0; virtual void visit(const GoalieTestTactic &tactic) = 0; - virtual void visit(const KickTactic &tactic) = 0; virtual void visit(const KickoffChipTactic &tactic) = 0; virtual void visit(const MoveTactic &tactic) = 0; virtual void visit(const MoveTestTactic &tactic) = 0; diff --git a/src/software/ai/motion_constraint/motion_constraint_set_builder_test.cpp b/src/software/ai/motion_constraint/motion_constraint_set_builder_test.cpp index 5f3af9f614..f2e2f32d75 100644 --- a/src/software/ai/motion_constraint/motion_constraint_set_builder_test.cpp +++ b/src/software/ai/motion_constraint/motion_constraint_set_builder_test.cpp @@ -34,7 +34,7 @@ std::vector, std::set()), - std::make_tuple(std::make_shared(ai_config_ptr), + std::make_tuple(std::make_shared(ai_config_ptr), std::set(), std::set()), std::make_tuple( diff --git a/src/software/ai/motion_constraint/motion_constraint_visitor.cpp b/src/software/ai/motion_constraint/motion_constraint_visitor.cpp index 8636c89fee..573d695cd7 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.cpp +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.cpp @@ -20,10 +20,6 @@ void MotionConstraintVisitor::visit(const ShadowEnemyTactic &tactic) {} void MotionConstraintVisitor::visit(const MoveTactic &tactic) {} -void MotionConstraintVisitor::visit(const ChipTactic &tactic) {} - -void MotionConstraintVisitor::visit(const KickTactic &tactic) {} - void MotionConstraintVisitor::visit(const PivotKickTactic &tactic) {} void MotionConstraintVisitor::visit(const KickoffChipTactic &tactic) diff --git a/src/software/ai/motion_constraint/motion_constraint_visitor.h b/src/software/ai/motion_constraint/motion_constraint_visitor.h index ee92df124a..25ea8cfdd8 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.h +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.h @@ -23,8 +23,6 @@ class MotionConstraintVisitor : public TacticVisitor void visit(const CreaseDefenderTactic &tactic) override; void visit(const ShadowEnemyTactic &tactic) override; void visit(const MoveTactic &tactic) override; - void visit(const ChipTactic &tactic) override; - void visit(const KickTactic &tactic) override; void visit(const KickoffChipTactic &tactic) override; void visit(const HaltTactic &tactic) override; void visit(const PenaltyKickTactic &tactic) override; From 2f3cb935b8620a5c63a980467258ae77e16fbf86 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Mon, 9 Mar 2026 19:52:28 -0700 Subject: [PATCH 14/24] update potos --- src/proto/tactic.proto | 61 ++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) diff --git a/src/proto/tactic.proto b/src/proto/tactic.proto index dc93ff51ff..95261c9561 100644 --- a/src/proto/tactic.proto +++ b/src/proto/tactic.proto @@ -16,21 +16,19 @@ message Tactic oneof tactic { AttackerTactic attacker = 1; - ChipTactic chip = 2; - CreaseDefenderTactic crease_defender = 3; - DribbleTactic dribble = 4; - GetBehindBallTactic get_behind_ball = 5; - GoalieTactic goalie = 6; - KickTactic kick = 7; - MoveGoalieToGoalLineTactic move_goalie_to_goal_line = 8; - MoveTactic move = 9; - PenaltyKickTactic penalty_kick = 10; - PivotKickTactic pivot_kick = 11; - ReceiverTactic receiver = 12; - ShadowEnemyTactic shadow_enemy = 13; - HaltTactic halt = 14; - PassDefenderTactic pass_defender = 15; - KickOrChipTactic kick_or_chip = 16; + CreaseDefenderTactic crease_defender = 2; + DribbleTactic dribble = 3; + GetBehindBallTactic get_behind_ball = 4; + GoalieTactic goalie = 5; + KickOrChipTactic kick_or_chip = 6; + MoveGoalieToGoalLineTactic move_goalie_to_goal_line = 7; + MoveTactic move = 8; + PenaltyKickTactic penalty_kick = 9; + PivotKickTactic pivot_kick = 10; + ReceiverTactic receiver = 11; + ShadowEnemyTactic shadow_enemy = 12; + HaltTactic halt = 13; + PassDefenderTactic pass_defender = 14; } } @@ -45,16 +43,6 @@ message AttackerTactic optional Point chip_target = 3; } -message ChipTactic -{ - // The location where the chip will be taken from - required Point chip_origin = 1; - // The direction the Robot will chip in - required Angle chip_direction = 2; - // The distance the robot will chip to - required double chip_distance_meters = 3; -} - enum CreaseDefenderAlignment { LEFT = 0; @@ -107,14 +95,14 @@ message GoalieTactic required MaxAllowedSpeedMode max_allowed_speed_mode = 1; } -message KickTactic +message KickOrChipTactic { - // The location where the kick will be taken from - required Point kick_origin = 1; - // The direction the Robot will kick in - required Angle kick_direction = 2; - // How fast the Robot will kick the ball in meters per second - required double kick_speed_meters_per_second = 3; + // The location where the kick or chip will be taken from + required Point kick_or_chip_origin = 1; + // The direction the Robot will kick or chip in + required Angle kick_or_chip_direction = 2; + // How the robot will chip or kick the ball + required AutoChipOrKick auto_chip_or_kick = 3; } message MoveGoalieToGoalLineTactic {} @@ -179,12 +167,3 @@ message ShadowEnemyTactic message HaltTactic {} -message KickOrChipTactic -{ - // The location where the kick or chip will be taken from - required Point kick_or_chip_origin = 1; - // The direction the Robot will kick or chip in - required Angle kick_or_chip_direction = 2; - // How the robot will chip or kick the ball - required AutoChipOrKick auto_chip_or_kick = 3; -} From 0577bce75d888e25431d3e700203bf3505dda46a Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Mon, 9 Mar 2026 20:10:26 -0700 Subject: [PATCH 15/24] fix free kick play --- .../ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp index 38f3af2349..5380f26705 100644 --- a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp @@ -289,11 +289,13 @@ void FreeKickPlayFSM::passBall(const Update &event) PriorityTacticVector tactics_to_run = {{}}; Pass pass = best_pass_and_score_so_far.pass; + LOG(INFO) << "looking for pass" << pass.speed() <updateControlParams( pass.passerPoint(), pass.passerOrientation(), - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, pass.speed()}); - receiver_tactic->updateControlParams(pass); + auto_chip_or_kick); + receiver_tactic->updateControlParams(pass); tactics_to_run[0].emplace_back(passer_tactic); tactics_to_run[0].emplace_back(receiver_tactic); From 927cbc4956922b4068b2f9a0ec4563d89f881c34 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Mon, 9 Mar 2026 20:14:20 -0700 Subject: [PATCH 16/24] change old protos to reserved --- src/proto/tactic.proto | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/proto/tactic.proto b/src/proto/tactic.proto index 95261c9561..58c5ab9964 100644 --- a/src/proto/tactic.proto +++ b/src/proto/tactic.proto @@ -15,20 +15,21 @@ message Tactic { oneof tactic { + reserved 2, 7; AttackerTactic attacker = 1; - CreaseDefenderTactic crease_defender = 2; - DribbleTactic dribble = 3; - GetBehindBallTactic get_behind_ball = 4; - GoalieTactic goalie = 5; - KickOrChipTactic kick_or_chip = 6; - MoveGoalieToGoalLineTactic move_goalie_to_goal_line = 7; - MoveTactic move = 8; - PenaltyKickTactic penalty_kick = 9; - PivotKickTactic pivot_kick = 10; - ReceiverTactic receiver = 11; - ShadowEnemyTactic shadow_enemy = 12; - HaltTactic halt = 13; - PassDefenderTactic pass_defender = 14; + CreaseDefenderTactic crease_defender = 3; + DribbleTactic dribble = 4; + GetBehindBallTactic get_behind_ball = 5; + GoalieTactic goalie = 6; + MoveGoalieToGoalLineTactic move_goalie_to_goal_line = 8; + MoveTactic move = 9; + PenaltyKickTactic penalty_kick = 10; + PivotKickTactic pivot_kick = 11; + ReceiverTactic receiver = 12; + ShadowEnemyTactic shadow_enemy = 13; + HaltTactic halt = 14; + PassDefenderTactic pass_defender = 15; + KickOrChipTactic kick_or_chip = 16; } } @@ -95,16 +96,6 @@ message GoalieTactic required MaxAllowedSpeedMode max_allowed_speed_mode = 1; } -message KickOrChipTactic -{ - // The location where the kick or chip will be taken from - required Point kick_or_chip_origin = 1; - // The direction the Robot will kick or chip in - required Angle kick_or_chip_direction = 2; - // How the robot will chip or kick the ball - required AutoChipOrKick auto_chip_or_kick = 3; -} - message MoveGoalieToGoalLineTactic {} message MoveTactic @@ -167,3 +158,12 @@ message ShadowEnemyTactic message HaltTactic {} +message KickOrChipTactic +{ + // The location where the kick or chip will be taken from + required Point kick_or_chip_origin = 1; + // The direction the Robot will kick or chip in + required Angle kick_or_chip_direction = 2; + // How the robot will chip or kick the ball + required AutoChipOrKick auto_chip_or_kick = 3; +} From abe1ecf56e3d621a996949b126002f1d5fb975e2 Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Mon, 9 Mar 2026 20:19:59 -0700 Subject: [PATCH 17/24] fix proto issues: --- src/proto/tactic.proto | 2 +- src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/proto/tactic.proto b/src/proto/tactic.proto index 58c5ab9964..b964eb9209 100644 --- a/src/proto/tactic.proto +++ b/src/proto/tactic.proto @@ -13,9 +13,9 @@ message AssignedTacticPlayControlParams message Tactic { + reserved 2, 7; oneof tactic { - reserved 2, 7; AttackerTactic attacker = 1; CreaseDefenderTactic crease_defender = 3; DribbleTactic dribble = 4; diff --git a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp index 5380f26705..9c251b2a48 100644 --- a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp @@ -289,7 +289,6 @@ void FreeKickPlayFSM::passBall(const Update &event) PriorityTacticVector tactics_to_run = {{}}; Pass pass = best_pass_and_score_so_far.pass; - LOG(INFO) << "looking for pass" << pass.speed() <updateControlParams( From 7fb156e5123b2e139b89eabe536fdf988e577abd Mon Sep 17 00:00:00 2001 From: Samuel <92961466+StarrryNight@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:18:16 -0700 Subject: [PATCH 18/24] Remove ChipTactic and KickTactic messages Removed ChipTactic and KickTactic messages from tactic.proto. Added reserved fields for identifiers 2 and 7. --- src/proto/tactic.proto | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/proto/tactic.proto b/src/proto/tactic.proto index dc93ff51ff..54190d06dd 100644 --- a/src/proto/tactic.proto +++ b/src/proto/tactic.proto @@ -13,15 +13,14 @@ message AssignedTacticPlayControlParams message Tactic { + reserved 2,7; oneof tactic { AttackerTactic attacker = 1; - ChipTactic chip = 2; CreaseDefenderTactic crease_defender = 3; DribbleTactic dribble = 4; GetBehindBallTactic get_behind_ball = 5; GoalieTactic goalie = 6; - KickTactic kick = 7; MoveGoalieToGoalLineTactic move_goalie_to_goal_line = 8; MoveTactic move = 9; PenaltyKickTactic penalty_kick = 10; @@ -45,16 +44,6 @@ message AttackerTactic optional Point chip_target = 3; } -message ChipTactic -{ - // The location where the chip will be taken from - required Point chip_origin = 1; - // The direction the Robot will chip in - required Angle chip_direction = 2; - // The distance the robot will chip to - required double chip_distance_meters = 3; -} - enum CreaseDefenderAlignment { LEFT = 0; @@ -107,16 +96,6 @@ message GoalieTactic required MaxAllowedSpeedMode max_allowed_speed_mode = 1; } -message KickTactic -{ - // The location where the kick will be taken from - required Point kick_origin = 1; - // The direction the Robot will kick in - required Angle kick_direction = 2; - // How fast the Robot will kick the ball in meters per second - required double kick_speed_meters_per_second = 3; -} - message MoveGoalieToGoalLineTactic {} message MoveTactic From 128f186c666f62f6145c8504310801997b32193f Mon Sep 17 00:00:00 2001 From: Thunderbots Date: Wed, 11 Mar 2026 20:41:24 -0700 Subject: [PATCH 19/24] changed passing sim test and passing field test --- .../ai/hl/stp/play/passing_sim_test.py | 22 ++++++++++++------- .../field_tests/passing_field_test.py | 20 +++++++++++------ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/software/ai/hl/stp/play/passing_sim_test.py b/src/software/ai/hl/stp/play/passing_sim_test.py index b3821d363f..fbe186b988 100644 --- a/src/software/ai/hl/stp/play/passing_sim_test.py +++ b/src/software/ai/hl/stp/play/passing_sim_test.py @@ -100,7 +100,8 @@ def setup_pass_and_robots( # this improves the passes generated over time robots_to_ignore = [0] # Avoid sampling passes around the attacker robot for index in range(0, 100): - best_pass_with_score = pass_generator.getBestPass(world, robots_to_ignore) + best_pass_with_score = pass_generator.getBestPass( + world, robots_to_ignore) best_pass = best_pass_with_score.pass_value kick_vec = best_pass.receiverPoint() - best_pass.passerPoint() @@ -109,14 +110,17 @@ def setup_pass_and_robots( # We use KickTactic since AttackerTactic shoots towards the goal instead if open # KickTactic just does the kick we want params = AssignedTacticPlayControlParams() - params.assigned_tactics[0].kick.CopyFrom( - KickTactic( - kick_origin=Point( + params.assigned_tactics[0].kick_or_chip.CopyFrom( + KickOrChipTactic( + kick_or_chip_origin=Point( x_meters=best_pass.passerPoint().x(), y_meters=best_pass.passerPoint().y(), ), - kick_direction=Angle(radians=kick_vec.orientation().toRadians()), - kick_speed_meters_per_second=best_pass.speed(), + kick_or_chip_direction=Angle( + radians=kick_vec.orientation().toRadians()), + auto_chip_or_kick=AutoChipOrKick( + autokick_speed_m_per_s=best_pass.speed(), + ) ) ) @@ -138,7 +142,8 @@ def setup_pass_and_robots( "disable_one_touch_shot": True, } - params.assigned_tactics[1].receiver.CopyFrom(ReceiverTactic(**receiver_args)) + params.assigned_tactics[1].receiver.CopyFrom( + ReceiverTactic(**receiver_args)) simulated_test_runner.set_tactics(params, True) # Setup no tactics on the enemy side @@ -377,7 +382,8 @@ def test_passing_no_backwards_passes( initial_ball_position=ball_initial_position, regions=[ tbots_cpp.Rectangle( - tbots_cpp.Point(-field.xLength() / 2, field.yLength() / 2), + tbots_cpp.Point(-field.xLength() / 2, + field.yLength() / 2), tbots_cpp.Point(0 - buffer_x, -field.yLength() / 2), ) ], diff --git a/src/software/field_tests/passing_field_test.py b/src/software/field_tests/passing_field_test.py index 9899c6b63a..abbd26bb4a 100644 --- a/src/software/field_tests/passing_field_test.py +++ b/src/software/field_tests/passing_field_test.py @@ -14,12 +14,15 @@ def test_passing(field_test_runner): receiver_robot_id = 5 should_receive_pass = True - world = field_test_runner.world_buffer.get(block=True, timeout=WORLD_BUFFER_TIMEOUT) - passer_point = tbots_cpp.createPoint(world.ball.current_state.global_position) + world = field_test_runner.world_buffer.get( + block=True, timeout=WORLD_BUFFER_TIMEOUT) + passer_point = tbots_cpp.createPoint( + world.ball.current_state.global_position) receiver_point = None for robot in world.friendly_team.team_robots: if robot.id == receiver_robot_id: - receiver_point = tbots_cpp.createPoint(robot.current_state.global_position) + receiver_point = tbots_cpp.createPoint( + robot.current_state.global_position) receive_speed_m_per_s = 2.0 min_pass_speed_m_per_s = 1.0 @@ -42,14 +45,17 @@ def test_passing(field_test_runner): # We use KickTactic since AttackerTactic shoots towards the goal instead if open # KickTactic just does the kick we want params = AssignedTacticPlayControlParams() - params.assigned_tactics[passer_robot_id].kick.CopyFrom( + params.assigned_tactics[passer_robot_id].kick_or_chip.CopyFrom( KickTactic( - kick_origin=Point( + kick_or_chip_origin=Point( x_meters=pass_to_test.passerPoint().x(), y_meters=pass_to_test.passerPoint().y(), ), - kick_direction=Angle(radians=kick_vec.orientation().toRadians()), - kick_speed_meters_per_second=pass_to_test.speed(), + kick_or_chip_direction=Angle( + radians=kick_vec.orientation().toRadians()), + auto_chip_or_kick=AutoChipOrKick( + autokick_speed_m_per_s=pass_to_test.speed(), + ) ) ) From a1b80672752e4eed90f3bcd92af9f92cbccf6729 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Thu, 12 Mar 2026 03:47:58 +0000 Subject: [PATCH 20/24] [pre-commit.ci lite] apply automatic fixes --- docs/fsm-diagrams.md | 34 ------------- src/proto/tactic.proto | 4 +- .../ai/hl/stp/play/kickoff_friendly_play.cpp | 15 +++--- .../ai/hl/stp/play/passing_sim_test.py | 14 ++---- .../ai/hl/stp/tactic/kick_or_chip/BUILD | 1 - .../kick_or_chip/kick_or_chip_tactic_test.cpp | 50 +++++++++---------- .../field_tests/passing_field_test.py | 14 ++---- 7 files changed, 44 insertions(+), 88 deletions(-) diff --git a/docs/fsm-diagrams.md b/docs/fsm-diagrams.md index eeeb2ea148..ece828b30a 100644 --- a/docs/fsm-diagrams.md +++ b/docs/fsm-diagrams.md @@ -244,23 +244,6 @@ Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION GetBehindBallFSM -GetBehindBallFSM --> GetBehindBallFSM : updateGetBehindBall -GetBehindBallFSM --> ChipState -ChipState --> GetBehindBallFSM : [shouldRealignWithBall]\nupdateGetBehindBall -ChipState --> ChipState : [!ballChicked]\nupdateChip -ChipState --> Terminate:::terminate : [ballChicked]\nSET_STOP_PRIMITIVE_ACTION -Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION - -``` - ## [CreaseDefenderFSM](/src/software/ai/hl/stp/tactic/crease_defender/crease_defender_fsm.h) ```mermaid @@ -375,23 +358,6 @@ Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION GetBehindBallFSM -GetBehindBallFSM --> GetBehindBallFSM : updateGetBehindBall -GetBehindBallFSM --> KickState -KickState --> GetBehindBallFSM : [shouldRealignWithBall]\nupdateGetBehindBall -KickState --> KickState : [!ballChicked]\nupdateKick -KickState --> Terminate:::terminate : [ballChicked]\nSET_STOP_PRIMITIVE_ACTION -Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION - -``` - ## [KickOrChipFSM](/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h) ```mermaid diff --git a/src/proto/tactic.proto b/src/proto/tactic.proto index 54190d06dd..208cdb4f1e 100644 --- a/src/proto/tactic.proto +++ b/src/proto/tactic.proto @@ -13,7 +13,7 @@ message AssignedTacticPlayControlParams message Tactic { - reserved 2,7; + reserved 2, 7; oneof tactic { AttackerTactic attacker = 1; @@ -161,7 +161,7 @@ message HaltTactic {} message KickOrChipTactic { // The location where the kick or chip will be taken from - required Point kick_or_chip_origin = 1; + required Point kick_or_chip_origin = 1; // The direction the Robot will kick or chip in required Angle kick_or_chip_direction = 2; // How the robot will chip or kick the ball diff --git a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp index 46e5abaa0e..439c64110d 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp +++ b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp @@ -116,14 +116,13 @@ void KickoffFriendlyPlay::getNextTactics(TacticCoroutine::push_type &yield, // TODO (#2612): This needs to be adjusted post field testing, ball needs to land // exactly in the middle of the enemy field - Point ball_position = world_ptr->ball().position(); - Point kick_target = world_ptr->field().centerPoint() + - Vector(world_ptr->field().xLength() / 6, 0); - AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, (kick_target - ball_position).length()}; - kickoff_chip_tactic->updateControlParams( - ball_position, - kick_target, - auto_chip_or_kick); + Point ball_position = world_ptr->ball().position(); + Point kick_target = world_ptr->field().centerPoint() + + Vector(world_ptr->field().xLength() / 6, 0); + AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOCHIP, + (kick_target - ball_position).length()}; + kickoff_chip_tactic->updateControlParams(ball_position, kick_target, + auto_chip_or_kick); result[0].emplace_back(kickoff_chip_tactic); // the robot at position 0 will be closest to the ball, so positions starting from diff --git a/src/software/ai/hl/stp/play/passing_sim_test.py b/src/software/ai/hl/stp/play/passing_sim_test.py index fbe186b988..e7c299a3d4 100644 --- a/src/software/ai/hl/stp/play/passing_sim_test.py +++ b/src/software/ai/hl/stp/play/passing_sim_test.py @@ -100,8 +100,7 @@ def setup_pass_and_robots( # this improves the passes generated over time robots_to_ignore = [0] # Avoid sampling passes around the attacker robot for index in range(0, 100): - best_pass_with_score = pass_generator.getBestPass( - world, robots_to_ignore) + best_pass_with_score = pass_generator.getBestPass(world, robots_to_ignore) best_pass = best_pass_with_score.pass_value kick_vec = best_pass.receiverPoint() - best_pass.passerPoint() @@ -116,11 +115,10 @@ def setup_pass_and_robots( x_meters=best_pass.passerPoint().x(), y_meters=best_pass.passerPoint().y(), ), - kick_or_chip_direction=Angle( - radians=kick_vec.orientation().toRadians()), + kick_or_chip_direction=Angle(radians=kick_vec.orientation().toRadians()), auto_chip_or_kick=AutoChipOrKick( autokick_speed_m_per_s=best_pass.speed(), - ) + ), ) ) @@ -142,8 +140,7 @@ def setup_pass_and_robots( "disable_one_touch_shot": True, } - params.assigned_tactics[1].receiver.CopyFrom( - ReceiverTactic(**receiver_args)) + params.assigned_tactics[1].receiver.CopyFrom(ReceiverTactic(**receiver_args)) simulated_test_runner.set_tactics(params, True) # Setup no tactics on the enemy side @@ -382,8 +379,7 @@ def test_passing_no_backwards_passes( initial_ball_position=ball_initial_position, regions=[ tbots_cpp.Rectangle( - tbots_cpp.Point(-field.xLength() / 2, - field.yLength() / 2), + tbots_cpp.Point(-field.xLength() / 2, field.yLength() / 2), tbots_cpp.Point(0 - buffer_x, -field.yLength() / 2), ) ], diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD index 102b177bdf..af69044e13 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/BUILD @@ -44,4 +44,3 @@ cc_test( "//software/test_util", ], ) - diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic_test.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic_test.cpp index 6a869685d5..cc2f7cc5e2 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic_test.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic_test.cpp @@ -24,9 +24,9 @@ class KickOrChipTacticTest TEST_P(KickOrChipTacticTest, kick_or_chip_test) { - Vector ball_offset_from_robot = std::get<0>(GetParam()); - Angle angle_to_kick_at = std::get<1>(GetParam()); - AutoChipOrKick auto_chip_or_kick = std::get<2>(GetParam()); + Vector ball_offset_from_robot = std::get<0>(GetParam()); + Angle angle_to_kick_at = std::get<1>(GetParam()); + AutoChipOrKick auto_chip_or_kick = std::get<2>(GetParam()); Point robot_position = Point(0, 0); BallState ball_state(robot_position + ball_offset_from_robot, Vector(0, 0)); @@ -61,28 +61,28 @@ TEST_P(KickOrChipTacticTest, kick_or_chip_test) INSTANTIATE_TEST_CASE_P( AutokickBallLocations, KickOrChipTacticTest, - ::testing::Values( - std::make_tuple(Vector(0, 0.5), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), - std::make_tuple(Vector(0, -0.5), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), - std::make_tuple(Vector(0.5, 0), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), - std::make_tuple(Vector(-0.5, 0), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), - std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}))); + ::testing::Values(std::make_tuple(Vector(0, 0.5), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), + std::make_tuple(Vector(0, -0.5), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), + std::make_tuple(Vector(0.5, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), + std::make_tuple(Vector(-0.5, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, 5.0}), + std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOKICK, + 5.0}))); INSTANTIATE_TEST_CASE_P( AutochipBallLocations, KickOrChipTacticTest, - ::testing::Values( - std::make_tuple(Vector(0, 0.5), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), - std::make_tuple(Vector(0, -0.5), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), - std::make_tuple(Vector(0.5, 0), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), - std::make_tuple(Vector(-0.5, 0), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), - std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero(), - AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}))); + ::testing::Values(std::make_tuple(Vector(0, 0.5), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), + std::make_tuple(Vector(0, -0.5), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), + std::make_tuple(Vector(0.5, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), + std::make_tuple(Vector(-0.5, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, 2.0}), + std::make_tuple(Vector(ROBOT_MAX_RADIUS_METERS, 0), Angle::zero(), + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, + 2.0}))); diff --git a/src/software/field_tests/passing_field_test.py b/src/software/field_tests/passing_field_test.py index abbd26bb4a..b65f45cc13 100644 --- a/src/software/field_tests/passing_field_test.py +++ b/src/software/field_tests/passing_field_test.py @@ -14,15 +14,12 @@ def test_passing(field_test_runner): receiver_robot_id = 5 should_receive_pass = True - world = field_test_runner.world_buffer.get( - block=True, timeout=WORLD_BUFFER_TIMEOUT) - passer_point = tbots_cpp.createPoint( - world.ball.current_state.global_position) + world = field_test_runner.world_buffer.get(block=True, timeout=WORLD_BUFFER_TIMEOUT) + passer_point = tbots_cpp.createPoint(world.ball.current_state.global_position) receiver_point = None for robot in world.friendly_team.team_robots: if robot.id == receiver_robot_id: - receiver_point = tbots_cpp.createPoint( - robot.current_state.global_position) + receiver_point = tbots_cpp.createPoint(robot.current_state.global_position) receive_speed_m_per_s = 2.0 min_pass_speed_m_per_s = 1.0 @@ -51,11 +48,10 @@ def test_passing(field_test_runner): x_meters=pass_to_test.passerPoint().x(), y_meters=pass_to_test.passerPoint().y(), ), - kick_or_chip_direction=Angle( - radians=kick_vec.orientation().toRadians()), + kick_or_chip_direction=Angle(radians=kick_vec.orientation().toRadians()), auto_chip_or_kick=AutoChipOrKick( autokick_speed_m_per_s=pass_to_test.speed(), - ) + ), ) ) From d44d75d61a1e26a5c9d174cf0bcf2218dc501c96 Mon Sep 17 00:00:00 2001 From: StarrryNight <92961466+StarrryNight@users.noreply.github.com> Date: Tue, 7 Apr 2026 15:02:06 -0700 Subject: [PATCH 21/24] fix merge error --- src/software/ai/hl/stp/play/BUILD | 61 ------------------------------- 1 file changed, 61 deletions(-) diff --git a/src/software/ai/hl/stp/play/BUILD b/src/software/ai/hl/stp/play/BUILD index 5b3f6e555a..8cef5ab8d7 100644 --- a/src/software/ai/hl/stp/play/BUILD +++ b/src/software/ai/hl/stp/play/BUILD @@ -7,67 +7,6 @@ package(default_visibility = ["//visibility:public"]) # https://www.bfilipek.com/2018/02/static-vars-static-lib.html cc_library( -<<<<<<< HEAD - name = "kickoff_enemy_play", - srcs = ["kickoff_enemy_play.cpp"], - hdrs = ["kickoff_enemy_play.h"], - deps = [ - ":play", - "//shared:constants", - "//software/ai/evaluation:enemy_threat", - "//software/ai/evaluation:possession", - "//software/ai/hl/stp/tactic/goalie:goalie_tactic", - "//software/ai/hl/stp/tactic/move:move_tactic", - "//software/ai/hl/stp/tactic/shadow_enemy:shadow_enemy_tactic", - "//software/logger", - "//software/util/generic_factory", - ], - alwayslink = True, -) - -cc_library( - name = "kickoff_friendly_play", - srcs = ["kickoff_friendly_play.cpp"], - hdrs = ["kickoff_friendly_play.h"], - deps = [ - ":play", - "//shared:constants", - "//software/ai/evaluation:enemy_threat", - "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", - "//software/ai/hl/stp/tactic/move:move_tactic", - "//software/logger", - "//software/util/generic_factory", - ], - alwayslink = True, -) - -cc_library( - name = "shoot_or_chip_play", - srcs = ["shoot_or_chip_play.cpp"], - hdrs = ["shoot_or_chip_play.h"], - deps = [ - ":play", - "//proto/message_translation:tbots_protobuf", - "//shared:constants", - "//software/ai/evaluation:enemy_threat", - "//software/ai/evaluation:find_open_areas", - "//software/ai/evaluation:possession", - "//software/ai/hl/stp/tactic/attacker:attacker_tactic", - "//software/ai/hl/stp/tactic/crease_defender:crease_defender_tactic", - "//software/ai/hl/stp/tactic/goalie:goalie_tactic", - "//software/ai/hl/stp/tactic/halt:halt_tactic", - "//software/ai/hl/stp/tactic/move:move_tactic", - "//software/ai/hl/stp/tactic/shadow_enemy:shadow_enemy_tactic", - "//software/logger", - "//software/util/generic_factory", - "//software/world:game_state", - ], - alwayslink = True, -) - -cc_library( -======= ->>>>>>> master name = "stop_play", srcs = [ "stop_play.cpp", From 570e3718fe915ef098a4fde9941c535af8ac220c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 7 Apr 2026 22:07:29 +0000 Subject: [PATCH 22/24] [pre-commit.ci lite] apply automatic fixes --- .../ai/hl/stp/play/passing_sim_test.py | 19 +++++++++---------- .../field_tests/passing_field_test.py | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/software/ai/hl/stp/play/passing_sim_test.py b/src/software/ai/hl/stp/play/passing_sim_test.py index a2c00b41c2..d9dad5c17c 100644 --- a/src/software/ai/hl/stp/play/passing_sim_test.py +++ b/src/software/ai/hl/stp/play/passing_sim_test.py @@ -112,16 +112,15 @@ def setup_pass_and_robots( # KickTactic just does the kick we want blue_tactics = {} blue_tactics[0] = KickOrChipTactic( - kick_or_chip_origin=Point( - x_meters=best_pass.passerPoint().x(), - y_meters=best_pass.passerPoint().y(), - ), - kick_or_chip_direction=Angle(radians=kick_vec.orientation().toRadians()), - auto_chip_or_kick=AutoChipOrKick( - autokick_speed_m_per_s=best_pass.speed(), - ), - ) - + kick_or_chip_origin=Point( + x_meters=best_pass.passerPoint().x(), + y_meters=best_pass.passerPoint().y(), + ), + kick_or_chip_direction=Angle(radians=kick_vec.orientation().toRadians()), + auto_chip_or_kick=AutoChipOrKick( + autokick_speed_m_per_s=best_pass.speed(), + ), + ) # if we want a friendly robot to receive the pass if receive_pass: diff --git a/src/software/field_tests/passing_field_test.py b/src/software/field_tests/passing_field_test.py index 299cd7c819..4336bc4803 100644 --- a/src/software/field_tests/passing_field_test.py +++ b/src/software/field_tests/passing_field_test.py @@ -43,16 +43,15 @@ def test_passing(field_test_runner): # KickTactic just does the kick we want blue_tactics = {} blue_tactics[passer_robot_id] = KickOrChipTactic( - kick_or_chip_origin=Point( - x_meters=pass_to_test.passerPoint().x(), - y_meters=pass_to_test.passerPoint().y(), - ), - kick_or_chip_direction=Angle(radians=kick_vec.orientation().toRadians()), - auto_chip_or_kick=AutoChipOrKick( - autokick_speed_m_per_s=pass_to_test.speed(), - ), - ) - + kick_or_chip_origin=Point( + x_meters=pass_to_test.passerPoint().x(), + y_meters=pass_to_test.passerPoint().y(), + ), + kick_or_chip_direction=Angle(radians=kick_vec.orientation().toRadians()), + auto_chip_or_kick=AutoChipOrKick( + autokick_speed_m_per_s=pass_to_test.speed(), + ), + ) # if we want a friendly robot to receive the pass if should_receive_pass: From b50a83125f67bebc1aa1f0ff13a7ab6e3b83b51b Mon Sep 17 00:00:00 2001 From: StarrryNight Date: Sun, 26 Apr 2026 10:27:14 -0700 Subject: [PATCH 23/24] fix build errors --- src/software/ai/hl/stp/play/kickoff_friendly/BUILD | 2 +- .../stp/play/kickoff_friendly/kickoff_friendly_play_fsm.cpp | 5 ++++- .../hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/software/ai/hl/stp/play/kickoff_friendly/BUILD b/src/software/ai/hl/stp/play/kickoff_friendly/BUILD index 17e661499b..e00d6bb685 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly/BUILD +++ b/src/software/ai/hl/stp/play/kickoff_friendly/BUILD @@ -17,7 +17,7 @@ cc_library( "//software/ai/evaluation:enemy_threat", "//software/ai/evaluation:find_open_areas", "//software/ai/hl/stp/play", - "//software/ai/hl/stp/tactic/chip:chip_tactic", + "//software/ai/hl/stp/tactic/kick_or_chip:kick_or_chip_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/logger", "//software/util/generic_factory", diff --git a/src/software/ai/hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.cpp b/src/software/ai/hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.cpp index 7c1afd31f9..0708c8b5cc 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.cpp @@ -129,7 +129,10 @@ void KickoffFriendlyPlayFSM::chipBall(const Update& event) selected_target = best_target_it->origin(); } - kickoff_chip_tactic->updateControlParams(ball_position, selected_target); + kickoff_chip_tactic->updateControlParams( + ball_position, selected_target, + AutoChipOrKick{AutoChipOrKickMode::AUTOCHIP, + (selected_target - ball_position).length()}); tactics_to_run[0].emplace_back(kickoff_chip_tactic); event.common.set_tactics(tactics_to_run); } diff --git a/src/software/ai/hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.h b/src/software/ai/hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.h index 28787b434b..61ac1ab620 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.h +++ b/src/software/ai/hl/stp/play/kickoff_friendly/kickoff_friendly_play_fsm.h @@ -6,7 +6,7 @@ #include "software/ai/evaluation/find_open_areas.h" #include "software/ai/hl/stp/play/play.h" #include "software/ai/hl/stp/play/play_fsm.hpp" -#include "software/ai/hl/stp/tactic/chip/chip_tactic.h" +#include "software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/logger/logger.h" From d35dadcea0b48d108922839d401b13a4d8a53c0f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sun, 26 Apr 2026 17:45:17 +0000 Subject: [PATCH 24/24] [pre-commit.ci lite] apply automatic fixes --- docs/fsm-diagrams.md | 17 +++++++ .../stp/play/free_kick/free_kick_play_fsm.cpp | 7 ++- .../ai/hl/stp/play/kickoff_friendly_play.cpp | 4 +- .../tactic/kick_or_chip/kick_or_chip_fsm.cpp | 10 ++-- .../tactic/kick_or_chip/kick_or_chip_fsm.h | 2 +- .../tactic/penalty_kick/penalty_kick_fsm.cpp | 2 +- .../tactic/penalty_kick/penalty_kick_fsm.h | 2 +- .../ai/hl/stp/tactic/tactic_factory.cpp | 4 +- .../ai/hl/stp/tactic/tactic_factory.h | 4 +- .../ai/hl/stp/tactic/tactic_visitor.h | 50 +++++++++---------- .../motion_constraint_visitor.cpp | 6 +-- .../motion_constraint_visitor.h | 50 +++++++++---------- 12 files changed, 87 insertions(+), 71 deletions(-) diff --git a/docs/fsm-diagrams.md b/docs/fsm-diagrams.md index 247ef514bc..88d30fdf4b 100644 --- a/docs/fsm-diagrams.md +++ b/docs/fsm-diagrams.md @@ -298,6 +298,23 @@ Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION GetBehindBallFSM +GetBehindBallFSM --> GetBehindBallFSM : updateGetBehindBall +GetBehindBallFSM --> ChipState +ChipState --> GetBehindBallFSM : [shouldRealignWithBall]\nupdateGetBehindBall +ChipState --> ChipState : [!ballChicked]\nupdateChip +ChipState --> Terminate:::terminate : [ballChicked]\nSET_STOP_PRIMITIVE_ACTION +Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION + +``` + ## [CreaseDefenderFSM](/src/software/ai/hl/stp/tactic/crease_defender/crease_defender_fsm.h) ```mermaid diff --git a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp index e878355554..375241c806 100644 --- a/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.cpp @@ -291,10 +291,9 @@ void FreeKickPlayFSM::passBall(const Update& event) Pass pass = best_pass_and_score_so_far.pass; AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, pass.speed()}; - passer_tactic->updateControlParams( - pass.passerPoint(), pass.passerOrientation(), - auto_chip_or_kick); - receiver_tactic->updateControlParams(pass); + passer_tactic->updateControlParams(pass.passerPoint(), pass.passerOrientation(), + auto_chip_or_kick); + receiver_tactic->updateControlParams(pass); tactics_to_run[0].emplace_back(passer_tactic); tactics_to_run[0].emplace_back(receiver_tactic); diff --git a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp index 439c64110d..f4c80d9d9d 100644 --- a/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp +++ b/src/software/ai/hl/stp/play/kickoff_friendly_play.cpp @@ -12,8 +12,8 @@ KickoffFriendlyPlay::KickoffFriendlyPlay( { } -void KickoffFriendlyPlay::getNextTactics(TacticCoroutine::push_type &yield, - const WorldPtr &world_ptr) +void KickoffFriendlyPlay::getNextTactics(TacticCoroutine::push_type& yield, + const WorldPtr& world_ptr) { // Since we only have 6 robots at the maximum, the number one priority // is the robot doing the kickoff up front. The goalie is the second most diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp index c008a08a3a..4c2c6be01b 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.cpp @@ -8,7 +8,7 @@ KickOrChipFSM::KickOrChipFSM(std::shared_ptr ai_conf { } -void KickOrChipFSM::kickOrChipBall(const Update &event) +void KickOrChipFSM::kickOrChipBall(const Update& event) { Vector direction = Vector::createFromAngle(event.control_params.kick_or_chip_direction); @@ -24,7 +24,7 @@ void KickOrChipFSM::kickOrChipBall(const Update &event) } void KickOrChipFSM::updateGetBehindBall( - const Update &event, boost::sml::back::process processEvent) + const Update& event, boost::sml::back::process processEvent) { GetBehindBallFSM::ControlParams control_params{ .ball_location = event.control_params.kick_or_chip_origin, @@ -34,15 +34,15 @@ void KickOrChipFSM::updateGetBehindBall( processEvent(GetBehindBallFSM::Update(control_params, event.common)); } -bool KickOrChipFSM::ballChicked(const Update &event) +bool KickOrChipFSM::ballChicked(const Update& event) { return event.common.world_ptr->ball().hasBallBeenKicked( event.control_params.kick_or_chip_direction); } -bool KickOrChipFSM::shouldRealignWithBall(const Update &event) +bool KickOrChipFSM::shouldRealignWithBall(const Update& event) { - const Robot &robot = event.common.robot; + const Robot& robot = event.common.robot; // First check to see if it's too late to realign with the ball if (robot.isNearDribbler(event.control_params.kick_or_chip_origin, 0.05)) diff --git a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h index ef4d03b809..d259d13a62 100644 --- a/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h +++ b/src/software/ai/hl/stp/tactic/kick_or_chip/kick_or_chip_fsm.h @@ -40,7 +40,7 @@ struct KickOrChipFSM : TacticFSM * * @param event KickFSM::Update event */ - void kickOrChipBall(const Update &event); + void kickOrChipBall(const Update& event); /** * Action that updates the GetBehindBallFSM diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp index 60a2fa622f..0e44c80260 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.cpp @@ -121,7 +121,7 @@ const Point PenaltyKickFSM::evaluateNextShotPosition(std::optional enemy_ } } -void PenaltyKickFSM::shoot(const Update &event, +void PenaltyKickFSM::shoot(const Update& event, boost::sml::back::process processEvent) { AutoChipOrKick auto_chip_or_kick = {AutoChipOrKickMode::AUTOKICK, diff --git a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h index 5b3ce7467c..1bd3711e05 100644 --- a/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h +++ b/src/software/ai/hl/stp/tactic/penalty_kick/penalty_kick_fsm.h @@ -58,7 +58,7 @@ struct PenaltyKickFSM : TacticFSM * @param event PenaltyKickFSM::Update event * @param processEvent processes the KickFSM::Update */ - void shoot(const Update &event, + void shoot(const Update& event, boost::sml::back::process processEvent); /** diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.cpp b/src/software/ai/hl/stp/tactic/tactic_factory.cpp index 291d516b9f..d86df9e5aa 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.cpp +++ b/src/software/ai/hl/stp/tactic/tactic_factory.cpp @@ -59,7 +59,7 @@ std::shared_ptr createTactic( } std::shared_ptr createTactic( - const TbotsProto::CreaseDefenderTactic &tactic_proto, + const TbotsProto::CreaseDefenderTactic& tactic_proto, std::shared_ptr ai_config_ptr) { auto tactic = std::make_shared(ai_config_ptr); @@ -113,7 +113,7 @@ std::shared_ptr createTactic( } std::shared_ptr createTactic( - const TbotsProto::KickOrChipTactic &tactic_proto, + const TbotsProto::KickOrChipTactic& tactic_proto, std::shared_ptr ai_config_ptr) { auto tactic = std::make_shared(ai_config_ptr); diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.h b/src/software/ai/hl/stp/tactic/tactic_factory.h index 5e8134265f..ab92265d88 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.h +++ b/src/software/ai/hl/stp/tactic/tactic_factory.h @@ -18,7 +18,7 @@ std::shared_ptr createTactic( const TbotsProto::AttackerTactic& tactic_proto, std::shared_ptr ai_config_ptr); std::shared_ptr createTactic( - const TbotsProto::CreaseDefenderTactic &tactic_proto, + const TbotsProto::CreaseDefenderTactic& tactic_proto, std::shared_ptr ai_config_ptr); std::shared_ptr createTactic( const TbotsProto::DribbleTactic& tactic_proto, @@ -30,7 +30,7 @@ std::shared_ptr createTactic( const TbotsProto::GoalieTactic& tactic_proto, std::shared_ptr ai_config_ptr); std::shared_ptr createTactic( - const TbotsProto::KickOrChipTactic &tactic_proto, + const TbotsProto::KickOrChipTactic& tactic_proto, std::shared_ptr ai_config_ptr); std::shared_ptr createTactic( const TbotsProto::MoveGoalieToGoalLineTactic& tactic_proto, diff --git a/src/software/ai/hl/stp/tactic/tactic_visitor.h b/src/software/ai/hl/stp/tactic/tactic_visitor.h index 69d9db7f0e..125837b28d 100644 --- a/src/software/ai/hl/stp/tactic/tactic_visitor.h +++ b/src/software/ai/hl/stp/tactic/tactic_visitor.h @@ -46,29 +46,29 @@ class TacticVisitor * @param tactic The tactic to visit */ - virtual void visit(const CreaseDefenderTactic &tactic) = 0; - virtual void visit(const DefenseShadowEnemyTactic &tactic) = 0; - virtual void visit(const DribbleTactic &tactic) = 0; - virtual void visit(const GetBehindBallTactic &tactic) = 0; - virtual void visit(const GoalieTactic &tactic) = 0; - virtual void visit(const GoalieTestTactic &tactic) = 0; - virtual void visit(const KickoffChipTactic &tactic) = 0; - virtual void visit(const MoveTactic &tactic) = 0; - virtual void visit(const MoveTestTactic &tactic) = 0; - virtual void visit(const AttackerTactic &tactic) = 0; - virtual void visit(const PassDefenderTactic &tactic) = 0; - virtual void visit(const PenaltyKickTactic &tactic) = 0; - virtual void visit(const PenaltySetupTactic &tactic) = 0; - virtual void visit(const PivotKickTactic &tactic) = 0; - virtual void visit(const ReceiverTactic &tactic) = 0; - virtual void visit(const ShadowEnemyTactic &tactic) = 0; - virtual void visit(const HaltTactic &tactic) = 0; - virtual void visit(const StopTestTactic &tactic) = 0; - virtual void visit(const MoveGoalieToGoalLineTactic &tactic) = 0; - virtual void visit(const PrepareKickoffMoveTactic &tactic) = 0; - virtual void visit(const PlaceBallTactic &tactic) = 0; - virtual void visit(const PlaceBallMoveTactic &tactic) = 0; - virtual void visit(const WallKickoffTactic &tactic) = 0; - virtual void visit(const AvoidInterferenceTactic &tactic) = 0; - virtual void visit(const KickOrChipTactic &tactic) = 0; + virtual void visit(const CreaseDefenderTactic& tactic) = 0; + virtual void visit(const DefenseShadowEnemyTactic& tactic) = 0; + virtual void visit(const DribbleTactic& tactic) = 0; + virtual void visit(const GetBehindBallTactic& tactic) = 0; + virtual void visit(const GoalieTactic& tactic) = 0; + virtual void visit(const GoalieTestTactic& tactic) = 0; + virtual void visit(const KickoffChipTactic& tactic) = 0; + virtual void visit(const MoveTactic& tactic) = 0; + virtual void visit(const MoveTestTactic& tactic) = 0; + virtual void visit(const AttackerTactic& tactic) = 0; + virtual void visit(const PassDefenderTactic& tactic) = 0; + virtual void visit(const PenaltyKickTactic& tactic) = 0; + virtual void visit(const PenaltySetupTactic& tactic) = 0; + virtual void visit(const PivotKickTactic& tactic) = 0; + virtual void visit(const ReceiverTactic& tactic) = 0; + virtual void visit(const ShadowEnemyTactic& tactic) = 0; + virtual void visit(const HaltTactic& tactic) = 0; + virtual void visit(const StopTestTactic& tactic) = 0; + virtual void visit(const MoveGoalieToGoalLineTactic& tactic) = 0; + virtual void visit(const PrepareKickoffMoveTactic& tactic) = 0; + virtual void visit(const PlaceBallTactic& tactic) = 0; + virtual void visit(const PlaceBallMoveTactic& tactic) = 0; + virtual void visit(const WallKickoffTactic& tactic) = 0; + virtual void visit(const AvoidInterferenceTactic& tactic) = 0; + virtual void visit(const KickOrChipTactic& tactic) = 0; }; diff --git a/src/software/ai/motion_constraint/motion_constraint_visitor.cpp b/src/software/ai/motion_constraint/motion_constraint_visitor.cpp index b9ba881f26..cfe02dd308 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.cpp +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.cpp @@ -20,7 +20,7 @@ void MotionConstraintVisitor::visit(const ShadowEnemyTactic& tactic) {} void MotionConstraintVisitor::visit(const MoveTactic& tactic) {} -void MotionConstraintVisitor::visit(const PivotKickTactic &tactic) {} +void MotionConstraintVisitor::visit(const PivotKickTactic& tactic) {} void MotionConstraintVisitor::visit(const KickoffChipTactic& tactic) { @@ -103,9 +103,9 @@ void MotionConstraintVisitor::visit(const AvoidInterferenceTactic& tactic) current_motion_constraints.clear(); } -void MotionConstraintVisitor::visit(const KickOrChipTactic &tactic) {} +void MotionConstraintVisitor::visit(const KickOrChipTactic& tactic) {} -void MotionConstraintVisitor::visit(const PassDefenderTactic &tactic) {} +void MotionConstraintVisitor::visit(const PassDefenderTactic& tactic) {} std::set MotionConstraintVisitor::getUpdatedMotionConstraints( diff --git a/src/software/ai/motion_constraint/motion_constraint_visitor.h b/src/software/ai/motion_constraint/motion_constraint_visitor.h index 3fe167b2a6..74d6b7a01d 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.h +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.h @@ -19,31 +19,31 @@ class MotionConstraintVisitor : public TacticVisitor * * @modifies current_motion_constraints */ - void visit(const GoalieTactic &tactic) override; - void visit(const CreaseDefenderTactic &tactic) override; - void visit(const ShadowEnemyTactic &tactic) override; - void visit(const MoveTactic &tactic) override; - void visit(const KickoffChipTactic &tactic) override; - void visit(const HaltTactic &tactic) override; - void visit(const PenaltyKickTactic &tactic) override; - void visit(const PenaltySetupTactic &tactic) override; - void visit(const ReceiverTactic &tactic) override; - void visit(const AttackerTactic &tactic) override; - void visit(const DefenseShadowEnemyTactic &tactic) override; - void visit(const MoveTestTactic &tactic) override; - void visit(const StopTestTactic &tactic) override; - void visit(const GoalieTestTactic &tactic) override; - void visit(const DribbleTactic &tactic) override; - void visit(const GetBehindBallTactic &tactic) override; - void visit(const PivotKickTactic &tactic) override; - void visit(const MoveGoalieToGoalLineTactic &tactic) override; - void visit(const PrepareKickoffMoveTactic &tactic) override; - void visit(const PlaceBallTactic &tactic) override; - void visit(const PlaceBallMoveTactic &tactic) override; - void visit(const WallKickoffTactic &tactic) override; - void visit(const AvoidInterferenceTactic &tactic) override; - void visit(const PassDefenderTactic &tactic) override; - void visit(const KickOrChipTactic &tactic) override; + void visit(const GoalieTactic& tactic) override; + void visit(const CreaseDefenderTactic& tactic) override; + void visit(const ShadowEnemyTactic& tactic) override; + void visit(const MoveTactic& tactic) override; + void visit(const KickoffChipTactic& tactic) override; + void visit(const HaltTactic& tactic) override; + void visit(const PenaltyKickTactic& tactic) override; + void visit(const PenaltySetupTactic& tactic) override; + void visit(const ReceiverTactic& tactic) override; + void visit(const AttackerTactic& tactic) override; + void visit(const DefenseShadowEnemyTactic& tactic) override; + void visit(const MoveTestTactic& tactic) override; + void visit(const StopTestTactic& tactic) override; + void visit(const GoalieTestTactic& tactic) override; + void visit(const DribbleTactic& tactic) override; + void visit(const GetBehindBallTactic& tactic) override; + void visit(const PivotKickTactic& tactic) override; + void visit(const MoveGoalieToGoalLineTactic& tactic) override; + void visit(const PrepareKickoffMoveTactic& tactic) override; + void visit(const PlaceBallTactic& tactic) override; + void visit(const PlaceBallMoveTactic& tactic) override; + void visit(const WallKickoffTactic& tactic) override; + void visit(const AvoidInterferenceTactic& tactic) override; + void visit(const PassDefenderTactic& tactic) override; + void visit(const KickOrChipTactic& tactic) override; /** * Gets the motion constraints updated with the requirements of the tactics