Thunderbots Project
Loading...
Searching...
No Matches
chip_fsm.h
1#pragma once
2
3#include "software/ai/hl/stp/tactic/get_behind_ball/get_behind_ball_fsm.h"
4#include "software/ai/hl/stp/tactic/tactic.h"
5
6struct ChipFSM
7{
8 public:
9 class ChipState;
10
12 {
13 // The location where the chip will be taken from
14 Point chip_origin;
15 // The direction the Robot will chip in
16 Angle chip_direction;
17 // The distance the robot will chip to
18 double chip_distance_meters;
19 };
20
21 DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS
22
28 void updateChip(const Update &event);
29
37 const Update &event,
38 boost::sml::back::process<GetBehindBallFSM::Update> processEvent);
39
47 bool ballChicked(const Update &event);
48
56 bool shouldRealignWithBall(const Update &event);
57
58 auto operator()()
59 {
60 using namespace boost::sml;
61
62 DEFINE_SML_STATE(GetBehindBallFSM)
63 DEFINE_SML_STATE(ChipState)
64 DEFINE_SML_EVENT(Update)
65
66 DEFINE_SML_GUARD(ballChicked)
67 DEFINE_SML_GUARD(shouldRealignWithBall)
68 DEFINE_SML_ACTION(updateChip)
69 DEFINE_SML_SUB_FSM_UPDATE_ACTION(updateGetBehindBall, GetBehindBallFSM)
70
71 return make_transition_table(
72 // src_state + event [guard] / action = dest_state
73 *GetBehindBallFSM_S + Update_E / updateGetBehindBall_A,
74 GetBehindBallFSM_S = ChipState_S,
75
76 ChipState_S + Update_E[shouldRealignWithBall_G] / updateGetBehindBall_A =
77 GetBehindBallFSM_S,
78 ChipState_S + Update_E[!ballChicked_G] / updateChip_A = ChipState_S,
79 ChipState_S + Update_E[ballChicked_G] / SET_STOP_PRIMITIVE_ACTION = X,
80 X + Update_E / SET_STOP_PRIMITIVE_ACTION = X);
81 }
82};
Definition angle.h:15
Definition point.h:14
Definition chip_fsm.h:12
Definition chip_fsm.h:7
void updateGetBehindBall(const Update &event, boost::sml::back::process< GetBehindBallFSM::Update > processEvent)
Definition chip_fsm.cpp:5
bool shouldRealignWithBall(const Update &event)
Definition chip_fsm.cpp:38
bool ballChicked(const Update &event)
Definition chip_fsm.cpp:32
DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS void updateChip(const Update &event)
Definition chip_fsm.cpp:16
Definition get_behind_ball_fsm.h:8