Thunderbots Project
Loading...
Searching...
No Matches
move_fsm.h
1#pragma once
2
3#include "software/ai/hl/stp/tactic/tactic.h"
4
5struct MoveFSM
6{
7 public:
8 // these classes define the states used in the transition table
9 // they are exposed so that tests can check if the FSM is in a particular state
10 class MoveState;
11
12 // this struct defines the unique control parameters that the MoveFSM requires in its
13 // update
15 {
16 // The point the robot is trying to move to
17 Point destination;
18 // The orientation the robot should have when it arrives at its destination
19 Angle final_orientation;
20 // How to run the dribbler
21 TbotsProto::DribblerMode dribbler_mode;
22 // How to navigate around the ball
23 TbotsProto::BallCollisionType ball_collision_type;
24 // The command to autochip or autokick
25 AutoChipOrKick auto_chip_or_kick;
26 // The maximum allowed speed mode
27 TbotsProto::MaxAllowedSpeedMode max_allowed_speed_mode;
28 // The obstacle avoidance mode
29 TbotsProto::ObstacleAvoidanceMode obstacle_avoidance_mode;
30 };
31
32 // this struct defines the only event that the MoveFSM responds to
33 DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS
34
41 void updateMove(const Update &event);
42
50 bool moveDone(const Update &event);
51
52 auto operator()()
53 {
54 using namespace boost::sml;
55
56 // MoveState_S is the _state_ used in the transition table
57 DEFINE_SML_STATE(MoveState)
58 // Update_E is the _event_ that the MoveFSM responds to
59 DEFINE_SML_EVENT(Update)
60
61 DEFINE_SML_GUARD(moveDone)
62 DEFINE_SML_ACTION(updateMove)
63
64 return make_transition_table(
65 // src_state + event [guard] / action = dest_state
66 *MoveState_S + Update_E[!moveDone_G] / updateMove_A = MoveState_S,
67 MoveState_S + Update_E[moveDone_G] / updateMove_A = X,
68 X + Update_E[!moveDone_G] / updateMove_A = MoveState_S,
69 X + Update_E / updateMove_A = X);
70 }
71};
Definition angle.h:15
Definition point.h:14
Definition primitive_types.h:9
Definition move_fsm.h:15
Definition move_fsm.h:6
DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS void updateMove(const Update &event)
Definition move_fsm.cpp:5
bool moveDone(const Update &event)
Definition move_fsm.cpp:16