Skip to content

Commit

Permalink
move stopRobot in FutureAction class
Browse files Browse the repository at this point in the history
  • Loading branch information
DArtagnant committed Jun 8, 2024
1 parent 3ec2c1e commit 7179412
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/strategy.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "strategy.h"

//////// FutureAction

FutureAction::FutureAction(
Vector2 target,
int celerity,
Expand All @@ -10,26 +12,31 @@ 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)) {
if (leavingField(fP, cS)) {
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 {
Expand Down
2 changes: 2 additions & 0 deletions src/strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7179412

Please sign in to comment.