EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
Executor.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_CORE_EXECUTOR_HPP_
2 #define ORG_EEROS_CORE_EXECUTOR_HPP_
3 
4 #include <vector>
5 #include <condition_variable>
6 
10 #include <eeros/logger/Logger.hpp>
11 
12 #ifdef USE_ETHERCAT
13 #include <EtherCATMain.hpp>
14 #endif
15 
16 #ifdef USE_ROS
17 #include <ros/ros.h>
18 #endif
19 
20 
21 namespace eeros {
22 
23  namespace control {
24  class TimeDomain;
25  }
26 
27  namespace safety {
28  class SafetySystem;
29  };
30 
31  class Executor : public Runnable {
32  Executor();
33  public:
34  static constexpr int basePriority = 49;
35 
36  virtual ~Executor();
37  static Executor& instance();
38 #ifdef USE_ETHERCAT
39  void syncWithEtherCATSTack(ethercat::EtherCATMain* etherCATStack);
40 #endif
41  void setMainTask(task::Periodic &mainTask);
42  void setMainTask(safety::SafetySystem &mainTask);
43  task::Periodic* getMainTask();
44  void add(task::Periodic &task);
45  void add(control::TimeDomain &timedomain);
46  virtual void run();
47 
48  static void prefault_stack();
49  static bool lock_memory();
50  static bool set_priority(int nice);
51  static void stop();
52 
53 
55 
56 
57 #ifdef USE_ROS
58  void syncWithRosTime();
59  void syncWithRosTopic(ros::CallbackQueue* syncRosCallbackQueue);
60  ros::CallbackQueue* syncRosCallbackQueue;
61 #endif
62 
63 
64  private:
65  void assignPriorities();
66 ;
67 #ifdef USE_ETHERCAT
68  ethercat::EtherCATMain* etherCATStack;
69  std::mutex* m;
70  std::condition_variable* cv;
71 #endif
72  bool syncWithEtherCatStackIsSet;
73  bool syncWithRosTimeIsSet;
74  bool syncWithRosTopicIsSet;
75  logger::Logger log;
76  double period;
77  task::Periodic* mainTask;
78  std::vector<task::Periodic> tasks;
79  };
80 
81 }
82 
83 #endif // ORG_EEROS_CORE_EXECUTOR_HPP_
Safety system.
Definition: SafetySystem.hpp:19
Definition: Logger.hpp:15
Definition: PeriodicCounter.hpp:14
Definition: Executor.hpp:31
Definition: Config.hpp:14
Definition: Runnable.hpp:6
PeriodicCounter counter
Definition: Executor.hpp:54
Definition: Periodic.hpp:13
Definition: TimeDomain.hpp:17