From 00f37531ea33e21f51c6f878537fb126aec83c10 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 3 Oct 2024 19:52:49 -0700 Subject: [PATCH 01/29] Refactor `StopTactic` to `HaltTactic`, refactoring variables where necessary Files still need to be refactored, which will be done in the next commit --- src/proto/tactic.proto | 4 +- src/software/ai/hl/stp/play/halt_play.cpp | 16 +++---- src/software/ai/hl/stp/play/play.cpp | 6 +-- src/software/ai/hl/stp/play/play.h | 2 +- .../hl/stp/play/test_plays/halt_test_play.cpp | 8 ++-- .../ai/hl/stp/stp_tactic_assignment_test.cpp | 46 +++++++++---------- src/software/ai/hl/stp/stp_test.cpp | 2 +- .../ai/hl/stp/tactic/stop/stop_tactic.cpp | 6 +-- .../ai/hl/stp/tactic/stop/stop_tactic.h | 8 ++-- .../hl/stp/tactic/stop/stop_tactic_test.cpp | 4 +- .../ai/hl/stp/tactic/tactic_factory.cpp | 4 +- .../ai/hl/stp/tactic/tactic_factory.h | 2 +- .../ai/hl/stp/tactic/tactic_visitor.h | 4 +- .../motion_constraint_set_builder_test.cpp | 2 +- .../motion_constraint_visitor.cpp | 2 +- .../motion_constraint_visitor.h | 2 +- 16 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/proto/tactic.proto b/src/proto/tactic.proto index ecb73872cd..055f006b46 100644 --- a/src/proto/tactic.proto +++ b/src/proto/tactic.proto @@ -28,7 +28,7 @@ message Tactic PivotKickTactic pivot_kick = 11; ReceiverTactic receiver = 12; ShadowEnemyTactic shadow_enemy = 13; - StopTactic stop = 14; + HaltTactic stop = 14; PassDefenderTactic pass_defender = 15; } } @@ -179,4 +179,4 @@ message ShadowEnemyTactic required double shadow_distance = 2; } -message StopTactic {} +message HaltTactic {} diff --git a/src/software/ai/hl/stp/play/halt_play.cpp b/src/software/ai/hl/stp/play/halt_play.cpp index 009332c535..c8b738e59a 100644 --- a/src/software/ai/hl/stp/play/halt_play.cpp +++ b/src/software/ai/hl/stp/play/halt_play.cpp @@ -8,18 +8,18 @@ HaltPlay::HaltPlay(TbotsProto::AiConfig config) : Play(config, false) {} void HaltPlay::getNextTactics(TacticCoroutine::push_type &yield, const WorldPtr &world_ptr) { - auto stop_tactic_1 = std::make_shared(); - auto stop_tactic_2 = std::make_shared(); - auto stop_tactic_3 = std::make_shared(); - auto stop_tactic_4 = std::make_shared(); - auto stop_tactic_5 = std::make_shared(); - auto stop_tactic_6 = std::make_shared(); + auto halt_tactic_1 = std::make_shared(); + auto halt_tactic_2 = std::make_shared(); + auto halt_tactic_3 = std::make_shared(); + auto halt_tactic_4 = std::make_shared(); + auto halt_tactic_5 = std::make_shared(); + auto halt_tactic_6 = std::make_shared(); do { // yield the Tactics this Play wants to run, in order of priority - yield({{stop_tactic_1, stop_tactic_2, stop_tactic_3, stop_tactic_4, stop_tactic_5, - stop_tactic_6}}); + yield({{halt_tactic_1, halt_tactic_2, halt_tactic_3, halt_tactic_4, halt_tactic_5, + halt_tactic_6}}); } while (true); } diff --git a/src/software/ai/hl/stp/play/play.cpp b/src/software/ai/hl/stp/play/play.cpp index 85cc5755be..9b23333b2f 100644 --- a/src/software/ai/hl/stp/play/play.cpp +++ b/src/software/ai/hl/stp/play/play.cpp @@ -13,7 +13,7 @@ Play::Play(TbotsProto::AiConfig ai_config, bool requires_goalie) : ai_config(ai_config), goalie_tactic(std::make_shared(ai_config)), - stop_tactics(), + halt_tactics(), requires_goalie(requires_goalie), tactic_sequence(boost::bind(&Play::getNextTacticsWrapper, this, _1)), world_ptr_(std::nullopt), @@ -21,7 +21,7 @@ Play::Play(TbotsProto::AiConfig ai_config, bool requires_goalie) { for (unsigned int i = 0; i < MAX_ROBOT_IDS; i++) { - stop_tactics.push_back(std::make_shared()); + halt_tactics.push_back(std::make_shared()); } } @@ -192,7 +192,7 @@ std::unique_ptr Play::get( // StopTactics for (unsigned int ii = 0; ii < (robots.size() - num_tactics); ii++) { - tactic_vector.push_back(stop_tactics[ii]); + tactic_vector.push_back(halt_tactics[ii]); } } diff --git a/src/software/ai/hl/stp/play/play.h b/src/software/ai/hl/stp/play/play.h index 1a87f6934c..f79a3bce23 100644 --- a/src/software/ai/hl/stp/play/play.h +++ b/src/software/ai/hl/stp/play/play.h @@ -171,7 +171,7 @@ class Play const WorldPtr& world_ptr) = 0; // Stop tactic common to all plays for robots that don't have tactics assigned - TacticVector stop_tactics; + TacticVector halt_tactics; // Whether this play requires a goalie const bool requires_goalie; diff --git a/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp b/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp index f670f96fb0..342fa386eb 100644 --- a/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp +++ b/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp @@ -9,13 +9,13 @@ HaltTestPlay::HaltTestPlay(TbotsProto::AiConfig config) : Play(config, false) {} void HaltTestPlay::getNextTactics(TacticCoroutine::push_type &yield, const WorldPtr &world_ptr) { - auto stop_test_tactic_1 = std::make_shared(); - auto stop_test_tactic_2 = std::make_shared(); - auto stop_test_tactic_3 = std::make_shared(); + auto halt_test_tactic_1 = std::make_shared(); + auto halt_test_tactic_2 = std::make_shared(); + auto halt_test_tactic_3 = std::make_shared(); do { - yield({{stop_test_tactic_1, stop_test_tactic_2, stop_test_tactic_3}}); + yield({{halt_test_tactic_1, halt_test_tactic_2, halt_test_tactic_3}}); } while (true); } diff --git a/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp b/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp index e4856b67cc..26890a4474 100644 --- a/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp +++ b/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp @@ -160,12 +160,12 @@ TEST_F(STPTacticAssignmentTest, world.updateFriendlyTeamState(friendly_team); auto move_tactic_1 = std::make_shared(); - auto stop_tactic_1 = std::make_shared(); + auto halt_tactic_1 = std::make_shared(); move_tactic_1->updateControlParams(Point(-1, 0), Angle::zero(), 0, TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT); - ConstTacticVector tactics = {move_tactic_1, stop_tactic_1}; + ConstTacticVector tactics = {move_tactic_1, halt_tactic_1}; // Both robots are now closest to move_tactic_1's destination. We do NOT want // robot_0 to be assigned to move_tactic_1, because then robot_1 has to move all the @@ -175,11 +175,11 @@ TEST_F(STPTacticAssignmentTest, auto asst = stp.assignRobotsToTactics({tactics}, world, false); - // move_tactic_1 should be the only Tactic assigned a robot, since stop_tactic_1 is a + // move_tactic_1 should be the only Tactic assigned a robot, since halt_tactic_1 is a // lower priority than move_tactic_1 so it should be dropped since there's only 1 // robot EXPECT_TRUE(asst.find(move_tactic_1) != asst.end()); - EXPECT_FALSE(asst.find(stop_tactic_1) != asst.end()); + EXPECT_FALSE(asst.find(halt_tactic_1) != asst.end()); } @@ -329,21 +329,21 @@ TEST_F(STPTacticAssignmentTest, friendly_team.updateRobots({robot_0, robot_1, robot_2}); world.updateFriendlyTeamState(friendly_team); - auto stop_tactic_1 = std::make_shared(); - auto stop_tactic_2 = std::make_shared(); - auto stop_tactic_3 = std::make_shared(); + auto halt_tactic_1 = std::make_shared(); + auto halt_tactic_2 = std::make_shared(); + auto halt_tactic_3 = std::make_shared(); - ConstTacticVector tactics = {stop_tactic_1, stop_tactic_2, stop_tactic_3}; + ConstTacticVector tactics = {halt_tactic_1, halt_tactic_2, halt_tactic_3}; // If all costs are equal, the robots and tactics are simply paired in order auto asst = stp.assignRobotsToTactics({tactics}, world, false); - ASSERT_TRUE(asst.find(stop_tactic_1) != asst.end()); - ASSERT_TRUE(asst.find(stop_tactic_2) != asst.end()); - ASSERT_TRUE(asst.find(stop_tactic_3) != asst.end()); - EXPECT_EQ(asst.find(stop_tactic_1)->second, robot_0); - EXPECT_EQ(asst.find(stop_tactic_2)->second, robot_1); - EXPECT_EQ(asst.find(stop_tactic_3)->second, robot_2); + ASSERT_TRUE(asst.find(halt_tactic_1) != asst.end()); + ASSERT_TRUE(asst.find(halt_tactic_2) != asst.end()); + ASSERT_TRUE(asst.find(halt_tactic_3) != asst.end()); + EXPECT_EQ(asst.find(halt_tactic_1)->second, robot_0); + EXPECT_EQ(asst.find(halt_tactic_2)->second, robot_1); + EXPECT_EQ(asst.find(halt_tactic_3)->second, robot_2); } TEST_F(STPTacticAssignmentTest, @@ -359,26 +359,26 @@ TEST_F(STPTacticAssignmentTest, friendly_team.updateRobots({robot_0, robot_1, robot_2}); world.updateFriendlyTeamState(friendly_team); - auto stop_tactic_1 = std::make_shared(); + auto halt_tactic_1 = std::make_shared(); auto move_tactic_1 = std::make_shared(); - auto stop_tactic_2 = std::make_shared(); + auto halt_tactic_2 = std::make_shared(); // The destination of the move_tactic is relatively close to the robot positions, so // the cost of assigning any robot to the move_tactic should be less than the - // stop_tactics + // halt_tactics move_tactic_1->updateControlParams(Point(0, 0), Angle::zero(), 0, TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT); - ConstTacticVector tactics = {stop_tactic_1, move_tactic_1, stop_tactic_2}; + ConstTacticVector tactics = {halt_tactic_1, move_tactic_1, halt_tactic_2}; auto asst = stp.assignRobotsToTactics({tactics}, world, false); - ASSERT_TRUE(asst.find(stop_tactic_1) != asst.end()); + ASSERT_TRUE(asst.find(halt_tactic_1) != asst.end()); ASSERT_TRUE(asst.find(move_tactic_1) != asst.end()); - ASSERT_TRUE(asst.find(stop_tactic_2) != asst.end()); - EXPECT_EQ(asst.find(stop_tactic_1)->second, robot_2); + ASSERT_TRUE(asst.find(halt_tactic_2) != asst.end()); + EXPECT_EQ(asst.find(halt_tactic_1)->second, robot_2); EXPECT_EQ(asst.find(move_tactic_1)->second, robot_0); - EXPECT_EQ(asst.find(stop_tactic_2)->second, robot_1); + EXPECT_EQ(asst.find(halt_tactic_2)->second, robot_1); } TEST_F(STPTacticAssignmentTest, @@ -452,7 +452,7 @@ TEST_F(STPTacticAssignmentTest, TEST_F(STPTacticAssignmentTest, test_assigning_stop_tactics_to_unassigned_non_goalie_robots) { - // Test that StopTactic is assigned to remaining robots without tactics + // Test that HaltTactic is assigned to remaining robots without tactics Team friendly_team(Duration::fromSeconds(0)); Robot robot_0(0, Point(-1, 1), Vector(), Angle::zero(), AngularVelocity::zero(), diff --git a/src/software/ai/hl/stp/stp_test.cpp b/src/software/ai/hl/stp/stp_test.cpp index 4026521735..0cdf72e706 100644 --- a/src/software/ai/hl/stp/stp_test.cpp +++ b/src/software/ai/hl/stp/stp_test.cpp @@ -42,7 +42,7 @@ TEST_F(STPTest, test_get_play_info) std::string expected_play_name, expected_tactic_name; expected_play_name = "HaltPlay"; - expected_tactic_name = "StopTactic"; + expected_tactic_name = "HaltTactic"; TbotsProto::PlayInfo expected_play_info_msg = TbotsProto::PlayInfo(); expected_play_info_msg.mutable_play()->set_play_name(expected_play_name); diff --git a/src/software/ai/hl/stp/tactic/stop/stop_tactic.cpp b/src/software/ai/hl/stp/tactic/stop/stop_tactic.cpp index d6255bce30..3748c6ad44 100644 --- a/src/software/ai/hl/stp/tactic/stop/stop_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/stop/stop_tactic.cpp @@ -2,7 +2,7 @@ #include -StopTactic::StopTactic() : Tactic(std::set()), fsm_map() +HaltTactic::HaltTactic() : Tactic(std::set()), fsm_map() { for (RobotId id = 0; id < MAX_ROBOT_IDS; id++) { @@ -10,12 +10,12 @@ StopTactic::StopTactic() : Tactic(std::set()), fsm_map() } } -void StopTactic::accept(TacticVisitor &visitor) const +void HaltTactic::accept(TacticVisitor &visitor) const { visitor.visit(*this); } -void StopTactic::updatePrimitive(const TacticUpdate &tactic_update, bool reset_fsm) +void HaltTactic::updatePrimitive(const TacticUpdate &tactic_update, bool reset_fsm) { if (reset_fsm) { diff --git a/src/software/ai/hl/stp/tactic/stop/stop_tactic.h b/src/software/ai/hl/stp/tactic/stop/stop_tactic.h index 8cc9486b8d..bb07d46f57 100644 --- a/src/software/ai/hl/stp/tactic/stop/stop_tactic.h +++ b/src/software/ai/hl/stp/tactic/stop/stop_tactic.h @@ -4,16 +4,16 @@ #include "software/ai/hl/stp/tactic/tactic.h" /** - * The StopTactic will stop the robot from moving. The robot will actively try and brake + * The HaltTactic will stop the robot from moving. The robot will actively try and brake * to come to a halt. */ -class StopTactic : public Tactic +class HaltTactic : public Tactic { public: /** - * Creates a new StopTactic + * Creates a new HaltTactic */ - explicit StopTactic(); + explicit HaltTactic(); void accept(TacticVisitor& visitor) const override; diff --git a/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp b/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp index 0164465d98..0b66868d7a 100644 --- a/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp +++ b/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp @@ -23,7 +23,7 @@ TEST_F(StopTacticTest, robot_already_stopped) {Point(-3, 2.5), Point()}, {Vector(), Vector()}); auto enemy_robots = TestUtil::createStationaryRobotStatesWithId({Point(4, 0)}); - auto tactic = std::make_shared(); + auto tactic = std::make_shared(); setTactic(1, tactic); std::vector terminating_validation_functions = { @@ -49,7 +49,7 @@ TEST_F(StopTacticTest, robot_start_moving) {Point(-3, 2.5), Point()}, {Vector(), Vector(4, 4)}); auto enemy_robots = TestUtil::createStationaryRobotStatesWithId({Point(4, 0)}); - auto tactic = std::make_shared(); + auto tactic = std::make_shared(); setTactic(1, tactic); std::vector terminating_validation_functions = { diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.cpp b/src/software/ai/hl/stp/tactic/tactic_factory.cpp index e7e9957c92..f85a1272d7 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.cpp +++ b/src/software/ai/hl/stp/tactic/tactic_factory.cpp @@ -203,10 +203,10 @@ std::shared_ptr createTactic(const TbotsProto::ShadowEnemyTactic &tactic return tactic; } -std::shared_ptr createTactic(const TbotsProto::StopTactic &tactic_proto, +std::shared_ptr createTactic(const TbotsProto::HaltTactic &tactic_proto, TbotsProto::AiConfig ai_config) { - auto tactic = std::make_shared(); + auto tactic = std::make_shared(); return tactic; } diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.h b/src/software/ai/hl/stp/tactic/tactic_factory.h index 5da161d4af..a3967b69bc 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.h +++ b/src/software/ai/hl/stp/tactic/tactic_factory.h @@ -42,7 +42,7 @@ std::shared_ptr createTactic(const TbotsProto::ReceiverTactic &tactic_pr TbotsProto::AiConfig ai_config); std::shared_ptr createTactic(const TbotsProto::ShadowEnemyTactic &tactic_proto, TbotsProto::AiConfig ai_config); -std::shared_ptr createTactic(const TbotsProto::StopTactic &tactic_proto, +std::shared_ptr createTactic(const TbotsProto::HaltTactic &tactic_proto, TbotsProto::AiConfig ai_config); /** diff --git a/src/software/ai/hl/stp/tactic/tactic_visitor.h b/src/software/ai/hl/stp/tactic/tactic_visitor.h index 5ef7fc69a1..ea5c6e5ab0 100644 --- a/src/software/ai/hl/stp/tactic/tactic_visitor.h +++ b/src/software/ai/hl/stp/tactic/tactic_visitor.h @@ -23,7 +23,7 @@ class PenaltySetupTactic; class PivotKickTactic; class ReceiverTactic; class ShadowEnemyTactic; -class StopTactic; +class HaltTactic; class StopTestTactic; class MoveGoalieToGoalLineTactic; class PrepareKickoffMoveTactic; @@ -65,7 +65,7 @@ class TacticVisitor 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 StopTactic &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; 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 daaafdfb7d..7b58c68d57 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 @@ -68,7 +68,7 @@ namespace std::make_tuple(std::make_shared(ai_config), std::set(), std::set()), - std::make_tuple(std::make_shared(), + std::make_tuple(std::make_shared(), 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 2e72672309..cbedffc25c 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.cpp +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.cpp @@ -46,7 +46,7 @@ void MotionConstraintVisitor::visit(const PrepareKickoffMoveTactic &tactic) TbotsProto::MotionConstraint::ENEMY_HALF_WITHOUT_CENTRE_CIRCLE); } -void MotionConstraintVisitor::visit(const StopTactic &tactic) {} +void MotionConstraintVisitor::visit(const HaltTactic &tactic) {} void MotionConstraintVisitor::visit(const PenaltyKickTactic &tactic) { diff --git a/src/software/ai/motion_constraint/motion_constraint_visitor.h b/src/software/ai/motion_constraint/motion_constraint_visitor.h index 5aba45c2b5..8c913c1ae6 100644 --- a/src/software/ai/motion_constraint/motion_constraint_visitor.h +++ b/src/software/ai/motion_constraint/motion_constraint_visitor.h @@ -26,7 +26,7 @@ class MotionConstraintVisitor : public TacticVisitor void visit(const ChipTactic &tactic) override; void visit(const KickTactic &tactic) override; void visit(const KickoffChipTactic &tactic) override; - void visit(const StopTactic &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; From 148d72aaf8dd80a61c61f852bd32ff449ff8333f Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 4 Oct 2024 17:25:51 -0700 Subject: [PATCH 02/29] Rename `stop_tactic.cpp` and `stop_tactic.h` to `halt_tactic.cpp` and `halt_tactic.h`, renaming variables and strings where necessary Variables and strings renamed for consistency and to allow tests to successfully run --- src/software/ai/hl/stp/play/BUILD | 8 ++++---- src/software/ai/hl/stp/play/enemy_free_kick/BUILD | 2 +- src/software/ai/hl/stp/play/halt_play.cpp | 2 +- .../hl/stp/play/penalty_kick/penalty_kick_play_fsm.h | 2 +- src/software/ai/hl/stp/play/play.cpp | 2 +- src/software/ai/hl/stp/play/shoot_or_chip_play.cpp | 2 +- src/software/ai/hl/stp/play/test_plays/BUILD | 2 +- .../ai/hl/stp/play/test_plays/halt_test_play.cpp | 2 +- .../ai/hl/stp/stp_tactic_assignment_test.cpp | 4 ++-- src/software/ai/hl/stp/tactic/BUILD | 2 +- src/software/ai/hl/stp/tactic/all_tactics.h | 2 +- src/software/ai/hl/stp/tactic/stop/BUILD | 10 +++++----- .../tactic/stop/{stop_tactic.cpp => halt_tactic.cpp} | 2 +- .../stp/tactic/stop/{stop_tactic.h => halt_tactic.h} | 0 .../ai/hl/stp/tactic/stop/stop_tactic_test.cpp | 2 +- .../field_tests/movement_robot_field_test.py | 12 ++++++------ src/software/field_tests/passing_field_test.py | 8 ++++---- src/software/field_tests/pivot_kick_field_test.py | 6 +++--- 18 files changed, 35 insertions(+), 35 deletions(-) rename src/software/ai/hl/stp/tactic/stop/{stop_tactic.cpp => halt_tactic.cpp} (91%) rename src/software/ai/hl/stp/tactic/stop/{stop_tactic.h => halt_tactic.h} (100%) diff --git a/src/software/ai/hl/stp/play/BUILD b/src/software/ai/hl/stp/play/BUILD index d44cc02421..202459084e 100644 --- a/src/software/ai/hl/stp/play/BUILD +++ b/src/software/ai/hl/stp/play/BUILD @@ -27,7 +27,7 @@ cc_library( deps = [ ":play", "//shared:constants", - "//software/ai/hl/stp/tactic/stop:stop_tactic", + "//software/ai/hl/stp/tactic/stop:halt_tactic", "//software/logger", "//software/util/generic_factory", ], @@ -84,7 +84,7 @@ cc_library( "//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/ai/hl/stp/tactic/stop:stop_tactic", + "//software/ai/hl/stp/tactic/stop:halt_tactic", "//software/logger", "//software/util/generic_factory", "//software/world:game_state", @@ -119,7 +119,7 @@ cc_library( deps = [ "//software/ai/hl/stp/tactic", "//software/ai/hl/stp/tactic/goalie:goalie_tactic", - "//software/ai/hl/stp/tactic/stop:stop_tactic", + "//software/ai/hl/stp/tactic/stop:halt_tactic", "//software/ai/motion_constraint:motion_constraint_set_builder", "//software/ai/navigator/trajectory:trajectory_planner", "//software/ai/passing:pass_with_rating", @@ -303,7 +303,7 @@ cc_library( deps = [ ":play", "//shared:constants", - "//software/ai/hl/stp/tactic/stop:stop_tactic", + "//software/ai/hl/stp/tactic/stop:halt_tactic", "//software/logger", "//software/util/generic_factory", ], diff --git a/src/software/ai/hl/stp/play/enemy_free_kick/BUILD b/src/software/ai/hl/stp/play/enemy_free_kick/BUILD index 061e8c5e84..716c7d3036 100644 --- a/src/software/ai/hl/stp/play/enemy_free_kick/BUILD +++ b/src/software/ai/hl/stp/play/enemy_free_kick/BUILD @@ -26,7 +26,7 @@ cc_library( "//software/ai/hl/stp/tactic/goalie:goalie_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/ai/hl/stp/tactic/pass_defender:pass_defender_tactic", - "//software/ai/hl/stp/tactic/stop:stop_tactic", + "//software/ai/hl/stp/tactic/stop:halt_tactic", "//software/logger", "//software/util/generic_factory", "//software/world:game_state", diff --git a/src/software/ai/hl/stp/play/halt_play.cpp b/src/software/ai/hl/stp/play/halt_play.cpp index c8b738e59a..2facb6ff53 100644 --- a/src/software/ai/hl/stp/play/halt_play.cpp +++ b/src/software/ai/hl/stp/play/halt_play.cpp @@ -1,6 +1,6 @@ #include "software/ai/hl/stp/play/halt_play.h" -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include "software/util/generic_factory/generic_factory.h" HaltPlay::HaltPlay(TbotsProto::AiConfig config) : Play(config, false) {} diff --git a/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h b/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h index d6733c55b6..ae18c2ef51 100644 --- a/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h +++ b/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h @@ -5,7 +5,7 @@ #include "software/ai/hl/stp/play/play_fsm.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.h" -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include "software/logger/logger.h" diff --git a/src/software/ai/hl/stp/play/play.cpp b/src/software/ai/hl/stp/play/play.cpp index 9b23333b2f..82a3c66af3 100644 --- a/src/software/ai/hl/stp/play/play.cpp +++ b/src/software/ai/hl/stp/play/play.cpp @@ -5,7 +5,7 @@ #include #include "proto/message_translation/tbots_protobuf.h" -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include "software/ai/motion_constraint/motion_constraint_set_builder.h" #include "software/logger/logger.h" diff --git a/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp b/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp index 8a34000f60..a36c88c75f 100644 --- a/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp +++ b/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp @@ -9,7 +9,7 @@ #include "software/ai/hl/stp/tactic/crease_defender/crease_defender_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/shadow_enemy/shadow_enemy_tactic.h" -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include "software/logger/logger.h" #include "software/util/generic_factory/generic_factory.h" #include "software/world/game_state.h" diff --git a/src/software/ai/hl/stp/play/test_plays/BUILD b/src/software/ai/hl/stp/play/test_plays/BUILD index 5ddb293225..aa24703cce 100644 --- a/src/software/ai/hl/stp/play/test_plays/BUILD +++ b/src/software/ai/hl/stp/play/test_plays/BUILD @@ -6,7 +6,7 @@ cc_library( hdrs = ["halt_test_play.h"], deps = [ "//software/ai/hl/stp/play", - "//software/ai/hl/stp/tactic/stop:stop_tactic", + "//software/ai/hl/stp/tactic/stop:halt_tactic", "//software/util/generic_factory", ], alwayslink = True, diff --git a/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp b/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp index 342fa386eb..a7f83c13e7 100644 --- a/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp +++ b/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp @@ -1,6 +1,6 @@ #include "software/ai/hl/stp/play/test_plays/halt_test_play.h" -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include "software/geom/algorithms/contains.h" #include "software/util/generic_factory/generic_factory.h" diff --git a/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp b/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp index 26890a4474..3957f15a21 100644 --- a/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp +++ b/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp @@ -6,7 +6,7 @@ #include "software/ai/hl/stp/play/halt_play.h" #include "software/ai/hl/stp/stp.h" #include "software/ai/hl/stp/tactic/all_tactics.h" -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include "software/test_util/test_util.h" /** @@ -450,7 +450,7 @@ TEST_F(STPTacticAssignmentTest, } TEST_F(STPTacticAssignmentTest, - test_assigning_stop_tactics_to_unassigned_non_goalie_robots) + test_assigning_halt_tactics_to_unassigned_non_goalie_robots) { // Test that HaltTactic is assigned to remaining robots without tactics diff --git a/src/software/ai/hl/stp/tactic/BUILD b/src/software/ai/hl/stp/tactic/BUILD index 5baefe0328..dc9c8a7e3d 100644 --- a/src/software/ai/hl/stp/tactic/BUILD +++ b/src/software/ai/hl/stp/tactic/BUILD @@ -28,7 +28,7 @@ cc_library( "//software/ai/hl/stp/tactic/pivot_kick:pivot_kick_tactic", "//software/ai/hl/stp/tactic/receiver:receiver_tactic", "//software/ai/hl/stp/tactic/shadow_enemy:shadow_enemy_tactic", - "//software/ai/hl/stp/tactic/stop:stop_tactic", + "//software/ai/hl/stp/tactic/stop:halt_tactic", ], ) diff --git a/src/software/ai/hl/stp/tactic/all_tactics.h b/src/software/ai/hl/stp/tactic/all_tactics.h index 46b0df0f0c..960ef5633e 100644 --- a/src/software/ai/hl/stp/tactic/all_tactics.h +++ b/src/software/ai/hl/stp/tactic/all_tactics.h @@ -13,5 +13,5 @@ #include "software/ai/hl/stp/tactic/pivot_kick/pivot_kick_tactic.h" #include "software/ai/hl/stp/tactic/receiver/receiver_tactic.h" #include "software/ai/hl/stp/tactic/shadow_enemy/shadow_enemy_tactic.h" -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include "software/ai/hl/stp/tactic/tactic.h" diff --git a/src/software/ai/hl/stp/tactic/stop/BUILD b/src/software/ai/hl/stp/tactic/stop/BUILD index d9a730d949..7df872c5ec 100644 --- a/src/software/ai/hl/stp/tactic/stop/BUILD +++ b/src/software/ai/hl/stp/tactic/stop/BUILD @@ -1,14 +1,14 @@ package(default_visibility = ["//visibility:public"]) cc_library( - name = "stop_tactic", + name = "halt_tactic", srcs = [ "stop_fsm.cpp", - "stop_tactic.cpp", + "halt_tactic.cpp", ], hdrs = [ "stop_fsm.h", - "stop_tactic.h", + "halt_tactic.h", ], deps = [ "//shared:constants", @@ -21,7 +21,7 @@ cc_test( name = "stop_fsm_test", srcs = ["stop_fsm_test.cpp"], deps = [ - ":stop_tactic", + ":halt_tactic", "//shared/test_util:tbots_gtest_main", "//software/test_util", ], @@ -31,7 +31,7 @@ cc_test( name = "stop_tactic_test", srcs = ["stop_tactic_test.cpp"], deps = [ - ":stop_tactic", + ":halt_tactic", "//shared/test_util:tbots_gtest_main", "//software/simulated_tests:simulated_er_force_sim_play_test_fixture", "//software/simulated_tests/terminating_validation_functions", diff --git a/src/software/ai/hl/stp/tactic/stop/stop_tactic.cpp b/src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp similarity index 91% rename from src/software/ai/hl/stp/tactic/stop/stop_tactic.cpp rename to src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp index 3748c6ad44..c411c060b8 100644 --- a/src/software/ai/hl/stp/tactic/stop/stop_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include diff --git a/src/software/ai/hl/stp/tactic/stop/stop_tactic.h b/src/software/ai/hl/stp/tactic/stop/halt_tactic.h similarity index 100% rename from src/software/ai/hl/stp/tactic/stop/stop_tactic.h rename to src/software/ai/hl/stp/tactic/stop/halt_tactic.h diff --git a/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp b/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp index 0b66868d7a..392336c1d2 100644 --- a/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp +++ b/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/tactic/stop/stop_tactic.h" +#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" #include diff --git a/src/software/field_tests/movement_robot_field_test.py b/src/software/field_tests/movement_robot_field_test.py index 49e43b3254..358f559429 100644 --- a/src/software/field_tests/movement_robot_field_test.py +++ b/src/software/field_tests/movement_robot_field_test.py @@ -117,10 +117,10 @@ def test_basic_rotation(field_test_runner): eventually_validation_sequence_set=[[]], test_timeout_s=5, ) - # Send a stop tactic after the test finishes - stop_tactic = StopTactic() + # Send a halt tactic after the test finishes + halt_tactic = HaltTactic() params = AssignedTacticPlayControlParams() - params.assigned_tactics[id].stop.CopyFrom(stop_tactic) + params.assigned_tactics[id].stop.CopyFrom(halt_tactic) # send the stop tactic field_test_runner.set_tactics(params, True) @@ -209,10 +209,10 @@ def test_one_robots_square(field_test_runner): test_timeout_s=4, ) - # Send a stop tactic after the test finishes - stop_tactic = StopTactic() + # Send a halt tactic after the test finishes + halt_tactic = HaltTactic() params = AssignedTacticPlayControlParams() - params.assigned_tactics[id].stop.CopyFrom(stop_tactic) + params.assigned_tactics[id].stop.CopyFrom(halt_tactic) if __name__ == "__main__": diff --git a/src/software/field_tests/passing_field_test.py b/src/software/field_tests/passing_field_test.py index eff8acafc1..3d1c5ffdb0 100644 --- a/src/software/field_tests/passing_field_test.py +++ b/src/software/field_tests/passing_field_test.py @@ -96,11 +96,11 @@ def test_passing(field_test_runner): test_timeout_s=5, ) - # Send a stop tactic after the test finishes - stop_tactic = StopTactic() + # Send a halt tactic after the test finishes + halt_tactic = StopTactic() params = AssignedTacticPlayControlParams() - params.assigned_tactics[passer_robot_id].stop.CopyFrom(stop_tactic) - params.assigned_tactics[receiver_robot_id].stop.CopyFrom(stop_tactic) + params.assigned_tactics[passer_robot_id].stop.CopyFrom(halt_tactic) + params.assigned_tactics[receiver_robot_id].stop.CopyFrom(halt_tactic) # send the stop tactic field_test_runner.set_tactics(params, True) diff --git a/src/software/field_tests/pivot_kick_field_test.py b/src/software/field_tests/pivot_kick_field_test.py index 432171ccfb..4edeaa2167 100644 --- a/src/software/field_tests/pivot_kick_field_test.py +++ b/src/software/field_tests/pivot_kick_field_test.py @@ -38,10 +38,10 @@ def test_pivot_kick(field_test_runner): eventually_validation_sequence_set=[[]], test_timeout_s=15, ) - # Send a stop tactic after the test finishes - stop_tactic = StopTactic() + # Send a halt tactic after the test finishes + halt_tactic = HaltTactic() params = AssignedTacticPlayControlParams() - params.assigned_tactics[id].stop.CopyFrom(stop_tactic) + params.assigned_tactics[id].stop.CopyFrom(halt_tactic) if __name__ == "__main__": From 629c067217bb4ad0a83913165468755ce6c7b1d9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 4 Oct 2024 17:36:10 -0700 Subject: [PATCH 03/29] Rename `stop_tactic_test.cpp` to `halt_tactic_test.cpp` --- src/software/ai/hl/stp/tactic/stop/BUILD | 4 ++-- .../stop/{stop_tactic_test.cpp => halt_tactic_test.cpp} | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/software/ai/hl/stp/tactic/stop/{stop_tactic_test.cpp => halt_tactic_test.cpp} (94%) diff --git a/src/software/ai/hl/stp/tactic/stop/BUILD b/src/software/ai/hl/stp/tactic/stop/BUILD index 7df872c5ec..d5244c5b01 100644 --- a/src/software/ai/hl/stp/tactic/stop/BUILD +++ b/src/software/ai/hl/stp/tactic/stop/BUILD @@ -28,8 +28,8 @@ cc_test( ) cc_test( - name = "stop_tactic_test", - srcs = ["stop_tactic_test.cpp"], + name = "halt_tactic_test", + srcs = ["halt_tactic_test.cpp"], deps = [ ":halt_tactic", "//shared/test_util:tbots_gtest_main", diff --git a/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp b/src/software/ai/hl/stp/tactic/stop/halt_tactic_test.cpp similarity index 94% rename from src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp rename to src/software/ai/hl/stp/tactic/stop/halt_tactic_test.cpp index 392336c1d2..d6f44c9bb3 100644 --- a/src/software/ai/hl/stp/tactic/stop/stop_tactic_test.cpp +++ b/src/software/ai/hl/stp/tactic/stop/halt_tactic_test.cpp @@ -8,14 +8,14 @@ #include "software/simulated_tests/validation/validation_function.h" #include "software/test_util/test_util.h" -class StopTacticTest : public SimulatedErForceSimPlayTestFixture +class HaltTacticTest : public SimulatedErForceSimPlayTestFixture { protected: TbotsProto::FieldType field_type = TbotsProto::FieldType::DIV_B; Field field = Field::createField(field_type); }; -TEST_F(StopTacticTest, robot_already_stopped) +TEST_F(HaltTacticTest, robot_already_stopped) { BallState ball_state(Point(0, 0.5), Vector(0, 0)); @@ -41,7 +41,7 @@ TEST_F(StopTacticTest, robot_already_stopped) Duration::fromSeconds(5)); } -TEST_F(StopTacticTest, robot_start_moving) +TEST_F(HaltTacticTest, robot_start_moving) { BallState ball_state(Point(0, 0.5), Vector(0, 0)); From 835de969422d58062bdffbe069d004035a34766a Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 4 Oct 2024 17:59:24 -0700 Subject: [PATCH 04/29] Rename `stop_fsm` and `stop_fsm_test` to `halt_fsm` and `halt_fsm_test`, renaming where necessary --- src/software/ai/hl/stp/tactic/stop/BUILD | 8 ++++---- src/software/ai/hl/stp/tactic/stop/halt_fsm.cpp | 11 +++++++++++ .../stp/tactic/stop/{stop_fsm.h => halt_fsm.h} | 10 +++++----- .../{stop_fsm_test.cpp => halt_fsm_test.cpp} | 16 ++++++++-------- .../ai/hl/stp/tactic/stop/halt_tactic.cpp | 6 +++--- src/software/ai/hl/stp/tactic/stop/halt_tactic.h | 4 ++-- src/software/ai/hl/stp/tactic/stop/stop_fsm.cpp | 11 ----------- 7 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 src/software/ai/hl/stp/tactic/stop/halt_fsm.cpp rename src/software/ai/hl/stp/tactic/stop/{stop_fsm.h => halt_fsm.h} (87%) rename src/software/ai/hl/stp/tactic/stop/{stop_fsm_test.cpp => halt_fsm_test.cpp} (71%) delete mode 100644 src/software/ai/hl/stp/tactic/stop/stop_fsm.cpp diff --git a/src/software/ai/hl/stp/tactic/stop/BUILD b/src/software/ai/hl/stp/tactic/stop/BUILD index d5244c5b01..266edf3f11 100644 --- a/src/software/ai/hl/stp/tactic/stop/BUILD +++ b/src/software/ai/hl/stp/tactic/stop/BUILD @@ -3,11 +3,11 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "halt_tactic", srcs = [ - "stop_fsm.cpp", + "halt_fsm.cpp", "halt_tactic.cpp", ], hdrs = [ - "stop_fsm.h", + "halt_fsm.h", "halt_tactic.h", ], deps = [ @@ -18,8 +18,8 @@ cc_library( ) cc_test( - name = "stop_fsm_test", - srcs = ["stop_fsm_test.cpp"], + name = "halt_fsm_test", + srcs = ["halt_fsm_test.cpp"], deps = [ ":halt_tactic", "//shared/test_util:tbots_gtest_main", diff --git a/src/software/ai/hl/stp/tactic/stop/halt_fsm.cpp b/src/software/ai/hl/stp/tactic/stop/halt_fsm.cpp new file mode 100644 index 0000000000..a874a305c5 --- /dev/null +++ b/src/software/ai/hl/stp/tactic/stop/halt_fsm.cpp @@ -0,0 +1,11 @@ +#include "software/ai/hl/stp/tactic/stop/halt_fsm.h" + +void HaltFSM::updateStop(const Update& event) +{ + event.common.set_primitive(std::make_unique()); +} + +bool HaltFSM::stopDone(const Update& event) +{ + return robotStopped(event.common.robot); +} diff --git a/src/software/ai/hl/stp/tactic/stop/stop_fsm.h b/src/software/ai/hl/stp/tactic/stop/halt_fsm.h similarity index 87% rename from src/software/ai/hl/stp/tactic/stop/stop_fsm.h rename to src/software/ai/hl/stp/tactic/stop/halt_fsm.h index d5c35ad38d..7ed1ec2df0 100644 --- a/src/software/ai/hl/stp/tactic/stop/stop_fsm.h +++ b/src/software/ai/hl/stp/tactic/stop/halt_fsm.h @@ -2,7 +2,7 @@ #include "software/ai/hl/stp/tactic/tactic.h" -struct StopFSM +struct HaltFSM { public: class StopState; @@ -14,21 +14,21 @@ struct StopFSM DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS /** - * Constructor for StopFSM struct + * Constructor for HaltFSM struct */ - explicit StopFSM() {} + explicit HaltFSM() {} /** * Action to set the StopPrimitive * - * @param event StopFSM::Update + * @param event HaltFSM::Update */ void updateStop(const Update& event); /** * Guard if the stop is done * - * @param event StopFSM::Update + * @param event HaltFSM::Update * * @return if the robot has stopped */ diff --git a/src/software/ai/hl/stp/tactic/stop/stop_fsm_test.cpp b/src/software/ai/hl/stp/tactic/stop/halt_fsm_test.cpp similarity index 71% rename from src/software/ai/hl/stp/tactic/stop/stop_fsm_test.cpp rename to src/software/ai/hl/stp/tactic/stop/halt_fsm_test.cpp index d4672ab7ae..3d6d381294 100644 --- a/src/software/ai/hl/stp/tactic/stop/stop_fsm_test.cpp +++ b/src/software/ai/hl/stp/tactic/stop/halt_fsm_test.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/tactic/stop/stop_fsm.h" +#include "software/ai/hl/stp/tactic/stop/halt_fsm.h" #include @@ -12,22 +12,22 @@ TEST(StopFSMTest, test_transitions) AngularVelocity::zero()), Timestamp::fromSeconds(123)); - FSM fsm{StopFSM()}; - EXPECT_TRUE(fsm.is(boost::sml::state)); - fsm.process_event(StopFSM::Update( + FSM fsm{HaltFSM()}; + EXPECT_TRUE(fsm.is(boost::sml::state)); + fsm.process_event(HaltFSM::Update( {}, TacticUpdate(robot, world, [](std::shared_ptr) {}))); // robot is still moving - EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is(boost::sml::state)); robot = Robot(0, RobotState(Point(1, -3), Vector(1.1, 2.1), Angle::half(), AngularVelocity::zero()), Timestamp::fromSeconds(123)); - fsm.process_event(StopFSM::Update( + fsm.process_event(HaltFSM::Update( {}, TacticUpdate(robot, world, [](std::shared_ptr) {}))); // robot is still moving - EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is(boost::sml::state)); robot = TestUtil::createRobotAtPos(Point(1, -3)); - fsm.process_event(StopFSM::Update( + fsm.process_event(HaltFSM::Update( {}, TacticUpdate(robot, world, [](std::shared_ptr) {}))); // robot stopped EXPECT_TRUE(fsm.is(boost::sml::X)); diff --git a/src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp b/src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp index c411c060b8..7623d48c5b 100644 --- a/src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp @@ -6,7 +6,7 @@ HaltTactic::HaltTactic() : Tactic(std::set()), fsm_map() { for (RobotId id = 0; id < MAX_ROBOT_IDS; id++) { - fsm_map[id] = std::make_unique>(StopFSM()); + fsm_map[id] = std::make_unique>(HaltFSM()); } } @@ -19,8 +19,8 @@ void HaltTactic::updatePrimitive(const TacticUpdate &tactic_update, bool reset_f { if (reset_fsm) { - fsm_map[tactic_update.robot.id()] = std::make_unique>(StopFSM()); + fsm_map[tactic_update.robot.id()] = std::make_unique>(HaltFSM()); } fsm_map.at(tactic_update.robot.id()) - ->process_event(StopFSM::Update({}, tactic_update)); + ->process_event(HaltFSM::Update({}, tactic_update)); } diff --git a/src/software/ai/hl/stp/tactic/stop/halt_tactic.h b/src/software/ai/hl/stp/tactic/stop/halt_tactic.h index bb07d46f57..d504a30cf2 100644 --- a/src/software/ai/hl/stp/tactic/stop/halt_tactic.h +++ b/src/software/ai/hl/stp/tactic/stop/halt_tactic.h @@ -1,6 +1,6 @@ #pragma once -#include "software/ai/hl/stp/tactic/stop/stop_fsm.h" +#include "software/ai/hl/stp/tactic/stop/halt_fsm.h" #include "software/ai/hl/stp/tactic/tactic.h" /** @@ -22,5 +22,5 @@ class HaltTactic : public Tactic private: void updatePrimitive(const TacticUpdate& tactic_update, bool reset_fsm) override; - std::map>> fsm_map; + std::map>> fsm_map; }; diff --git a/src/software/ai/hl/stp/tactic/stop/stop_fsm.cpp b/src/software/ai/hl/stp/tactic/stop/stop_fsm.cpp deleted file mode 100644 index b8728aaa13..0000000000 --- a/src/software/ai/hl/stp/tactic/stop/stop_fsm.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "software/ai/hl/stp/tactic/stop/stop_fsm.h" - -void StopFSM::updateStop(const Update& event) -{ - event.common.set_primitive(std::make_unique()); -} - -bool StopFSM::stopDone(const Update& event) -{ - return robotStopped(event.common.robot); -} From 3d7810f6e126c34f499bbebf8f6b33d2cddcec55 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 4 Oct 2024 18:28:00 -0700 Subject: [PATCH 05/29] Rename `tactic/stop` folder to `tactic/halt`, renaming addresses where necessary --- src/software/ai/hl/stp/play/BUILD | 8 ++++---- src/software/ai/hl/stp/play/enemy_free_kick/BUILD | 2 +- src/software/ai/hl/stp/play/halt_play.cpp | 2 +- .../ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h | 2 +- src/software/ai/hl/stp/play/play.cpp | 2 +- src/software/ai/hl/stp/play/shoot_or_chip_play.cpp | 2 +- src/software/ai/hl/stp/play/test_plays/BUILD | 2 +- src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp | 2 +- src/software/ai/hl/stp/stp_tactic_assignment_test.cpp | 2 +- src/software/ai/hl/stp/tactic/BUILD | 2 +- src/software/ai/hl/stp/tactic/all_tactics.h | 2 +- src/software/ai/hl/stp/tactic/{stop => halt}/BUILD | 0 src/software/ai/hl/stp/tactic/{stop => halt}/halt_fsm.cpp | 2 +- src/software/ai/hl/stp/tactic/{stop => halt}/halt_fsm.h | 4 ++-- .../ai/hl/stp/tactic/{stop => halt}/halt_fsm_test.cpp | 2 +- .../ai/hl/stp/tactic/{stop => halt}/halt_tactic.cpp | 2 +- .../ai/hl/stp/tactic/{stop => halt}/halt_tactic.h | 2 +- .../ai/hl/stp/tactic/{stop => halt}/halt_tactic_test.cpp | 2 +- 18 files changed, 21 insertions(+), 21 deletions(-) rename src/software/ai/hl/stp/tactic/{stop => halt}/BUILD (100%) rename src/software/ai/hl/stp/tactic/{stop => halt}/halt_fsm.cpp (80%) rename src/software/ai/hl/stp/tactic/{stop => halt}/halt_fsm.h (94%) rename src/software/ai/hl/stp/tactic/{stop => halt}/halt_fsm_test.cpp (96%) rename src/software/ai/hl/stp/tactic/{stop => halt}/halt_tactic.cpp (91%) rename src/software/ai/hl/stp/tactic/{stop => halt}/halt_tactic.h (91%) rename src/software/ai/hl/stp/tactic/{stop => halt}/halt_tactic_test.cpp (97%) diff --git a/src/software/ai/hl/stp/play/BUILD b/src/software/ai/hl/stp/play/BUILD index 202459084e..094bc3eb83 100644 --- a/src/software/ai/hl/stp/play/BUILD +++ b/src/software/ai/hl/stp/play/BUILD @@ -27,7 +27,7 @@ cc_library( deps = [ ":play", "//shared:constants", - "//software/ai/hl/stp/tactic/stop:halt_tactic", + "//software/ai/hl/stp/tactic/halt:halt_tactic", "//software/logger", "//software/util/generic_factory", ], @@ -84,7 +84,7 @@ cc_library( "//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/ai/hl/stp/tactic/stop:halt_tactic", + "//software/ai/hl/stp/tactic/halt:halt_tactic", "//software/logger", "//software/util/generic_factory", "//software/world:game_state", @@ -119,7 +119,7 @@ cc_library( deps = [ "//software/ai/hl/stp/tactic", "//software/ai/hl/stp/tactic/goalie:goalie_tactic", - "//software/ai/hl/stp/tactic/stop:halt_tactic", + "//software/ai/hl/stp/tactic/halt:halt_tactic", "//software/ai/motion_constraint:motion_constraint_set_builder", "//software/ai/navigator/trajectory:trajectory_planner", "//software/ai/passing:pass_with_rating", @@ -303,7 +303,7 @@ cc_library( deps = [ ":play", "//shared:constants", - "//software/ai/hl/stp/tactic/stop:halt_tactic", + "//software/ai/hl/stp/tactic/halt:halt_tactic", "//software/logger", "//software/util/generic_factory", ], diff --git a/src/software/ai/hl/stp/play/enemy_free_kick/BUILD b/src/software/ai/hl/stp/play/enemy_free_kick/BUILD index 716c7d3036..15cf532bca 100644 --- a/src/software/ai/hl/stp/play/enemy_free_kick/BUILD +++ b/src/software/ai/hl/stp/play/enemy_free_kick/BUILD @@ -26,7 +26,7 @@ cc_library( "//software/ai/hl/stp/tactic/goalie:goalie_tactic", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/ai/hl/stp/tactic/pass_defender:pass_defender_tactic", - "//software/ai/hl/stp/tactic/stop:halt_tactic", + "//software/ai/hl/stp/tactic/halt:halt_tactic", "//software/logger", "//software/util/generic_factory", "//software/world:game_state", diff --git a/src/software/ai/hl/stp/play/halt_play.cpp b/src/software/ai/hl/stp/play/halt_play.cpp index 2facb6ff53..0aa2e8ad87 100644 --- a/src/software/ai/hl/stp/play/halt_play.cpp +++ b/src/software/ai/hl/stp/play/halt_play.cpp @@ -1,6 +1,6 @@ #include "software/ai/hl/stp/play/halt_play.h" -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/util/generic_factory/generic_factory.h" HaltPlay::HaltPlay(TbotsProto::AiConfig config) : Play(config, false) {} diff --git a/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h b/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h index ae18c2ef51..b7a21546eb 100644 --- a/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h +++ b/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h @@ -5,7 +5,7 @@ #include "software/ai/hl/stp/play/play_fsm.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.h" -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/logger/logger.h" diff --git a/src/software/ai/hl/stp/play/play.cpp b/src/software/ai/hl/stp/play/play.cpp index 82a3c66af3..0150e313c6 100644 --- a/src/software/ai/hl/stp/play/play.cpp +++ b/src/software/ai/hl/stp/play/play.cpp @@ -5,7 +5,7 @@ #include #include "proto/message_translation/tbots_protobuf.h" -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/ai/motion_constraint/motion_constraint_set_builder.h" #include "software/logger/logger.h" diff --git a/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp b/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp index a36c88c75f..f3a17c65cb 100644 --- a/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp +++ b/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp @@ -9,7 +9,7 @@ #include "software/ai/hl/stp/tactic/crease_defender/crease_defender_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/shadow_enemy/shadow_enemy_tactic.h" -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/logger/logger.h" #include "software/util/generic_factory/generic_factory.h" #include "software/world/game_state.h" diff --git a/src/software/ai/hl/stp/play/test_plays/BUILD b/src/software/ai/hl/stp/play/test_plays/BUILD index aa24703cce..bc08c72b17 100644 --- a/src/software/ai/hl/stp/play/test_plays/BUILD +++ b/src/software/ai/hl/stp/play/test_plays/BUILD @@ -6,7 +6,7 @@ cc_library( hdrs = ["halt_test_play.h"], deps = [ "//software/ai/hl/stp/play", - "//software/ai/hl/stp/tactic/stop:halt_tactic", + "//software/ai/hl/stp/tactic/halt:halt_tactic", "//software/util/generic_factory", ], alwayslink = True, diff --git a/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp b/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp index a7f83c13e7..95b84e9af0 100644 --- a/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp +++ b/src/software/ai/hl/stp/play/test_plays/halt_test_play.cpp @@ -1,6 +1,6 @@ #include "software/ai/hl/stp/play/test_plays/halt_test_play.h" -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/geom/algorithms/contains.h" #include "software/util/generic_factory/generic_factory.h" diff --git a/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp b/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp index 3957f15a21..78a5cce5b0 100644 --- a/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp +++ b/src/software/ai/hl/stp/stp_tactic_assignment_test.cpp @@ -6,7 +6,7 @@ #include "software/ai/hl/stp/play/halt_play.h" #include "software/ai/hl/stp/stp.h" #include "software/ai/hl/stp/tactic/all_tactics.h" -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/test_util/test_util.h" /** diff --git a/src/software/ai/hl/stp/tactic/BUILD b/src/software/ai/hl/stp/tactic/BUILD index dc9c8a7e3d..76961d6d90 100644 --- a/src/software/ai/hl/stp/tactic/BUILD +++ b/src/software/ai/hl/stp/tactic/BUILD @@ -28,7 +28,7 @@ cc_library( "//software/ai/hl/stp/tactic/pivot_kick:pivot_kick_tactic", "//software/ai/hl/stp/tactic/receiver:receiver_tactic", "//software/ai/hl/stp/tactic/shadow_enemy:shadow_enemy_tactic", - "//software/ai/hl/stp/tactic/stop:halt_tactic", + "//software/ai/hl/stp/tactic/halt:halt_tactic", ], ) diff --git a/src/software/ai/hl/stp/tactic/all_tactics.h b/src/software/ai/hl/stp/tactic/all_tactics.h index 960ef5633e..286e6f71f8 100644 --- a/src/software/ai/hl/stp/tactic/all_tactics.h +++ b/src/software/ai/hl/stp/tactic/all_tactics.h @@ -13,5 +13,5 @@ #include "software/ai/hl/stp/tactic/pivot_kick/pivot_kick_tactic.h" #include "software/ai/hl/stp/tactic/receiver/receiver_tactic.h" #include "software/ai/hl/stp/tactic/shadow_enemy/shadow_enemy_tactic.h" -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/ai/hl/stp/tactic/tactic.h" diff --git a/src/software/ai/hl/stp/tactic/stop/BUILD b/src/software/ai/hl/stp/tactic/halt/BUILD similarity index 100% rename from src/software/ai/hl/stp/tactic/stop/BUILD rename to src/software/ai/hl/stp/tactic/halt/BUILD diff --git a/src/software/ai/hl/stp/tactic/stop/halt_fsm.cpp b/src/software/ai/hl/stp/tactic/halt/halt_fsm.cpp similarity index 80% rename from src/software/ai/hl/stp/tactic/stop/halt_fsm.cpp rename to src/software/ai/hl/stp/tactic/halt/halt_fsm.cpp index a874a305c5..c8ca316eb3 100644 --- a/src/software/ai/hl/stp/tactic/stop/halt_fsm.cpp +++ b/src/software/ai/hl/stp/tactic/halt/halt_fsm.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/tactic/stop/halt_fsm.h" +#include "software/ai/hl/stp/tactic/halt/halt_fsm.h" void HaltFSM::updateStop(const Update& event) { diff --git a/src/software/ai/hl/stp/tactic/stop/halt_fsm.h b/src/software/ai/hl/stp/tactic/halt/halt_fsm.h similarity index 94% rename from src/software/ai/hl/stp/tactic/stop/halt_fsm.h rename to src/software/ai/hl/stp/tactic/halt/halt_fsm.h index 7ed1ec2df0..dae78c1112 100644 --- a/src/software/ai/hl/stp/tactic/stop/halt_fsm.h +++ b/src/software/ai/hl/stp/tactic/halt/halt_fsm.h @@ -26,11 +26,11 @@ struct HaltFSM void updateStop(const Update& event); /** - * Guard if the stop is done + * Guard if the halt is done * * @param event HaltFSM::Update * - * @return if the robot has stopped + * @return if the robot has halted */ bool stopDone(const Update& event); diff --git a/src/software/ai/hl/stp/tactic/stop/halt_fsm_test.cpp b/src/software/ai/hl/stp/tactic/halt/halt_fsm_test.cpp similarity index 96% rename from src/software/ai/hl/stp/tactic/stop/halt_fsm_test.cpp rename to src/software/ai/hl/stp/tactic/halt/halt_fsm_test.cpp index 3d6d381294..849ac30428 100644 --- a/src/software/ai/hl/stp/tactic/stop/halt_fsm_test.cpp +++ b/src/software/ai/hl/stp/tactic/halt/halt_fsm_test.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/tactic/stop/halt_fsm.h" +#include "software/ai/hl/stp/tactic/halt/halt_fsm.h" #include diff --git a/src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp b/src/software/ai/hl/stp/tactic/halt/halt_tactic.cpp similarity index 91% rename from src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp rename to src/software/ai/hl/stp/tactic/halt/halt_tactic.cpp index 7623d48c5b..49e6e1fe01 100644 --- a/src/software/ai/hl/stp/tactic/stop/halt_tactic.cpp +++ b/src/software/ai/hl/stp/tactic/halt/halt_tactic.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include diff --git a/src/software/ai/hl/stp/tactic/stop/halt_tactic.h b/src/software/ai/hl/stp/tactic/halt/halt_tactic.h similarity index 91% rename from src/software/ai/hl/stp/tactic/stop/halt_tactic.h rename to src/software/ai/hl/stp/tactic/halt/halt_tactic.h index d504a30cf2..39bce73916 100644 --- a/src/software/ai/hl/stp/tactic/stop/halt_tactic.h +++ b/src/software/ai/hl/stp/tactic/halt/halt_tactic.h @@ -1,6 +1,6 @@ #pragma once -#include "software/ai/hl/stp/tactic/stop/halt_fsm.h" +#include "software/ai/hl/stp/tactic/halt/halt_fsm.h" #include "software/ai/hl/stp/tactic/tactic.h" /** diff --git a/src/software/ai/hl/stp/tactic/stop/halt_tactic_test.cpp b/src/software/ai/hl/stp/tactic/halt/halt_tactic_test.cpp similarity index 97% rename from src/software/ai/hl/stp/tactic/stop/halt_tactic_test.cpp rename to src/software/ai/hl/stp/tactic/halt/halt_tactic_test.cpp index d6f44c9bb3..e2867bae07 100644 --- a/src/software/ai/hl/stp/tactic/stop/halt_tactic_test.cpp +++ b/src/software/ai/hl/stp/tactic/halt/halt_tactic_test.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/tactic/stop/halt_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include From 922210f456e37febce6d36f0e92ff87887d4f000 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 5 Oct 2024 01:51:48 +0000 Subject: [PATCH 06/29] [pre-commit.ci lite] apply automatic fixes --- docs/fsm-diagrams.md | 30 +++++++++---------- src/software/ai/hl/stp/play/BUILD | 2 +- .../ai/hl/stp/play/enemy_free_kick/BUILD | 2 +- .../play/penalty_kick/penalty_kick_play_fsm.h | 2 +- .../ai/hl/stp/play/shoot_or_chip_play.cpp | 2 +- src/software/ai/hl/stp/tactic/BUILD | 2 +- src/software/ai/hl/stp/tactic/all_tactics.h | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/fsm-diagrams.md b/docs/fsm-diagrams.md index be8fd153c5..7dbe3e5538 100644 --- a/docs/fsm-diagrams.md +++ b/docs/fsm-diagrams.md @@ -314,6 +314,21 @@ Terminate:::terminate --> Terminate:::terminate ``` +## [HaltFSM](/src/software/ai/hl/stp/tactic/halt/halt_fsm.h) + +```mermaid + +stateDiagram-v2 +classDef terminate fill:white,color:black,font-weight:bold +direction LR +[*] --> StopState +StopState --> StopState : [!stopDone]\nupdateStop +StopState --> Terminate:::terminate : [stopDone]\nupdateStop +Terminate:::terminate --> StopState : [!stopDone]\nupdateStop +Terminate:::terminate --> Terminate:::terminate : [stopDone]\nupdateStop + +``` + ## [KickFSM](/src/software/ai/hl/stp/tactic/kick/kick_fsm.h) ```mermaid @@ -441,18 +456,3 @@ Terminate:::terminate --> Terminate:::terminate : SET_STOP_PRIMITIVE_ACTION StopState -StopState --> StopState : [!stopDone]\nupdateStop -StopState --> Terminate:::terminate : [stopDone]\nupdateStop -Terminate:::terminate --> StopState : [!stopDone]\nupdateStop -Terminate:::terminate --> Terminate:::terminate : [stopDone]\nupdateStop - -``` - diff --git a/src/software/ai/hl/stp/play/BUILD b/src/software/ai/hl/stp/play/BUILD index 094bc3eb83..6074c57c7d 100644 --- a/src/software/ai/hl/stp/play/BUILD +++ b/src/software/ai/hl/stp/play/BUILD @@ -82,9 +82,9 @@ cc_library( "//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/ai/hl/stp/tactic/halt:halt_tactic", "//software/logger", "//software/util/generic_factory", "//software/world:game_state", diff --git a/src/software/ai/hl/stp/play/enemy_free_kick/BUILD b/src/software/ai/hl/stp/play/enemy_free_kick/BUILD index 15cf532bca..552211c67d 100644 --- a/src/software/ai/hl/stp/play/enemy_free_kick/BUILD +++ b/src/software/ai/hl/stp/play/enemy_free_kick/BUILD @@ -24,9 +24,9 @@ cc_library( "//software/ai/hl/stp/play/defense:defense_play_base", "//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/pass_defender:pass_defender_tactic", - "//software/ai/hl/stp/tactic/halt:halt_tactic", "//software/logger", "//software/util/generic_factory", "//software/world:game_state", diff --git a/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h b/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h index b7a21546eb..5fe8a5481c 100644 --- a/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h +++ b/src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_fsm.h @@ -3,9 +3,9 @@ #include "proto/parameters.pb.h" #include "shared/constants.h" #include "software/ai/hl/stp/play/play_fsm.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/penalty_kick/penalty_kick_tactic.h" -#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/logger/logger.h" diff --git a/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp b/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp index f3a17c65cb..1192ea3080 100644 --- a/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp +++ b/src/software/ai/hl/stp/play/shoot_or_chip_play.cpp @@ -7,9 +7,9 @@ #include "software/ai/evaluation/possession.h" #include "software/ai/hl/stp/tactic/attacker/attacker_tactic.h" #include "software/ai/hl/stp/tactic/crease_defender/crease_defender_tactic.h" +#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/ai/hl/stp/tactic/shadow_enemy/shadow_enemy_tactic.h" -#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/logger/logger.h" #include "software/util/generic_factory/generic_factory.h" #include "software/world/game_state.h" diff --git a/src/software/ai/hl/stp/tactic/BUILD b/src/software/ai/hl/stp/tactic/BUILD index 76961d6d90..505da40cd1 100644 --- a/src/software/ai/hl/stp/tactic/BUILD +++ b/src/software/ai/hl/stp/tactic/BUILD @@ -21,6 +21,7 @@ cc_library( "//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/move:move_tactic", "//software/ai/hl/stp/tactic/pass_defender:pass_defender_tactic", @@ -28,7 +29,6 @@ cc_library( "//software/ai/hl/stp/tactic/pivot_kick:pivot_kick_tactic", "//software/ai/hl/stp/tactic/receiver:receiver_tactic", "//software/ai/hl/stp/tactic/shadow_enemy:shadow_enemy_tactic", - "//software/ai/hl/stp/tactic/halt:halt_tactic", ], ) diff --git a/src/software/ai/hl/stp/tactic/all_tactics.h b/src/software/ai/hl/stp/tactic/all_tactics.h index 286e6f71f8..9ca1d50a4e 100644 --- a/src/software/ai/hl/stp/tactic/all_tactics.h +++ b/src/software/ai/hl/stp/tactic/all_tactics.h @@ -6,6 +6,7 @@ #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/move/move_tactic.h" #include "software/ai/hl/stp/tactic/pass_defender/pass_defender_tactic.h" @@ -13,5 +14,4 @@ #include "software/ai/hl/stp/tactic/pivot_kick/pivot_kick_tactic.h" #include "software/ai/hl/stp/tactic/receiver/receiver_tactic.h" #include "software/ai/hl/stp/tactic/shadow_enemy/shadow_enemy_tactic.h" -#include "software/ai/hl/stp/tactic/halt/halt_tactic.h" #include "software/ai/hl/stp/tactic/tactic.h" From fc274283e872627432889aa19f611571bc2bcb40 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 4 Oct 2024 20:07:30 -0700 Subject: [PATCH 07/29] Small consistency improvements --- src/proto/tactic.proto | 2 +- src/software/ai/hl/stp/tactic/tactic_factory.cpp | 2 +- src/software/field_tests/movement_robot_field_test.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/proto/tactic.proto b/src/proto/tactic.proto index 055f006b46..797a10070f 100644 --- a/src/proto/tactic.proto +++ b/src/proto/tactic.proto @@ -28,7 +28,7 @@ message Tactic PivotKickTactic pivot_kick = 11; ReceiverTactic receiver = 12; ShadowEnemyTactic shadow_enemy = 13; - HaltTactic stop = 14; + HaltTactic halt = 14; PassDefenderTactic pass_defender = 15; } } diff --git a/src/software/ai/hl/stp/tactic/tactic_factory.cpp b/src/software/ai/hl/stp/tactic/tactic_factory.cpp index f85a1272d7..4ced87df53 100644 --- a/src/software/ai/hl/stp/tactic/tactic_factory.cpp +++ b/src/software/ai/hl/stp/tactic/tactic_factory.cpp @@ -29,7 +29,7 @@ std::shared_ptr createTactic(const TbotsProto::Tactic &tactic_proto, PROTO_CREATE_TACTIC_CASE(PivotKick, pivot_kick) PROTO_CREATE_TACTIC_CASE(Receiver, receiver) PROTO_CREATE_TACTIC_CASE(ShadowEnemy, shadow_enemy) - PROTO_CREATE_TACTIC_CASE(Stop, stop) + PROTO_CREATE_TACTIC_CASE(Halt, halt) case TbotsProto::Tactic::TACTIC_NOT_SET: { LOG(FATAL) << "Tactic not set"; diff --git a/src/software/field_tests/movement_robot_field_test.py b/src/software/field_tests/movement_robot_field_test.py index 358f559429..3713e5eeb0 100644 --- a/src/software/field_tests/movement_robot_field_test.py +++ b/src/software/field_tests/movement_robot_field_test.py @@ -121,7 +121,7 @@ def test_basic_rotation(field_test_runner): halt_tactic = HaltTactic() params = AssignedTacticPlayControlParams() params.assigned_tactics[id].stop.CopyFrom(halt_tactic) - # send the stop tactic + # send the halt tactic field_test_runner.set_tactics(params, True) # validate by eye From 12d8ecc1cb3a5c9488168a112365965940315429 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 4 Oct 2024 20:44:00 -0700 Subject: [PATCH 08/29] Small consistency improvements --- src/software/ai/hl/stp/play/play.cpp | 2 +- src/software/ai/hl/stp/play/play.h | 2 +- src/software/field_tests/passing_field_test.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/software/ai/hl/stp/play/play.cpp b/src/software/ai/hl/stp/play/play.cpp index 0150e313c6..dd317da133 100644 --- a/src/software/ai/hl/stp/play/play.cpp +++ b/src/software/ai/hl/stp/play/play.cpp @@ -189,7 +189,7 @@ std::unique_ptr Play::get( else if (i == (priority_tactics.size() - 1)) { // If assigning the last tactic vector, then assign rest of robots with - // StopTactics + // HaltTactics for (unsigned int ii = 0; ii < (robots.size() - num_tactics); ii++) { tactic_vector.push_back(halt_tactics[ii]); diff --git a/src/software/ai/hl/stp/play/play.h b/src/software/ai/hl/stp/play/play.h index f79a3bce23..cad46f0206 100644 --- a/src/software/ai/hl/stp/play/play.h +++ b/src/software/ai/hl/stp/play/play.h @@ -170,7 +170,7 @@ class Play virtual void getNextTactics(TacticCoroutine::push_type& yield, const WorldPtr& world_ptr) = 0; - // Stop tactic common to all plays for robots that don't have tactics assigned + // HaltTactics common to all plays for robots that don't have tactics assigned TacticVector halt_tactics; // Whether this play requires a goalie diff --git a/src/software/field_tests/passing_field_test.py b/src/software/field_tests/passing_field_test.py index 3d1c5ffdb0..7240754338 100644 --- a/src/software/field_tests/passing_field_test.py +++ b/src/software/field_tests/passing_field_test.py @@ -97,11 +97,10 @@ def test_passing(field_test_runner): ) # Send a halt tactic after the test finishes - halt_tactic = StopTactic() + halt_tactic = HaltTactic() params = AssignedTacticPlayControlParams() params.assigned_tactics[passer_robot_id].stop.CopyFrom(halt_tactic) params.assigned_tactics[receiver_robot_id].stop.CopyFrom(halt_tactic) - # send the stop tactic field_test_runner.set_tactics(params, True) From cca2c0b7d5ee417b38620b8c19796f47f4da8aa3 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sat, 19 Oct 2024 12:04:44 -0700 Subject: [PATCH 09/29] Create `example` directory containing all example plays (fsm incomplete) --- src/software/ai/hl/stp/play/BUILD | 30 +------------ src/software/ai/hl/stp/play/example/BUILD | 42 +++++++++++++++++++ .../stp/play/{ => example}/example_play.cpp | 2 +- .../hl/stp/play/{ => example}/example_play.h | 0 .../hl/stp/play/example/example_play_fsm.cpp | 1 + .../ai/hl/stp/play/example/example_play_fsm.h | 4 ++ .../play/{ => example}/example_play_test.cpp | 2 +- 7 files changed, 50 insertions(+), 31 deletions(-) create mode 100644 src/software/ai/hl/stp/play/example/BUILD rename src/software/ai/hl/stp/play/{ => example}/example_play.cpp (96%) rename src/software/ai/hl/stp/play/{ => example}/example_play.h (100%) create mode 100644 src/software/ai/hl/stp/play/example/example_play_fsm.cpp create mode 100644 src/software/ai/hl/stp/play/example/example_play_fsm.h rename src/software/ai/hl/stp/play/{ => example}/example_play_test.cpp (97%) diff --git a/src/software/ai/hl/stp/play/BUILD b/src/software/ai/hl/stp/play/BUILD index 6074c57c7d..0eaa90a1f1 100644 --- a/src/software/ai/hl/stp/play/BUILD +++ b/src/software/ai/hl/stp/play/BUILD @@ -6,20 +6,6 @@ load("@simulated_tests_deps//:requirements.bzl", "requirement") # "factory" design pattern to work are linked in # https://www.bfilipek.com/2018/02/static-vars-static-lib.html -cc_library( - name = "example_play", - srcs = ["example_play.cpp"], - hdrs = ["example_play.h"], - deps = [ - ":play", - "//shared:constants", - "//software/ai/hl/stp/tactic/move:move_tactic", - "//software/logger", - "//software/util/generic_factory", - ], - alwayslink = True, -) - cc_library( name = "halt_play", srcs = ["halt_play.cpp"], @@ -133,7 +119,6 @@ cc_library( cc_library( name = "all_plays", deps = [ - ":example_play", ":halt_play", ":kickoff_enemy_play", ":kickoff_friendly_play", @@ -144,6 +129,7 @@ cc_library( "//software/ai/hl/stp/play/defense:defense_play", "//software/ai/hl/stp/play/enemy_ball_placement:enemy_ball_placement_play", "//software/ai/hl/stp/play/enemy_free_kick:enemy_free_kick_play", + "//software/ai/hl/stp/play/example:example_play", "//software/ai/hl/stp/play/free_kick:free_kick_play", "//software/ai/hl/stp/play/hardware_challenge_plays:dribbling_parcour_play", "//software/ai/hl/stp/play/hardware_challenge_plays:pass_endurance_play", @@ -156,20 +142,6 @@ cc_library( ], ) -cc_test( - name = "example_play_test", - srcs = ["example_play_test.cpp"], - deps = [ - "//shared/test_util:tbots_gtest_main", - "//software/ai/hl/stp/play:example_play", - "//software/simulated_tests:simulated_er_force_sim_play_test_fixture", - "//software/simulated_tests/validation:validation_function", - "//software/test_util", - "//software/time:duration", - "//software/world", - ], -) - cc_test( name = "kickoff_friendly_play_cpp_test", srcs = ["kickoff_friendly_play_test.cpp"], diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD new file mode 100644 index 0000000000..271f9909fc --- /dev/null +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -0,0 +1,42 @@ +package(default_visibility = ["//visibility:public"]) + +# We force linking for all plays so that the static variables required for the +# "factory" design pattern to work are linked in +# https://www.bfilipek.com/2018/02/static-vars-static-lib.html + +cc_library( + name = "example_play", + srcs = ["example_play.cpp"], + hdrs = ["example_play.h"], + deps = [ + "//shared:constants", + "//software/ai/hl/stp/tactic/move:move_tactic", + "//software/logger", + "//software/util/generic_factory", + ], + alwayslink = True, +) + +cc_test( + name = "example_play_fsm_test", + srcs = ["example_play_fsm_test.cpp"], + deps = [ + ":example_play", + "//shared/test_util:tbots_gtest_main", + "//software/test_util", + ], +) + +cc_test( + name = "example_play_test", + srcs = ["example_play_test.cpp"], + deps = [ + "//shared/test_util:tbots_gtest_main", + "//software/ai/hl/stp/play/example:example_play", + "//software/simulated_tests:simulated_er_force_sim_play_test_fixture", + "//software/simulated_tests/validation:validation_function", + "//software/test_util", + "//software/time:duration", + "//software/world", + ], +) \ No newline at end of file diff --git a/src/software/ai/hl/stp/play/example_play.cpp b/src/software/ai/hl/stp/play/example/example_play.cpp similarity index 96% rename from src/software/ai/hl/stp/play/example_play.cpp rename to src/software/ai/hl/stp/play/example/example_play.cpp index e9480f767b..de7606962a 100644 --- a/src/software/ai/hl/stp/play/example_play.cpp +++ b/src/software/ai/hl/stp/play/example/example_play.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/play/example_play.h" +#include "software/ai/hl/stp/play/example/example_play.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" #include "software/util/generic_factory/generic_factory.h" diff --git a/src/software/ai/hl/stp/play/example_play.h b/src/software/ai/hl/stp/play/example/example_play.h similarity index 100% rename from src/software/ai/hl/stp/play/example_play.h rename to src/software/ai/hl/stp/play/example/example_play.h diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp new file mode 100644 index 0000000000..5eb456a2ee --- /dev/null +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -0,0 +1 @@ +#include "software/ai/hl/stp/play/example/example_play_fsm.h" diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h new file mode 100644 index 0000000000..cebe74a29d --- /dev/null +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -0,0 +1,4 @@ +#ifndef UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H +#define UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H + +#endif //UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H diff --git a/src/software/ai/hl/stp/play/example_play_test.cpp b/src/software/ai/hl/stp/play/example/example_play_test.cpp similarity index 97% rename from src/software/ai/hl/stp/play/example_play_test.cpp rename to src/software/ai/hl/stp/play/example/example_play_test.cpp index 6916f08391..b44bc815d3 100644 --- a/src/software/ai/hl/stp/play/example_play_test.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_test.cpp @@ -1,4 +1,4 @@ -#include "software/ai/hl/stp/play/example_play.h" +#include "software/ai/hl/stp/play/example/example_play.h" #include From 95aeed1b3504f7409090867b3248db48919b9c50 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sat, 26 Oct 2024 11:40:45 -0700 Subject: [PATCH 10/29] Create `example` directory containing all example plays (FSM incomplete) `example_play_fsm.cpp` and associated files have not been implemented; planned to be implemented next commit --- src/software/ai/hl/stp/play/example/BUILD | 15 ++++-- .../ai/hl/stp/play/example/example_play.cpp | 49 +++++++---------- .../ai/hl/stp/play/example/example_play.h | 20 +++++-- .../hl/stp/play/example/example_play_fsm.cpp | 52 +++++++++++++++++++ .../ai/hl/stp/play/example/example_play_fsm.h | 36 +++++++++++-- .../play/example/example_play_fsm_test.cpp | 5 ++ 6 files changed, 134 insertions(+), 43 deletions(-) create mode 100644 src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD index 271f9909fc..8598ccd266 100644 --- a/src/software/ai/hl/stp/play/example/BUILD +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -1,15 +1,20 @@ package(default_visibility = ["//visibility:public"]) -# We force linking for all plays so that the static variables required for the -# "factory" design pattern to work are linked in -# https://www.bfilipek.com/2018/02/static-vars-static-lib.html +load("@simulated_tests_deps//:requirements.bzl", "requirement") cc_library( name = "example_play", - srcs = ["example_play.cpp"], - hdrs = ["example_play.h"], + srcs = [ + "example_play.cpp", + "example_play_fsm.cpp" + ], + hdrs = [ + "example_play.h", + "example_play_fsm.h" + ], deps = [ "//shared:constants", + "//software/ai/hl/stp/play", "//software/ai/hl/stp/tactic/move:move_tactic", "//software/logger", "//software/util/generic_factory", diff --git a/src/software/ai/hl/stp/play/example/example_play.cpp b/src/software/ai/hl/stp/play/example/example_play.cpp index de7606962a..a8525b51be 100644 --- a/src/software/ai/hl/stp/play/example/example_play.cpp +++ b/src/software/ai/hl/stp/play/example/example_play.cpp @@ -1,42 +1,31 @@ #include "software/ai/hl/stp/play/example/example_play.h" -#include "software/ai/hl/stp/tactic/move/move_tactic.h" +#include "shared/constants.h" #include "software/util/generic_factory/generic_factory.h" -ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) : Play(config, false) {} +ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) + : Play(config, true), fsm{ExamplePlayFSM{config}}, control_params{} +{ +} void ExamplePlay::getNextTactics(TacticCoroutine::push_type &yield, - const WorldPtr &world_ptr) + const WorldPtr &world_ptr) { - std::vector> move_tactics(DIV_A_NUM_ROBOTS); - std::generate(move_tactics.begin(), move_tactics.end(), - []() { return std::make_shared(); }); - - // Continue to loop to demonstrate the example play indefinitely - do - { - // The angle between each robot spaced out in a circle around the ball - Angle angle_between_robots = - Angle::full() / static_cast(move_tactics.size()); - - for (size_t k = 0; k < move_tactics.size(); k++) - { - move_tactics[k]->updateControlParams( - world_ptr->ball().position() + - Vector::createFromAngle(angle_between_robots * - static_cast(k + 1)), - (angle_between_robots * static_cast(k + 1)) + Angle::half()); - } + // This function doesn't get called and it will be removed once coroutines are phased + // out +} - // yield the Tactics this Play wants to run, in order of priority - // If there are fewer robots in play, robots at the end of the list will not be - // assigned - TacticVector result = {}; - result.insert(result.end(), move_tactics.begin(), move_tactics.end()); - yield({result}); +void ExamplePlay::updateTactics(const PlayUpdate &play_update) +{ + fsm.process_event(ExamplePlayFSM::Update(control_params, play_update)); +} - } while (true); +std::vector ExamplePlay::getState() +{ + std::vector state; + state.emplace_back(objectTypeName(*this) + " - " + getCurrentFullStateName(fsm)); + return state; } // Register this play in the genericFactory -static TGenericFactory factory; +static TGenericFactory factory; \ No newline at end of file diff --git a/src/software/ai/hl/stp/play/example/example_play.h b/src/software/ai/hl/stp/play/example/example_play.h index e42c936767..515ea0f5b5 100644 --- a/src/software/ai/hl/stp/play/example/example_play.h +++ b/src/software/ai/hl/stp/play/example/example_play.h @@ -1,16 +1,26 @@ #pragma once -#include "proto/parameters.pb.h" -#include "software/ai/hl/stp/play/play.h" +#include "software/ai/hl/stp/play/example/example_play_fsm.h" /** - * An example Play that moves the robots in a circle around the ball + * An example play that moves the robots in a circle around the ball */ class ExamplePlay : public Play { - public: - explicit ExamplePlay(TbotsProto::AiConfig config); +public: + /** + * Creates an example play + * + * @param ai_config the play config for this play + */ + ExamplePlay(TbotsProto::AiConfig config); void getNextTactics(TacticCoroutine::push_type &yield, const WorldPtr &world_ptr) override; + void updateTactics(const PlayUpdate &play_update) override; + std::vector getState() override; + +private: + FSM fsm; + ExamplePlayFSM::ControlParams control_params; }; diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp index 5eb456a2ee..6414845d8c 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -1 +1,53 @@ #include "software/ai/hl/stp/play/example/example_play_fsm.h" + +ExamplePlayFSM::ExamplePlayFSM(const TbotsProto::AiConfig &ai_config) + : ai_config(ai_config) +{ +} + + +/* +#include "software/ai/hl/stp/play/example/example_play.h" + +#include "software/ai/hl/stp/tactic/move/move_tactic.h" +#include "software/util/generic_factory/generic_factory.h" + +ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) : Play(config, false) {} + +void ExamplePlay::getNextTactics(TacticCoroutine::push_type &yield, + const WorldPtr &world_ptr) +{ + std::vector> move_tactics(DIV_A_NUM_ROBOTS); + std::generate(move_tactics.begin(), move_tactics.end(), + []() { return std::make_shared(); }); + + // Continue to loop to demonstrate the example play indefinitely + do + { + // The angle between each robot spaced out in a circle around the ball + Angle angle_between_robots = + Angle::full() / static_cast(move_tactics.size()); + + for (size_t k = 0; k < move_tactics.size(); k++) + { + move_tactics[k]->updateControlParams( + world_ptr->ball().position() + + Vector::createFromAngle(angle_between_robots * + static_cast(k + 1)), + (angle_between_robots * static_cast(k + 1)) + Angle::half()); + } + + // yield the Tactics this Play wants to run, in order of priority + // If there are fewer robots in play, robots at the end of the list will not be + // assigned + TacticVector result = {}; + result.insert(result.end(), move_tactics.begin(), move_tactics.end()); + yield({result}); + + } while (true); +} + +// Register this play in the genericFactory +static TGenericFactory factory; + + */ \ No newline at end of file diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h index cebe74a29d..7c3806f005 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.h +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -1,4 +1,34 @@ -#ifndef UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H -#define UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H +#pragma once -#endif //UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H +#include "proto/parameters.pb.h" +#include "shared/constants.h" +#include "software/ai/hl/stp/play/play.h" +#include "software/ai/hl/stp/tactic/move/move_tactic.h" +#include "software/util/generic_factory/generic_factory.h" + +/** + * An example Play that moves the robots in a circle around the ball + * */ + +struct ExamplePlayFSM +{ + struct ControlParams + { + // TODO + }; + + DEFINE_PLAY_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS + + auto operator()() + { + using namespace boost::sml; + + DEFINE_SML_EVENT(Update) + // TODO + + return make_transition_table( + // src_state + event [guard] / action = dest_state + + ); // TODO + } +}; \ No newline at end of file diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp new file mode 100644 index 0000000000..68ab1aba36 --- /dev/null +++ b/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp @@ -0,0 +1,5 @@ +// +// Created by daniel on 2024-10-26. +// + +//TODO \ No newline at end of file From c470919143cbc5fb110169822f6900ca394db9b0 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sat, 26 Oct 2024 11:57:05 -0700 Subject: [PATCH 11/29] Copy relevant code from other fsm plays to `example_play` files Still giving errors, as `example_play_fsm.cpp` has not been implemented --- .../ai/hl/stp/play/example/example_play_fsm.h | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h index cebe74a29d..6acde9f803 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.h +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -1,4 +1,35 @@ -#ifndef UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H -#define UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H +#pragma once -#endif //UBC_THUNDERBOTS_SOFTWARE_EXAMPLE_PLAY_FSM_H +#include "proto/parameters.pb.h" +#include "shared/constants.h" +#include "software/ai/hl/stp/play/play.h" +#include "software/ai/hl/stp/tactic/move/move_tactic.h" +#include "software/util/generic_factory/generic_factory.h" + +/** + * An example Play that moves the robots in a circle around the ball + * */ + +struct ExamplePlayFSM +{ + struct ControlParams + { + // TODO + }; + + DEFINE_PLAY_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS + + auto operator()() + { + using namespace boost::sml; + + DEFINE_SML_EVENT(Update) + // TODO + + return make_transition_table( + // src_state + event [guard] / action = dest_state + + // X + Update_E = X); + ); // TODO + } +}; \ No newline at end of file From 3585ac771414de550c3e8a4b87af7311049794b4 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sat, 26 Oct 2024 15:37:05 -0700 Subject: [PATCH 12/29] Remove `example_play_fsm_test.cpp` --- src/software/ai/hl/stp/play/example/BUILD | 10 ---------- .../ai/hl/stp/play/example/example_play_fsm_test.cpp | 5 ----- 2 files changed, 15 deletions(-) delete mode 100644 src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD index 8598ccd266..b6e0d2cf3d 100644 --- a/src/software/ai/hl/stp/play/example/BUILD +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -22,16 +22,6 @@ cc_library( alwayslink = True, ) -cc_test( - name = "example_play_fsm_test", - srcs = ["example_play_fsm_test.cpp"], - deps = [ - ":example_play", - "//shared/test_util:tbots_gtest_main", - "//software/test_util", - ], -) - cc_test( name = "example_play_test", srcs = ["example_play_test.cpp"], diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp deleted file mode 100644 index 68ab1aba36..0000000000 --- a/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// Created by daniel on 2024-10-26. -// - -//TODO \ No newline at end of file From 1d9248d57d842964f6520dcfa07405294bcec1d8 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sat, 26 Oct 2024 15:38:06 -0700 Subject: [PATCH 13/29] Implement `example_play_fsm.cpp` and `example_play_fsm.h` Debugging still necessary, as the `example_play_test.cpp` is not passing --- .../hl/stp/play/example/example_play_fsm.cpp | 55 ++++++------------- .../ai/hl/stp/play/example/example_play_fsm.h | 31 +++++++++-- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp index 6414845d8c..1e71366ee4 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -5,49 +5,28 @@ ExamplePlayFSM::ExamplePlayFSM(const TbotsProto::AiConfig &ai_config) { } - -/* -#include "software/ai/hl/stp/play/example/example_play.h" - -#include "software/ai/hl/stp/tactic/move/move_tactic.h" -#include "software/util/generic_factory/generic_factory.h" - -ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) : Play(config, false) {} - -void ExamplePlay::getNextTactics(TacticCoroutine::push_type &yield, - const WorldPtr &world_ptr) +void ExamplePlayFSM::moveToPosition(const Update &event) { std::vector> move_tactics(DIV_A_NUM_ROBOTS); std::generate(move_tactics.begin(), move_tactics.end(), []() { return std::make_shared(); }); - // Continue to loop to demonstrate the example play indefinitely - do - { - // The angle between each robot spaced out in a circle around the ball - Angle angle_between_robots = + // The angle between each robot spaced out in a circle around the ball + Angle angle_between_robots = Angle::full() / static_cast(move_tactics.size()); - for (size_t k = 0; k < move_tactics.size(); k++) - { - move_tactics[k]->updateControlParams( - world_ptr->ball().position() + - Vector::createFromAngle(angle_between_robots * - static_cast(k + 1)), + for (size_t k = 0; k < move_tactics.size(); k++) + { + move_tactics[k]->updateControlParams( + event.common.world_ptr->ball().position() + + Vector::createFromAngle(angle_between_robots * + static_cast(k + 1)), (angle_between_robots * static_cast(k + 1)) + Angle::half()); - } - - // yield the Tactics this Play wants to run, in order of priority - // If there are fewer robots in play, robots at the end of the list will not be - // assigned - TacticVector result = {}; - result.insert(result.end(), move_tactics.begin(), move_tactics.end()); - yield({result}); - - } while (true); -} - -// Register this play in the genericFactory -static TGenericFactory factory; - - */ \ No newline at end of file + } + +// // yield the Tactics this Play wants to run, in order of priority +// // If there are fewer robots in play, robots at the end of the list will not be assigned +// TacticVector result = {}; +// result.insert(result.end(), move_tactics.begin(), move_tactics.end()); +// yield({result}); +} \ No newline at end of file diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h index 6acde9f803..6832339950 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.h +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -4,7 +4,7 @@ #include "shared/constants.h" #include "software/ai/hl/stp/play/play.h" #include "software/ai/hl/stp/tactic/move/move_tactic.h" -#include "software/util/generic_factory/generic_factory.h" +#include "software/logger/logger.h" /** * An example Play that moves the robots in a circle around the ball @@ -12,24 +12,45 @@ struct ExamplePlayFSM { + class MoveState; + struct ControlParams { - // TODO }; DEFINE_PLAY_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS + /** + * Creates an example play FSM + * + * @param ai_config the play config for this play FSM + */ + explicit ExamplePlayFSM(const TbotsProto::AiConfig& ai_config); + + /** + * Action that moves the robots to certain positions around the ball + * + * @param event the ExamplePlayFSM Update event + */ + void moveToPosition(const Update& event); + auto operator()() { using namespace boost::sml; + DEFINE_SML_STATE(MoveState) + DEFINE_SML_EVENT(Update) - // TODO + + DEFINE_SML_ACTION(moveToPosition) return make_transition_table( // src_state + event [guard] / action = dest_state + *MoveState_S + Update_E / moveToPosition_A = MoveState_S, - // X + Update_E = X); - ); // TODO + X + Update_E = X); } + + private: + TbotsProto::AiConfig ai_config; }; \ No newline at end of file From 54afbb4bab9ab7d882d35a5b47efd0dc2ad19ef6 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sun, 27 Oct 2024 22:54:38 -0700 Subject: [PATCH 14/29] Debug `example_play_fsm.cpp` test case works now yippee --- .../ai/hl/stp/play/example/example_play_fsm.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp index 1e71366ee4..ac42be99c3 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -24,9 +24,9 @@ void ExamplePlayFSM::moveToPosition(const Update &event) (angle_between_robots * static_cast(k + 1)) + Angle::half()); } -// // yield the Tactics this Play wants to run, in order of priority -// // If there are fewer robots in play, robots at the end of the list will not be assigned -// TacticVector result = {}; -// result.insert(result.end(), move_tactics.begin(), move_tactics.end()); -// yield({result}); + // set the Tactics this Play wants to run, in order of priority + // If there are fewer robots in play, robots at the end of the list will not be assigned + TacticVector result = {}; + result.insert(result.end(), move_tactics.begin(), move_tactics.end()); + event.common.set_tactics({result}); } \ No newline at end of file From 9631d554354e4450b3a00182493cbc71379eb469 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sun, 27 Oct 2024 23:32:20 -0700 Subject: [PATCH 15/29] comment fix --- src/software/ai/hl/stp/play/example/example_play_fsm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h index 6832339950..aec795db22 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.h +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -8,7 +8,7 @@ /** * An example Play that moves the robots in a circle around the ball - * */ + */ struct ExamplePlayFSM { From e6d5f47fb851afcf85e11d99ae9d0fe276d77ee1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 06:42:23 +0000 Subject: [PATCH 16/29] [pre-commit.ci lite] apply automatic fixes --- docs/fsm-diagrams.md | 13 +++++++++++++ src/software/ai/hl/stp/play/example/BUILD | 6 +++--- .../ai/hl/stp/play/example/example_play.cpp | 4 ++-- src/software/ai/hl/stp/play/example/example_play.h | 4 ++-- .../ai/hl/stp/play/example/example_play_fsm.cpp | 12 ++++++------ .../ai/hl/stp/play/example/example_play_fsm.h | 8 ++++---- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/docs/fsm-diagrams.md b/docs/fsm-diagrams.md index 7dbe3e5538..a096f26e24 100644 --- a/docs/fsm-diagrams.md +++ b/docs/fsm-diagrams.md @@ -106,6 +106,19 @@ Terminate:::terminate --> Terminate:::terminate ``` +## [ExamplePlayFSM](/src/software/ai/hl/stp/play/example/example_play_fsm.h) + +```mermaid + +stateDiagram-v2 +classDef terminate fill:white,color:black,font-weight:bold +direction LR +[*] --> MoveState +MoveState --> MoveState : moveToPosition +Terminate:::terminate --> Terminate:::terminate + +``` + ## [FreeKickPlayFSM](/src/software/ai/hl/stp/play/free_kick/free_kick_play_fsm.h) ```mermaid diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD index b6e0d2cf3d..f9fed145c9 100644 --- a/src/software/ai/hl/stp/play/example/BUILD +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -6,11 +6,11 @@ cc_library( name = "example_play", srcs = [ "example_play.cpp", - "example_play_fsm.cpp" + "example_play_fsm.cpp", ], hdrs = [ "example_play.h", - "example_play_fsm.h" + "example_play_fsm.h", ], deps = [ "//shared:constants", @@ -34,4 +34,4 @@ cc_test( "//software/time:duration", "//software/world", ], -) \ No newline at end of file +) diff --git a/src/software/ai/hl/stp/play/example/example_play.cpp b/src/software/ai/hl/stp/play/example/example_play.cpp index a8525b51be..254048d5ec 100644 --- a/src/software/ai/hl/stp/play/example/example_play.cpp +++ b/src/software/ai/hl/stp/play/example/example_play.cpp @@ -9,7 +9,7 @@ ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) } void ExamplePlay::getNextTactics(TacticCoroutine::push_type &yield, - const WorldPtr &world_ptr) + const WorldPtr &world_ptr) { // This function doesn't get called and it will be removed once coroutines are phased // out @@ -28,4 +28,4 @@ std::vector ExamplePlay::getState() } // Register this play in the genericFactory -static TGenericFactory factory; \ No newline at end of file +static TGenericFactory factory; diff --git a/src/software/ai/hl/stp/play/example/example_play.h b/src/software/ai/hl/stp/play/example/example_play.h index 515ea0f5b5..debf856cdf 100644 --- a/src/software/ai/hl/stp/play/example/example_play.h +++ b/src/software/ai/hl/stp/play/example/example_play.h @@ -7,7 +7,7 @@ */ class ExamplePlay : public Play { -public: + public: /** * Creates an example play * @@ -20,7 +20,7 @@ class ExamplePlay : public Play void updateTactics(const PlayUpdate &play_update) override; std::vector getState() override; -private: + private: FSM fsm; ExamplePlayFSM::ControlParams control_params; }; diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp index ac42be99c3..993d9c8110 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -12,21 +12,21 @@ void ExamplePlayFSM::moveToPosition(const Update &event) []() { return std::make_shared(); }); // The angle between each robot spaced out in a circle around the ball - Angle angle_between_robots = - Angle::full() / static_cast(move_tactics.size()); + Angle angle_between_robots = Angle::full() / static_cast(move_tactics.size()); for (size_t k = 0; k < move_tactics.size(); k++) { move_tactics[k]->updateControlParams( - event.common.world_ptr->ball().position() + + event.common.world_ptr->ball().position() + Vector::createFromAngle(angle_between_robots * static_cast(k + 1)), - (angle_between_robots * static_cast(k + 1)) + Angle::half()); + (angle_between_robots * static_cast(k + 1)) + Angle::half()); } // set the Tactics this Play wants to run, in order of priority - // If there are fewer robots in play, robots at the end of the list will not be assigned + // If there are fewer robots in play, robots at the end of the list will not be + // assigned TacticVector result = {}; result.insert(result.end(), move_tactics.begin(), move_tactics.end()); event.common.set_tactics({result}); -} \ No newline at end of file +} diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h index aec795db22..eed567b82e 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.h +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -45,12 +45,12 @@ struct ExamplePlayFSM DEFINE_SML_ACTION(moveToPosition) return make_transition_table( - // src_state + event [guard] / action = dest_state - *MoveState_S + Update_E / moveToPosition_A = MoveState_S, + // src_state + event [guard] / action = dest_state + *MoveState_S + Update_E / moveToPosition_A = MoveState_S, - X + Update_E = X); + X + Update_E = X); } private: TbotsProto::AiConfig ai_config; -}; \ No newline at end of file +}; From 8d7531316eae7981f536781c78b4fcf03e33b4ad Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Tue, 29 Oct 2024 17:03:58 -0700 Subject: [PATCH 17/29] Remove `AIConfig` from example plays --- src/software/ai/hl/stp/play/example/example_play.cpp | 5 ----- src/software/ai/hl/stp/play/example/example_play_fsm.cpp | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play.cpp b/src/software/ai/hl/stp/play/example/example_play.cpp index 254048d5ec..4ae9d3b3c6 100644 --- a/src/software/ai/hl/stp/play/example/example_play.cpp +++ b/src/software/ai/hl/stp/play/example/example_play.cpp @@ -3,11 +3,6 @@ #include "shared/constants.h" #include "software/util/generic_factory/generic_factory.h" -ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) - : Play(config, true), fsm{ExamplePlayFSM{config}}, control_params{} -{ -} - void ExamplePlay::getNextTactics(TacticCoroutine::push_type &yield, const WorldPtr &world_ptr) { diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp index 993d9c8110..1faa805669 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -1,10 +1,5 @@ #include "software/ai/hl/stp/play/example/example_play_fsm.h" -ExamplePlayFSM::ExamplePlayFSM(const TbotsProto::AiConfig &ai_config) - : ai_config(ai_config) -{ -} - void ExamplePlayFSM::moveToPosition(const Update &event) { std::vector> move_tactics(DIV_A_NUM_ROBOTS); From b44573a4dfda7557bd2ea3a2fd51522a125e63e6 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Mon, 11 Nov 2024 12:41:09 -0800 Subject: [PATCH 18/29] Implement suggestions from @williamckha --- src/software/ai/hl/stp/play/example/example_play.cpp | 5 +++++ src/software/ai/hl/stp/play/example/example_play.h | 5 ----- src/software/ai/hl/stp/play/example/example_play_fsm.cpp | 8 +++++--- src/software/ai/hl/stp/play/example/example_play_fsm.h | 5 ++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play.cpp b/src/software/ai/hl/stp/play/example/example_play.cpp index 4ae9d3b3c6..9fdcac08a4 100644 --- a/src/software/ai/hl/stp/play/example/example_play.cpp +++ b/src/software/ai/hl/stp/play/example/example_play.cpp @@ -3,6 +3,11 @@ #include "shared/constants.h" #include "software/util/generic_factory/generic_factory.h" +ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) +: Play(config, false), fsm{ExamplePlayFSM{}}, control_params{} +{ +} + void ExamplePlay::getNextTactics(TacticCoroutine::push_type &yield, const WorldPtr &world_ptr) { diff --git a/src/software/ai/hl/stp/play/example/example_play.h b/src/software/ai/hl/stp/play/example/example_play.h index debf856cdf..8bc63ea2ba 100644 --- a/src/software/ai/hl/stp/play/example/example_play.h +++ b/src/software/ai/hl/stp/play/example/example_play.h @@ -8,11 +8,6 @@ class ExamplePlay : public Play { public: - /** - * Creates an example play - * - * @param ai_config the play config for this play - */ ExamplePlay(TbotsProto::AiConfig config); void getNextTactics(TacticCoroutine::push_type &yield, diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp index 1faa805669..01aef73add 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -1,11 +1,13 @@ #include "software/ai/hl/stp/play/example/example_play_fsm.h" -void ExamplePlayFSM::moveToPosition(const Update &event) +ExamplePlayFSM::ExamplePlayFSM() : move_tactics(DIV_A_NUM_ROBOTS) { - std::vector> move_tactics(DIV_A_NUM_ROBOTS); std::generate(move_tactics.begin(), move_tactics.end(), []() { return std::make_shared(); }); +} +void ExamplePlayFSM::moveToPosition(const Update &event) +{ // The angle between each robot spaced out in a circle around the ball Angle angle_between_robots = Angle::full() / static_cast(move_tactics.size()); @@ -24,4 +26,4 @@ void ExamplePlayFSM::moveToPosition(const Update &event) TacticVector result = {}; result.insert(result.end(), move_tactics.begin(), move_tactics.end()); event.common.set_tactics({result}); -} +} \ No newline at end of file diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h index eed567b82e..40345afbbd 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.h +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -23,9 +23,8 @@ struct ExamplePlayFSM /** * Creates an example play FSM * - * @param ai_config the play config for this play FSM */ - explicit ExamplePlayFSM(const TbotsProto::AiConfig& ai_config); + explicit ExamplePlayFSM(); /** * Action that moves the robots to certain positions around the ball @@ -52,5 +51,5 @@ struct ExamplePlayFSM } private: - TbotsProto::AiConfig ai_config; + std::vector> move_tactics; }; From fb504d20a529f4a8963779e9699407365784b534 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 20:52:10 +0000 Subject: [PATCH 19/29] [pre-commit.ci lite] apply automatic fixes --- src/software/ai/hl/stp/play/example/example_play.cpp | 2 +- src/software/ai/hl/stp/play/example/example_play_fsm.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play.cpp b/src/software/ai/hl/stp/play/example/example_play.cpp index 9fdcac08a4..ecece8d333 100644 --- a/src/software/ai/hl/stp/play/example/example_play.cpp +++ b/src/software/ai/hl/stp/play/example/example_play.cpp @@ -4,7 +4,7 @@ #include "software/util/generic_factory/generic_factory.h" ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) -: Play(config, false), fsm{ExamplePlayFSM{}}, control_params{} + : Play(config, false), fsm{ExamplePlayFSM{}}, control_params{} { } diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp index 01aef73add..3ab434698d 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -26,4 +26,4 @@ void ExamplePlayFSM::moveToPosition(const Update &event) TacticVector result = {}; result.insert(result.end(), move_tactics.begin(), move_tactics.end()); event.common.set_tactics({result}); -} \ No newline at end of file +} From ad79923581603c459b29d237f0fb0982abc514d5 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Mon, 11 Nov 2024 12:58:08 -0800 Subject: [PATCH 20/29] Create `example_play_fsm_test.cpp` Copied from #3398 by @potatoisagender --- src/software/ai/hl/stp/play/example/BUILD | 10 +++++++ .../play/example/example_play_fsm_test.cpp | 27 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD index f9fed145c9..9e7db953e5 100644 --- a/src/software/ai/hl/stp/play/example/BUILD +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -35,3 +35,13 @@ cc_test( "//software/world", ], ) + +cc_test( + name = "example_play_fsm_test", + srcs = ["example_play_fsm_test.cpp"], + deps = [ + ":example_play", + "//shared/test_util:tbots_gtest_main", + "//software/test_util", + ], +) diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp new file mode 100644 index 0000000000..0368db12fb --- /dev/null +++ b/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp @@ -0,0 +1,27 @@ +#include "software/ai/hl/stp/play/example/example_play_fsm.h" + +#include + +#include "proto/parameters.pb.h" +#include "software/test_util/equal_within_tolerance.h" +#include "software/test_util/test_util.h" + +TEST(ExamplePlayFSMTest, test_transitions) +{ +std::shared_ptr world = ::TestUtil::createBlankTestingWorld(); +TbotsProto::AiConfig ai_config; + +FSM fsm(ExamplePlayFSM{}); + +EXPECT_TRUE(fsm.is(boost::sml::state)); + +int num_tactics = 6; + +fsm.process_event(ExamplePlayFSM::Update( + ExamplePlayFSM::ControlParams{}, + PlayUpdate( + world, num_tactics, [](PriorityTacticVector new_tactics) {}, + InterPlayCommunication{}, [](InterPlayCommunication comm) {}))); + +EXPECT_TRUE(fsm.is(boost::sml::state)); +} \ No newline at end of file From de099bc7fc369ab4e79c217bcea661dfdfcd4ff6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 21:08:39 +0000 Subject: [PATCH 21/29] [pre-commit.ci lite] apply automatic fixes --- .../play/example/example_play_fsm_test.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp index 0368db12fb..8bf6bc5a83 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm_test.cpp @@ -8,20 +8,20 @@ TEST(ExamplePlayFSMTest, test_transitions) { -std::shared_ptr world = ::TestUtil::createBlankTestingWorld(); -TbotsProto::AiConfig ai_config; + std::shared_ptr world = ::TestUtil::createBlankTestingWorld(); + TbotsProto::AiConfig ai_config; -FSM fsm(ExamplePlayFSM{}); + FSM fsm(ExamplePlayFSM{}); -EXPECT_TRUE(fsm.is(boost::sml::state)); + EXPECT_TRUE(fsm.is(boost::sml::state)); -int num_tactics = 6; + int num_tactics = 6; -fsm.process_event(ExamplePlayFSM::Update( + fsm.process_event(ExamplePlayFSM::Update( ExamplePlayFSM::ControlParams{}, PlayUpdate( - world, num_tactics, [](PriorityTacticVector new_tactics) {}, - InterPlayCommunication{}, [](InterPlayCommunication comm) {}))); + world, num_tactics, [](PriorityTacticVector new_tactics) {}, + InterPlayCommunication{}, [](InterPlayCommunication comm) {}))); -EXPECT_TRUE(fsm.is(boost::sml::state)); -} \ No newline at end of file + EXPECT_TRUE(fsm.is(boost::sml::state)); +} From fceadea92c4eaa53b435db60351cc5153a595554 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sat, 1 Feb 2025 12:26:34 -0800 Subject: [PATCH 22/29] temp push done so i can merge from remote --- src/software/ai/hl/stp/play/example/BUILD | 16 ++++ .../hl/stp/play/example/example_play_test.py | 85 +++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 src/software/ai/hl/stp/play/example/example_play_test.py diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD index 9e7db953e5..4c155bc0fe 100644 --- a/src/software/ai/hl/stp/play/example/BUILD +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -45,3 +45,19 @@ cc_test( "//software/test_util", ], ) + +py_test( + name = "example_play_test_py", + main = "example_play_test.py", + srcs = ["example_play_test.py"], + # TODO (#2619) Remove tag to run in parallel + tags = [ + "exclusive", + ], + deps = [ + "//software:conftest", + "//software/simulated_tests:speed_threshold_helpers", + "//software/simulated_tests:validation", + requirement("pytest"), + ], +) \ No newline at end of file diff --git a/src/software/ai/hl/stp/play/example/example_play_test.py b/src/software/ai/hl/stp/play/example/example_play_test.py new file mode 100644 index 0000000000..885fa8cb39 --- /dev/null +++ b/src/software/ai/hl/stp/play/example/example_play_test.py @@ -0,0 +1,85 @@ +import sys + +import pytest + +import software.python_bindings as tbots_cpp +from software.simulated_tests.robot_speed_threshold import * +from proto.message_translation.tbots_protobuf import create_world_state +from proto.ssl_gc_common_pb2 import Team + + +# TODO issue #2599 - Remove Duration parameter from test +# @pytest.mark.parametrize("run_enemy_ai,test_duration", [(False, 20), (True, 20)]) +def test_example_play(simulated_test_runner): + def setup(*args): + # starting point must be Point + ball_initial_pos = tbots_cpp.Point(0, 0) + + # Setup Bots + blue_bots = [ + tbots_cpp.Point(-3, 2.5), + tbots_cpp.Point(-3, 1.5), + tbots_cpp.Point(-3, 0.5), + tbots_cpp.Point(-3, -0.5), + tbots_cpp.Point(-3, -1.5), + tbots_cpp.Point(-3, -2.5), + ] + + yellow_bots = [ + tbots_cpp.Point(1, 0), + tbots_cpp.Point(1, 2.5), + tbots_cpp.Point(1, -2.5), + tbots_cpp.Field.createSSLDivisionBField().enemyGoalCenter(), + tbots_cpp.Field.createSSLDivisionBField() + .enemyDefenseArea() + .negXNegYCorner(), + tbots_cpp.Field.createSSLDivisionBField() + .enemyDefenseArea() + .negXPosYCorner(), + ] + + # Game Controller Setup + simulated_test_runner.gamecontroller.send_gc_command( + gc_command=Command.Type.STOP, team=Team.UNKNOWN + ) + simulated_test_runner.gamecontroller.send_gc_command( + gc_command=Command.Type.FORCE_START, team=Team.UNKNOWN + ) + + # Structure for a delayed call is tuple (delay in seconds, command, team) + (3, Command.Type.HALT, Team.BLUE) + (3, Command.Type.HALT, Team.YELLOW) + + # No plays to override. AI does whatever for 3 seconds before HALT CMD + # is issued + + # Create world state + simulated_test_runner.simulator_proto_unix_io.send_proto( + WorldState, + create_world_state( + yellow_robot_locations=yellow_bots, + blue_robot_locations=blue_bots, + ball_location=ball_initial_pos, + ball_velocity=tbots_cpp.Vector(0, 0), + ), + ) + + # params just have to be a list of length 1 to ensure the test runs at least once + simulated_test_runner.run_test( + setup=setup, + params=[0], + inv_always_validation_sequence_set=[[]], + inv_eventually_validation_sequence_set=[ + [RobotSpeedEventuallyBelowThreshold(1e-3)] + ], + ag_always_validation_sequence_set=[[]], + ag_eventually_validation_sequence_set=[ + [RobotSpeedEventuallyBelowThreshold(1e-3)] + ], + test_timeout_s=10, + ) + + +if __name__ == "__main__": + # Run the test, -s disables all capturing at -vv increases verbosity + sys.exit(pytest.main([__file__, "-svv"])) \ No newline at end of file From 55c63454fbe007e12f2b71d528cf0d6c9fff7cb7 Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sat, 8 Feb 2025 11:38:34 -0800 Subject: [PATCH 23/29] (try to) Merge master branch into own branch --- src/software/ai/hl/stp/play/example/BUILD | 8 ++++++++ src/software/ai/hl/stp/play/example/example_play.cpp | 4 ++-- src/software/ai/hl/stp/play/example/example_play.h | 9 +++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD index 4c155bc0fe..ac36743ad2 100644 --- a/src/software/ai/hl/stp/play/example/BUILD +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -6,11 +6,19 @@ cc_library( name = "example_play", srcs = [ "example_play.cpp", +<<<<<<< Updated upstream "example_play_fsm.cpp", ], hdrs = [ "example_play.h", "example_play_fsm.h", +======= + "example_play_fsm.cpp" + ], + hdrs = [ + "example_play.h", + "example_play_fsm.h" +>>>>>>> Stashed changes ], deps = [ "//shared:constants", diff --git a/src/software/ai/hl/stp/play/example/example_play.cpp b/src/software/ai/hl/stp/play/example/example_play.cpp index ecece8d333..0f7f69e3c0 100644 --- a/src/software/ai/hl/stp/play/example/example_play.cpp +++ b/src/software/ai/hl/stp/play/example/example_play.cpp @@ -9,7 +9,7 @@ ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) } void ExamplePlay::getNextTactics(TacticCoroutine::push_type &yield, - const WorldPtr &world_ptr) + const WorldPtr &world_ptr) { // This function doesn't get called and it will be removed once coroutines are phased // out @@ -28,4 +28,4 @@ std::vector ExamplePlay::getState() } // Register this play in the genericFactory -static TGenericFactory factory; +static TGenericFactory factory; \ No newline at end of file diff --git a/src/software/ai/hl/stp/play/example/example_play.h b/src/software/ai/hl/stp/play/example/example_play.h index 8bc63ea2ba..515ea0f5b5 100644 --- a/src/software/ai/hl/stp/play/example/example_play.h +++ b/src/software/ai/hl/stp/play/example/example_play.h @@ -7,7 +7,12 @@ */ class ExamplePlay : public Play { - public: +public: + /** + * Creates an example play + * + * @param ai_config the play config for this play + */ ExamplePlay(TbotsProto::AiConfig config); void getNextTactics(TacticCoroutine::push_type &yield, @@ -15,7 +20,7 @@ class ExamplePlay : public Play void updateTactics(const PlayUpdate &play_update) override; std::vector getState() override; - private: +private: FSM fsm; ExamplePlayFSM::ControlParams control_params; }; From 201be90a9e9a288af25286c2d3a640ee949ed21e Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Sat, 8 Feb 2025 11:42:30 -0800 Subject: [PATCH 24/29] Remove merge conflict in `play/example/BUILD` --- src/software/ai/hl/stp/play/example/BUILD | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD index ac36743ad2..4c155bc0fe 100644 --- a/src/software/ai/hl/stp/play/example/BUILD +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -6,19 +6,11 @@ cc_library( name = "example_play", srcs = [ "example_play.cpp", -<<<<<<< Updated upstream "example_play_fsm.cpp", ], hdrs = [ "example_play.h", "example_play_fsm.h", -======= - "example_play_fsm.cpp" - ], - hdrs = [ - "example_play.h", - "example_play_fsm.h" ->>>>>>> Stashed changes ], deps = [ "//shared:constants", From 2d30eb1cecc7549655d3fb043661798045e1d95c Mon Sep 17 00:00:00 2001 From: Daniel Liang Date: Mon, 17 Feb 2025 14:23:01 -0800 Subject: [PATCH 25/29] Resolve `.BUILD` merge conflict --- src/software/ai/hl/stp/play/BUILD | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/software/ai/hl/stp/play/BUILD b/src/software/ai/hl/stp/play/BUILD index 1a9ed3a4b5..bd9c16119d 100644 --- a/src/software/ai/hl/stp/play/BUILD +++ b/src/software/ai/hl/stp/play/BUILD @@ -105,11 +105,6 @@ cc_library( cc_library( name = "all_plays", deps = [ -<<<<<<< HEAD - ":halt_play", -======= - ":example_play", ->>>>>>> 23ff0f61c523d7aee00121b913e860825af523d8 ":kickoff_enemy_play", ":kickoff_friendly_play", ":shoot_or_chip_play", From 67d1ee6a9e47c148ae3edbaf3b53a7d4ccf94a51 Mon Sep 17 00:00:00 2001 From: Grayson Hoang Date: Tue, 29 Apr 2025 11:03:12 -0700 Subject: [PATCH 26/29] Adds pytests for example play --- .../hl/stp/play/example/example_play_test.py | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play_test.py b/src/software/ai/hl/stp/play/example/example_play_test.py index 885fa8cb39..745bb35bc4 100644 --- a/src/software/ai/hl/stp/play/example/example_play_test.py +++ b/src/software/ai/hl/stp/play/example/example_play_test.py @@ -3,18 +3,17 @@ import pytest import software.python_bindings as tbots_cpp +from software.simulated_tests.robot_enters_region import NumberOfRobotsEventuallyExitsRegion, NumberOfRobotsEventuallyEntersRegion from software.simulated_tests.robot_speed_threshold import * from proto.message_translation.tbots_protobuf import create_world_state from proto.ssl_gc_common_pb2 import Team - +from proto.play_pb2 import Play, PlayName # TODO issue #2599 - Remove Duration parameter from test # @pytest.mark.parametrize("run_enemy_ai,test_duration", [(False, 20), (True, 20)]) def test_example_play(simulated_test_runner): + ball_initial_pos = tbots_cpp.Point(0,0) def setup(*args): - # starting point must be Point - ball_initial_pos = tbots_cpp.Point(0, 0) - # Setup Bots blue_bots = [ tbots_cpp.Point(-3, 2.5), @@ -38,20 +37,30 @@ def setup(*args): .negXPosYCorner(), ] + # Force play override here + blue_play = Play() + blue_play.name = PlayName.ExamplePlay + + yellow_play = Play() + yellow_play.name = PlayName.HaltPlay + + simulated_test_runner.blue_full_system_proto_unix_io.send_proto(Play, blue_play) + simulated_test_runner.yellow_full_system_proto_unix_io.send_proto( + Play, yellow_play + ) + # Game Controller Setup simulated_test_runner.gamecontroller.send_gc_command( gc_command=Command.Type.STOP, team=Team.UNKNOWN ) simulated_test_runner.gamecontroller.send_gc_command( - gc_command=Command.Type.FORCE_START, team=Team.UNKNOWN + gc_command=Command.Type.NORMAL_START, team=Team.BLUE + ) + simulated_test_runner.gamecontroller.send_gc_command( + gc_command=Command.Type.DIRECT, team=Team.BLUE ) - # Structure for a delayed call is tuple (delay in seconds, command, team) - (3, Command.Type.HALT, Team.BLUE) - (3, Command.Type.HALT, Team.YELLOW) - # No plays to override. AI does whatever for 3 seconds before HALT CMD - # is issued # Create world state simulated_test_runner.simulator_proto_unix_io.send_proto( @@ -69,13 +78,15 @@ def setup(*args): setup=setup, params=[0], inv_always_validation_sequence_set=[[]], - inv_eventually_validation_sequence_set=[ - [RobotSpeedEventuallyBelowThreshold(1e-3)] - ], + inv_eventually_validation_sequence_set=[[NumberOfRobotsEventuallyEntersRegion( + region=tbots_cpp.Circle(ball_initial_pos, 1.1), + req_robot_cnt=6 + ), NumberOfRobotsEventuallyExitsRegion( + region=tbots_cpp.Circle(ball_initial_pos, 0.9), + req_robot_cnt=6 + )]], ag_always_validation_sequence_set=[[]], - ag_eventually_validation_sequence_set=[ - [RobotSpeedEventuallyBelowThreshold(1e-3)] - ], + ag_eventually_validation_sequence_set=[[]], test_timeout_s=10, ) From c2998e24b787042bb39f8df48352f67abefd4906 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, 29 Apr 2025 18:26:20 +0000 Subject: [PATCH 27/29] [pre-commit.ci lite] apply automatic fixes --- src/software/ai/hl/stp/play/example/BUILD | 4 +- .../ai/hl/stp/play/example/example_play.cpp | 4 +- .../ai/hl/stp/play/example/example_play.h | 4 +- .../hl/stp/play/example/example_play_test.py | 38 +++++++++++-------- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/BUILD b/src/software/ai/hl/stp/play/example/BUILD index 4c155bc0fe..91ba8b5d23 100644 --- a/src/software/ai/hl/stp/play/example/BUILD +++ b/src/software/ai/hl/stp/play/example/BUILD @@ -48,8 +48,8 @@ cc_test( py_test( name = "example_play_test_py", - main = "example_play_test.py", srcs = ["example_play_test.py"], + main = "example_play_test.py", # TODO (#2619) Remove tag to run in parallel tags = [ "exclusive", @@ -60,4 +60,4 @@ py_test( "//software/simulated_tests:validation", requirement("pytest"), ], -) \ No newline at end of file +) diff --git a/src/software/ai/hl/stp/play/example/example_play.cpp b/src/software/ai/hl/stp/play/example/example_play.cpp index 0f7f69e3c0..ecece8d333 100644 --- a/src/software/ai/hl/stp/play/example/example_play.cpp +++ b/src/software/ai/hl/stp/play/example/example_play.cpp @@ -9,7 +9,7 @@ ExamplePlay::ExamplePlay(TbotsProto::AiConfig config) } void ExamplePlay::getNextTactics(TacticCoroutine::push_type &yield, - const WorldPtr &world_ptr) + const WorldPtr &world_ptr) { // This function doesn't get called and it will be removed once coroutines are phased // out @@ -28,4 +28,4 @@ std::vector ExamplePlay::getState() } // Register this play in the genericFactory -static TGenericFactory factory; \ No newline at end of file +static TGenericFactory factory; diff --git a/src/software/ai/hl/stp/play/example/example_play.h b/src/software/ai/hl/stp/play/example/example_play.h index 515ea0f5b5..debf856cdf 100644 --- a/src/software/ai/hl/stp/play/example/example_play.h +++ b/src/software/ai/hl/stp/play/example/example_play.h @@ -7,7 +7,7 @@ */ class ExamplePlay : public Play { -public: + public: /** * Creates an example play * @@ -20,7 +20,7 @@ class ExamplePlay : public Play void updateTactics(const PlayUpdate &play_update) override; std::vector getState() override; -private: + private: FSM fsm; ExamplePlayFSM::ControlParams control_params; }; diff --git a/src/software/ai/hl/stp/play/example/example_play_test.py b/src/software/ai/hl/stp/play/example/example_play_test.py index 745bb35bc4..e5dda1f1a0 100644 --- a/src/software/ai/hl/stp/play/example/example_play_test.py +++ b/src/software/ai/hl/stp/play/example/example_play_test.py @@ -3,16 +3,21 @@ import pytest import software.python_bindings as tbots_cpp -from software.simulated_tests.robot_enters_region import NumberOfRobotsEventuallyExitsRegion, NumberOfRobotsEventuallyEntersRegion +from software.simulated_tests.robot_enters_region import ( + NumberOfRobotsEventuallyExitsRegion, + NumberOfRobotsEventuallyEntersRegion, +) from software.simulated_tests.robot_speed_threshold import * from proto.message_translation.tbots_protobuf import create_world_state from proto.ssl_gc_common_pb2 import Team from proto.play_pb2 import Play, PlayName + # TODO issue #2599 - Remove Duration parameter from test # @pytest.mark.parametrize("run_enemy_ai,test_duration", [(False, 20), (True, 20)]) def test_example_play(simulated_test_runner): - ball_initial_pos = tbots_cpp.Point(0,0) + ball_initial_pos = tbots_cpp.Point(0, 0) + def setup(*args): # Setup Bots blue_bots = [ @@ -30,11 +35,11 @@ def setup(*args): tbots_cpp.Point(1, -2.5), tbots_cpp.Field.createSSLDivisionBField().enemyGoalCenter(), tbots_cpp.Field.createSSLDivisionBField() - .enemyDefenseArea() - .negXNegYCorner(), + .enemyDefenseArea() + .negXNegYCorner(), tbots_cpp.Field.createSSLDivisionBField() - .enemyDefenseArea() - .negXPosYCorner(), + .enemyDefenseArea() + .negXPosYCorner(), ] # Force play override here @@ -60,8 +65,6 @@ def setup(*args): gc_command=Command.Type.DIRECT, team=Team.BLUE ) - - # Create world state simulated_test_runner.simulator_proto_unix_io.send_proto( WorldState, @@ -78,13 +81,16 @@ def setup(*args): setup=setup, params=[0], inv_always_validation_sequence_set=[[]], - inv_eventually_validation_sequence_set=[[NumberOfRobotsEventuallyEntersRegion( - region=tbots_cpp.Circle(ball_initial_pos, 1.1), - req_robot_cnt=6 - ), NumberOfRobotsEventuallyExitsRegion( - region=tbots_cpp.Circle(ball_initial_pos, 0.9), - req_robot_cnt=6 - )]], + inv_eventually_validation_sequence_set=[ + [ + NumberOfRobotsEventuallyEntersRegion( + region=tbots_cpp.Circle(ball_initial_pos, 1.1), req_robot_cnt=6 + ), + NumberOfRobotsEventuallyExitsRegion( + region=tbots_cpp.Circle(ball_initial_pos, 0.9), req_robot_cnt=6 + ), + ] + ], ag_always_validation_sequence_set=[[]], ag_eventually_validation_sequence_set=[[]], test_timeout_s=10, @@ -93,4 +99,4 @@ def setup(*args): if __name__ == "__main__": # Run the test, -s disables all capturing at -vv increases verbosity - sys.exit(pytest.main([__file__, "-svv"])) \ No newline at end of file + sys.exit(pytest.main([__file__, "-svv"])) From facfc19659a80ae800667178beb111b432ccdfd2 Mon Sep 17 00:00:00 2001 From: williamckha Date: Thu, 15 May 2025 12:47:12 -0700 Subject: [PATCH 28/29] Small fixes --- src/software/ai/hl/stp/play/example/example_play_fsm.cpp | 2 +- src/software/ai/hl/stp/play/example/example_play_fsm.h | 5 +---- src/software/ai/hl/stp/play/example/example_play_test.py | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp index 3ab434698d..a3528a40e1 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.cpp +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.cpp @@ -20,7 +20,7 @@ void ExamplePlayFSM::moveToPosition(const Update &event) (angle_between_robots * static_cast(k + 1)) + Angle::half()); } - // set the Tactics this Play wants to run, in order of priority + // Set the Tactics this Play wants to run, in order of priority. // If there are fewer robots in play, robots at the end of the list will not be // assigned TacticVector result = {}; diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h index 40345afbbd..04254bb78a 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.h +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -7,9 +7,8 @@ #include "software/logger/logger.h" /** - * An example Play that moves the robots in a circle around the ball + * An example play that moves the robots in a circle around the ball */ - struct ExamplePlayFSM { class MoveState; @@ -22,7 +21,6 @@ struct ExamplePlayFSM /** * Creates an example play FSM - * */ explicit ExamplePlayFSM(); @@ -46,7 +44,6 @@ struct ExamplePlayFSM return make_transition_table( // src_state + event [guard] / action = dest_state *MoveState_S + Update_E / moveToPosition_A = MoveState_S, - X + Update_E = X); } diff --git a/src/software/ai/hl/stp/play/example/example_play_test.py b/src/software/ai/hl/stp/play/example/example_play_test.py index e5dda1f1a0..ef5560feb1 100644 --- a/src/software/ai/hl/stp/play/example/example_play_test.py +++ b/src/software/ai/hl/stp/play/example/example_play_test.py @@ -13,8 +13,6 @@ from proto.play_pb2 import Play, PlayName -# TODO issue #2599 - Remove Duration parameter from test -# @pytest.mark.parametrize("run_enemy_ai,test_duration", [(False, 20), (True, 20)]) def test_example_play(simulated_test_runner): ball_initial_pos = tbots_cpp.Point(0, 0) From 3515714a5cdb6fcede6a1e9001b03af3724f9f58 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, 15 May 2025 19:59:38 +0000 Subject: [PATCH 29/29] [pre-commit.ci lite] apply automatic fixes --- src/software/ai/hl/stp/play/example/example_play_fsm.h | 3 +-- src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/software/ai/hl/stp/play/example/example_play_fsm.h b/src/software/ai/hl/stp/play/example/example_play_fsm.h index 04254bb78a..53b6947b74 100644 --- a/src/software/ai/hl/stp/play/example/example_play_fsm.h +++ b/src/software/ai/hl/stp/play/example/example_play_fsm.h @@ -43,8 +43,7 @@ struct ExamplePlayFSM return make_transition_table( // src_state + event [guard] / action = dest_state - *MoveState_S + Update_E / moveToPosition_A = MoveState_S, - X + Update_E = X); + *MoveState_S + Update_E / moveToPosition_A = MoveState_S, X + Update_E = X); } private: diff --git a/src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h b/src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h index 7afb334997..38283aa7d5 100644 --- a/src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h +++ b/src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h @@ -11,7 +11,7 @@ struct KeepAwayFSM * * @param ai_config The config to fetch parameters from */ - explicit KeepAwayFSM(const TbotsProto::AiConfig& ai_config) : ai_config(ai_config){}; + explicit KeepAwayFSM(const TbotsProto::AiConfig& ai_config) : ai_config(ai_config) {}; struct ControlParams {