Alex exoskeleton
ALEX SoftwareDocumentation
ExoTestMachine.cpp
Go to the documentation of this file.
1 
2 #include "ExoTestMachine.h"
3 
4 #define OWNER ((ExoTestMachine *)owner)
5 
6 ExoTestMachine::ExoTestMachine() {
7  trajectoryGenerator = new DummyTrajectoryGenerator(6); /*<! \todo Pilot Parameters would be set in constructor here*/
8  robot = new ExoRobot(trajectoryGenerator);
9 
10  // Create PRE-DESIGNED State Machine events and state objects.
11  isAPressed = new IsAPressed(this);
12  endTraj = new EndTraj(this);
13  startButtonsPressed = new StartButtonsPressed(this);
14  startExo = new StartExo(this);
15  startSit = new StartSit(this);
16  startStand = new StartStand(this);
17  initState = new InitState(this, robot, trajectoryGenerator);
18  standing = new Standing(this, robot, trajectoryGenerator);
19  sitting = new Sitting(this, robot, trajectoryGenerator);
20  standingUp = new StandingUp(this, robot, trajectoryGenerator);
21  sittingDwn = new SittingDwn(this, robot, trajectoryGenerator);
22 
29  NewTransition(initState, startExo, sitting);
30  NewTransition(sitting, startStand, standingUp);
31  NewTransition(standingUp, endTraj, standing);
32  NewTransition(standing, startSit, sittingDwn);
33  NewTransition(sittingDwn, endTraj, sitting);
34  //Initialize the state machine with first state of the designed state machine, using baseclass function.
35  StateMachine::initialize(initState);
36 }
42 void ExoTestMachine::init() {
43  DEBUG_OUT("ExoTestMachine::init()")
44  robot->initialise();
45  running = true;
46 }
47 
49 // Events ------------------------------------------------------------
51 
55 bool ExoTestMachine::EndTraj::check() {
56  return OWNER->trajectoryGenerator->isTrajectoryFinished();
57 }
58 bool ExoTestMachine::IsAPressed::check(void) {
59  if (OWNER->robot->keyboard.getA() == true) {
60  return true;
61  }
62  return false;
63 }
64 bool ExoTestMachine::StartButtonsPressed::check(void) {
65  if (OWNER->robot->keyboard.getW() == true) {
66  return true;
67  }
68  return false;
69 }
70 bool ExoTestMachine::StartExo::check(void) {
71  if (OWNER->robot->keyboard.getS() == true) {
72  std::cout << "LEAVING INIT and entering Sitting" << endl;
73  return true;
74  }
75  return false;
76 }
77 bool ExoTestMachine::StartStand::check(void) {
78  if (OWNER->robot->keyboard.getW() == true) {
79  return true;
80  }
81  return false;
82 }
83 
84 bool ExoTestMachine::StartSit::check(void) {
85  if (OWNER->robot->keyboard.getW()) {
86  return true;
87  }
88  return false;
89 }
95 void ExoTestMachine::hwStateUpdate(void) {
96  robot->updateRobot();
97 }
Example implementation of the Robot class, representing an X2 Exoskeleton, using DummyActuatedJoint a...
Definition: ExoRobot.h:27
State for the ExoTestMachine (implementing ExoTestState) - representing when the exo is standing up (...
Definition: StandingUp.h:11
Example Implementation of TrajectoryGenerator. Includes only two trajectories (Sit-to-Stand and Stand...
State for the ExoTestMachine (implementing ExoTestState) - representing when the exoskeleton is sitti...
Definition: Sitting.h:14
Initialisation State for the ExoTestMachine (implementing ExoTestState)
Definition: InitState.h:13
#define OWNER
double sitting[6]
#define DEBUG_OUT(x)
Definition: DebugMacro.h:11
State for the ExoTestMachine (implementing ExoTestState) - representing when the exoskeleton is stand...
Definition: Standing.h:11
#define NewTransition(_from_, _event_, _to_)
Macro to create statemachine transitions. Add a tranition object to the from states arch list to a sp...
Definition: StateMachine.h:90
double standing[6]
void initialize(State *i)
Sets the current state. Note: No check made.