Robot Devastation
State.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_STATE_HPP__
6 #define __RD_STATE_HPP__
7 
8 #include <string>
9 
10 namespace rd{
11 
18 class State
19 {
20  public:
21  State();
22  virtual ~State();
23 
28  virtual bool setup() = 0;
29 
34  virtual bool loop() = 0;
35 
40  virtual bool cleanup() = 0;
41 
49  virtual int evaluateConditions() = 0;
50 
51 
53  const std::string & getStateId() const;
54 
55  static State *getEndState();
56 
57  protected:
59  std::string state_id;
60 
61 };
62 
63 }
64 
65 #endif //-- __RD_STATE_HPP__
rd::State::cleanup
virtual bool cleanup()=0
Function excuted when this state is going to be stopped (due to an error or a transition)
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::State::state_id
std::string state_id
Name of the current state.
Definition: State.hpp:59
rd::State::loop
virtual bool loop()=0
Function executed periodically when the state is active.
rd::State::getStateId
const std::string & getStateId() const
Returns the string that identifies the state.
Definition: State.cpp:17
rd::State
Base class for each of the states of a FiniteStateMachine.
Definition: State.hpp:18
rd::State::setup
virtual bool setup()=0
Function executed just before the loop function, when the state is enabled.
rd::State::evaluateConditions
virtual int evaluateConditions()=0
This function is called after each call to loop() in order to know the transition to make.