mars
Task.hpp
Go to the documentation of this file.
1 #ifndef SIMULATION_MARS_TASK_HPP
2 #define SIMULATION_MARS_TASK_HPP
3 
4 #include "mars/TaskBase.hpp"
5 #include <vector>
6 #include <mars/data_broker/ReceiverInterface.h>
7 #include "Plugin.hpp"
8 #include <boost/thread/mutex.hpp>
9 
10 class QApplication;
11 
13 //
14 namespace lib_manager{
15  class LibManager;
16 };
17 
18 namespace mars{
19  namespace interfaces{
20  class SimulatorInterface;
21  class PluginInterface;
22  class GraphicsManagerInterface;
23  };
24  namespace app{
25  class GraphicsTimer;
26  };
27 };
28 
29 
30 namespace mars {
31 
32  class Task;
33 
34  // Argument to pass to startTaskFunc
36  {
38  bool enable_gui;
40  std::vector<SimulationProperty> mars_property_list;
41  std::vector<std::string> mars_plugins;
42  std::string config_dir;
44  bool add_floor;
47  // Raw command line option can be passed to mars
48  // using this option vector
49  std::vector<Option> raw_options;
50  };
51 
52 
65  class Task : public TaskBase, public mars::data_broker::ReceiverInterface
66 
67  {
68  friend class TaskBase;
69  protected:
70  QApplication* app;
71  static mars::app::GraphicsTimer *graphicsTimer;
72  static mars::interfaces::SimulatorInterface* simulatorInterface;
74  static void* startTaskFunc(void *);
75  static std::string configDir;
76  static bool marsRunning;
77 
78  pthread_t thread_info;
79  static lib_manager::LibManager* libManager;
80 
81  mars::interfaces::PluginInterface* multisimPlugin;
82 
83  int getOptionCount(const std::vector<Option>& options);
84 
85  /* This operation moves a node to a specific position, simpliar to the positions property but can be used during runtime
86  */
87  virtual void move_node(::mars::Positions const & arg);
88 
89  char** setOptions(const std::vector<Option>& options);
90 
91  /* Handler for the loadScene operation
92  */
93  virtual void loadScene(::std::string const & path);
94 
95  std::vector<Plugin*> plugins;
96 
97  /* Dynamic Property setter of show_coordinate_system
98  */
99  virtual bool setShow_coordinate_system(bool value);
100 
101  /* Dynamic Property setter of reaction_to_physics_error
102  */
103  virtual bool setReaction_to_physics_error(::std::string const & value);
104 
105 
106 
107  // GraphicsTimer will be later called with the marsGraphics reference
108  // which can be also NULL for a disabled gui
109  mars::interfaces::GraphicsManagerInterface* marsGraphics;
110 
111  virtual bool setSim_step_size(double value);
112  virtual bool setGravity(::base::Vector3d const & value);
113  virtual bool setGravity_internal(::base::Vector3d const & value);
114  virtual void setPosition(::mars::Positions const & positions);
115 
116  public:
119  static mars::interfaces::SimulatorInterface* getSimulatorInterface();
120  static mars::Task* getTaskInterface();
121 
122  Task(std::string const& name = "mars::Task");
123  Task(std::string const& name, RTT::ExecutionEngine* engine);
124 
125  ~Task();
126 
127  void registerPlugin(Plugin* plugin);
128  void unregisterPlugin(Plugin* plugin);
129 
143  bool configureHook();
144 
150  bool startHook();
151 
168  void updateHook();
169 
170 
177  void errorHook();
178 
182  void stopHook();
183 
188  void cleanupHook();
189 
190  void receiveData(const mars::data_broker::DataInfo& info,const mars::data_broker::DataPackage& package,int id);
191 
192  };
193 }
194 
195 #endif
196 
Definition: Task.hpp:65
std::vector< SimulationProperty > mars_property_list
Definition: Task.hpp:40
mars::interfaces::GraphicsManagerInterface * marsGraphics
Definition: Task.hpp:109
Definition: Task.hpp:35
bool enable_gui
Definition: Task.hpp:38
static mars::interfaces::SimulatorInterface * simulatorInterface
Definition: Task.hpp:72
bool initialized
Definition: Task.hpp:43
Definition: Task.hpp:14
std::vector< Plugin * > plugins
Definition: Task.hpp:95
int controller_port
Definition: Task.hpp:39
static lib_manager::LibManager * libManager
Definition: Task.hpp:79
std::vector< Option > raw_options
Definition: Task.hpp:49
pthread_t thread_info
Definition: Task.hpp:78
QApplication * app
Definition: Task.hpp:70
mars::interfaces::PluginInterface * multisimPlugin
Definition: Task.hpp:81
bool add_floor
Definition: Task.hpp:44
static mars::app::GraphicsTimer * graphicsTimer
Definition: Task.hpp:71
std::vector< std::string > mars_plugins
Definition: Task.hpp:41
Definition: jointTypes.hpp:9
static bool marsRunning
Definition: Task.hpp:76
std::string config_dir
Definition: Task.hpp:42
Task * mars
Definition: Task.hpp:37
static mars::Task * taskInterface
Definition: Task.hpp:73
The task context provides and requires services. It uses an ExecutionEngine to perform its functions...
Definition: Plugin.hpp:27
Definition: MarsControl.hpp:27
bool failed_to_init
Definition: Task.hpp:45
static std::string configDir
Definition: Task.hpp:75
bool realtime_calc
Definition: Task.hpp:46