Thunderbots Project
Loading...
Searching...
No Matches
kick_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 KickFSM
7{
8 public:
9 class KickState;
10
12 {
13 // The location where the kick will be taken from
14 Point kick_origin;
15 // The direction the Robot will kick in
16 Angle kick_direction;
17 // How fast the Robot will kick the ball in meters per second
18 double kick_speed_meters_per_second;
19 };
20
21 DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS
22
28 void updateKick(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
59 auto operator()()
60 {
61 using namespace boost::sml;
62
63 DEFINE_SML_STATE(GetBehindBallFSM)
64 DEFINE_SML_STATE(KickState)
65 DEFINE_SML_EVENT(Update)
66
67 DEFINE_SML_GUARD(ballChicked)
68 DEFINE_SML_GUARD(shouldRealignWithBall)
69 DEFINE_SML_ACTION(updateKick)
70 DEFINE_SML_SUB_FSM_UPDATE_ACTION(updateGetBehindBall, GetBehindBallFSM)
71
72 return make_transition_table(
73 // src_state + event [guard] / action = dest_state
74 *GetBehindBallFSM_S + Update_E / updateGetBehindBall_A,
75 GetBehindBallFSM_S = KickState_S,
76
77 KickState_S + Update_E[shouldRealignWithBall_G] / updateGetBehindBall_A =
78 GetBehindBallFSM_S,
79 KickState_S + Update_E[!ballChicked_G] / updateKick_A = KickState_S,
80 KickState_S + Update_E[ballChicked_G] / SET_STOP_PRIMITIVE_ACTION = X,
81 X + Update_E / SET_STOP_PRIMITIVE_ACTION = X);
82 }
83};
Definition angle.h:15
Definition point.h:14
Definition get_behind_ball_fsm.h:8
Definition kick_fsm.h:12
Definition kick_fsm.h:7
void updateGetBehindBall(const Update &event, boost::sml::back::process< GetBehindBallFSM::Update > processEvent)
Definition kick_fsm.cpp:21
bool shouldRealignWithBall(const Update &event)
Definition kick_fsm.cpp:38
DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS void updateKick(const Update &event)
Definition kick_fsm.cpp:5
bool ballChicked(const Update &event)
Definition kick_fsm.cpp:32