From 717941281d9b2626d9734ad491b063ac6bfcd869 Mon Sep 17 00:00:00 2001 From: DArtagnant <105509558+DArtagnant@users.noreply.github.com> Date: Sat, 8 Jun 2024 18:37:13 +0200 Subject: [PATCH] move stopRobot in FutureAction class --- src/strategy.cpp | 15 +++++++++++---- src/strategy.h | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/strategy.cpp b/src/strategy.cpp index b82b246..ce497b4 100644 --- a/src/strategy.cpp +++ b/src/strategy.cpp @@ -1,5 +1,7 @@ #include "strategy.h" +//////// FutureAction + FutureAction::FutureAction( Vector2 target, int celerity, @@ -10,13 +12,18 @@ FutureAction::FutureAction( _rotation(rotation), _activeKicker(activeKicker) {} -//////// +FutureAction FutureAction::stopRobot() { + return FutureAction(Vector2(0, 0), 0, 0, false); +} + +//////// Functions + +//TODO: remove parameters const int criticalWallDistance = 25; const int goalMinDistance = 90; // 85 pour SN10 et 95 pour SN9 const int myGoalMinDistance = 82; const int speedmotors = 120; const int shootSpeed = 180; -const FutureAction stopRobot = FutureAction(Vector2(0, 0), 0, 0, false); FutureAction chooseStrategy(FieldProperties fP, RobotState cS, FutureAction lA) { if (robotIsLost(fP, cS)) { @@ -24,12 +31,12 @@ FutureAction chooseStrategy(FieldProperties fP, RobotState cS, FutureAction lA) return refrainFromLeavingStrategy(fP, cS); } else if (!ballIsDetected(fP, cS)) { SerialDebug.println("stopRobotStrategy"); - return stopRobot; + return FutureAction::stopRobot(); } else if (ballIsCaught(fP, cS)) { if (!goalIsDetected(fP, cS)) { SerialDebug.println("stopRobotStrategy"); - return stopRobot; + return FutureAction::stopRobot(); } else if (targetJustInFrontOfRobot(fP, cS, cS.enemyGoalPos())) { return shootStrategy(fP, cS); } else { diff --git a/src/strategy.h b/src/strategy.h index b44f5ba..3fdde93 100644 --- a/src/strategy.h +++ b/src/strategy.h @@ -24,6 +24,8 @@ class FutureAction { inline int celerity() const { return _celerity; } inline Radians rotation() const { return _rotation; } inline bool activeKicker() const { return _activeKicker; } + + inline static FutureAction stopRobot(); }; FutureAction chooseStrategy(FieldProperties fP, RobotState cS, FutureAction lA);