EEROS  0.4.1.0
API for the EEROS Real-Time Robotics Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Step.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_CONTROL_STEP_HPP_
2 #define ORG_EEROS_CONTROL_STEP_HPP_
3 
5 #include <eeros/core/System.hpp>
6 
7 namespace eeros {
8  namespace control {
9 
10  template < typename T = double >
11  class Step : public Block1o<T> {
12 
13  public:
14  Step(T initValue = 0, T stepHeight = 1, double delayTime = 1) {
15 
16  }
17 
18 
19  virtual void run() {
20  if(first) {
22  this->out.getSignal().setValue(initValue);
23  first = false;
24  }
25  else if(!stepDone && System::getTime() >= stepTime) {
26  this->out.getSignal().setValue(initValue + stepHeight);
27  stepDone = true;
28  }
29  this->out.getSignal().setTimestamp(System::getTimeNs());
30  }
31 
32  virtual void reset() {
33  stepDone = false;
34  first = true;
35  }
36 
37  virtual void setInitValue(T initValue) {
38  this->initValue = initValue;
39  }
40 
41  virtual void setStepHeight(T stepHeight) {
42  this->stepHeight = stepHeight;
43  }
44 
45  virtual void setDelayTime(double delayTime) {
46  this->stepTime = delayTime;
47  }
48 
49  protected:
52  double stepTime;
53  bool stepDone;
54  bool first;
55  };
56 
57  };
58 };
59 
60 #endif /* ORG_EEROS_CONTROL_STEP_HPP_ */
Definition: Step.hpp:11
bool stepDone
Definition: Step.hpp:53
static double getTime()
Definition: System_POSIX.cpp:26
T stepHeight
Definition: Step.hpp:51
virtual void setStepHeight(T stepHeight)
Definition: Step.hpp:41
bool first
Definition: Step.hpp:54
Definition: Block1o.hpp:12
static uint64_t getTimeNs()
Definition: System_POSIX.cpp:30
virtual void reset()
Definition: Step.hpp:32
Output< T > out
Definition: Block1o.hpp:21
virtual void setInitValue(T initValue)
Definition: Step.hpp:37
virtual void setDelayTime(double delayTime)
Definition: Step.hpp:45
T initValue
Definition: Step.hpp:50
virtual void run()
Definition: Step.hpp:19
double stepTime
Definition: Step.hpp:52
Step(T initValue=0, T stepHeight=1, double delayTime=1)
Definition: Step.hpp:14