5 #ifndef SITTING_DEMO_FSM_H
6 #define SITTING_DEMO_FSM_H
10 #include <limb_control/PlayCommandsSrv.h>
14 namespace sitting_demo
17 using namespace statecontroller;
27 class WaitForSittingState;
28 class WaitForTimeState;
29 class WaitForMotionPlayerState;
30 class PlanDemoActionState;
38 WAIT_FOR_MOTION_PLAYER,
39 WAIT_FOR_LIMB_CONTROL,
42 START_MOTION_PLAYBACK,
55 SittingDemoSC(SittingDemo* SD);
58 SittingDemo*
const m_SD;
61 virtual bool preStepCallback();
62 virtual void preActivateCallback(
bool willCallActivate);
63 virtual void preExecuteCallback();
66 inline const ros::Time& now()
const {
return m_curStepTime; }
70 void enableLegDangle();
71 void disableLegDangle();
72 void enableHeadIdle();
73 void disableHeadIdle();
76 void handleLegDangle();
77 void handleHeadIdle();
80 bool m_legDangleEnabled;
83 bool m_headIdleEnabled;
86 ros::Time m_curStepTime;
90 class InitDemoState :
public GenState<SittingDemoSC>
94 InitDemoState(SittingDemoSC *sc) :
GenState(sc, INIT_DEMO,
"INIT_DEMO") {}
102 class WaitForSittingState :
public GenState<SittingDemoSC>
106 WaitForSittingState(SittingDemoSC *sc) :
GenState(sc, WAIT_FOR_SITTING,
"WAIT_FOR_SITTING") {}
114 class WaitForTimeState :
public GenState<SittingDemoSC>
118 static const ros::Time NullROSTime;
121 WaitForTimeState(SittingDemoSC* sc,
double waitTime, ros::Time endTime = NullROSTime) :
GenState(sc, WAIT_FOR_TIME,
"WAIT_FOR_TIME"), m_waitTime(waitTime), m_endTime(endTime) {}
125 virtual void activate(
cycle_t cyc);
134 class WaitForMotionPlayerState :
public GenState<SittingDemoSC>
138 WaitForMotionPlayerState(SittingDemoSC *sc) :
GenState(sc, WAIT_FOR_MOTION_PLAYER,
"WAIT_FOR_MOTION_PLAYER") {}
146 class WaitForLimbControlState :
public GenState<SittingDemoSC>
150 WaitForLimbControlState(SittingDemoSC *sc) :
GenState(sc, WAIT_FOR_LIMB_CONTROL,
"WAIT_FOR_LIMB_CONTROL") {}
157 const limb_control::PlayCommandsRequest PCmdReqNull;
161 class PlanDemoActionState :
public GenState<SittingDemoSC>
165 PlanDemoActionState(SittingDemoSC* sc) :
GenState(sc, PLAN_DEMO_ACTION,
"PLAN_DEMO_ACTION") {}
173 class ReturnToSittingState :
public GenState<SittingDemoSC>
177 ReturnToSittingState(SittingDemoSC* sc) :
GenState(sc, RETURN_TO_SITTING,
"RETURN_TO_SITTING") {}
181 virtual void activate(
cycle_t cyc);
185 limb_control::PlayCommandsRequest PCmdReq;
189 class StartMotionPlaybackState :
public GenState<SittingDemoSC>
193 StartMotionPlaybackState(SittingDemoSC *sc,
int motion) :
GenState(sc, START_MOTION_PLAYBACK,
"START_MOTION_PLAYBACK"), m_motion(motion) {}
197 virtual void activate(
cycle_t cyc);
205 class StopMotionPlaybackState :
public GenState<SittingDemoSC>
209 StopMotionPlaybackState(SittingDemoSC *sc) :
GenState(sc, STOP_MOTION_PLAYBACK,
"STOP_MOTION_PLAYBACK") {}
217 class StartLegDanglingState :
public GenState<SittingDemoSC>
221 StartLegDanglingState(SittingDemoSC *sc) :
GenState(sc, START_LEG_DANGLING,
"START_LEG_DANGLING") {}
225 virtual void activate(
cycle_t cyc);
230 class StopLegDanglingState :
public GenState<SittingDemoSC>
234 StopLegDanglingState(SittingDemoSC *sc) :
GenState(sc, STOP_LEG_DANGLING,
"STOP_LEG_DANGLING") {}
238 virtual void activate(
cycle_t cyc);
243 class StartHeadIdlingState :
public GenState<SittingDemoSC>
247 StartHeadIdlingState(SittingDemoSC *sc) :
GenState(sc, START_HEAD_IDLING,
"START_HEAD_IDLING") {}
251 virtual void activate(
cycle_t cyc);
256 class StopHeadIdlingState :
public GenState<SittingDemoSC>
260 StopHeadIdlingState(SittingDemoSC *sc) :
GenState(sc, STOP_HEAD_IDLING,
"STOP_HEAD_IDLING") {}
264 virtual void activate(
cycle_t cyc);
Implements the State Controller Library.
Base class for all state controllers.
Definition: state_controller.h:593
unsigned int cycle_t
Used to count the number of executed state controller cycles.
Definition: state_controller.h:415
bool action_t
Used to represent the state transition actions (HOLD_THIS_STATE and PROCEED_NEXT_STATE) ...
Definition: state_controller.h:416
Specialises the State class using templates to take care of the most common overloads.
Definition: state_controller.h:397