dynamic_graph_manager
device.hh
Go to the documentation of this file.
1 
10 #ifndef DEVICE_HH
11 #define DEVICE_HH
12 
13 #include <yaml-cpp/yaml.h>
14 
15 #include <dynamic-graph/all-signals.h>
16 #include <dynamic-graph/entity.h>
17 #include <dynamic-graph/linear-algebra.h>
18 
21 
22 namespace dynamic_graph
23 {
24 typedef dynamicgraph::Signal<dynamicgraph::Vector, int> OutSignal;
25 typedef dynamicgraph::SignalPtr<dynamicgraph::Vector, int> InSignal;
26 typedef std::map<std::string, OutSignal*> DeviceOutSignalMap;
27 typedef std::map<std::string, InSignal*> DeviceInSignalMap;
28 
29 class Device : public dynamicgraph::Entity
30 {
31 public:
36  static const std::string CLASS_NAME;
37 
43  virtual const std::string& getClassName(void) const
44  {
45  return CLASS_NAME;
46  }
47 
53  Device(const std::string& input_name);
54 
58  virtual ~Device();
59 
65  virtual void initialize(const YAML::Node& params);
66 
73  virtual void initialize_from_file(const std::string& yaml_file);
74 
79  void initialize_maps(const YAML::Node& sensors_and_controls);
80 
86  virtual void set_sensors_from_map(const VectorDGMap& sensors);
87 
97  virtual void execute_graph();
98 
109  {
110  std::cout << "\"device.executeGraph\" python command is deprecated, "
111  << "please use \"device.execute_graph()\"" << std::endl;
112  execute_graph();
113  }
114 
120  virtual void get_controls_to_map(VectorDGMap& motor_controls);
121 
122  /****************************************************************
123  * DEVICE OUPUT SIGNALS // INPUT OF THE GRAPH <=> SENSOR VALUES *
124  ****************************************************************/
125 
130  DeviceOutSignalMap sensors_out_;
131 
137 
138  /*******************************************************
139  * DEVICE INPUT SIGNALS // OUTPUT OF THE CONTROL GRAPH *
140  *******************************************************/
141 
147  DeviceInSignalMap motor_controls_in_;
148 
154 
155 protected:
162 
169 
173  YAML::Node params_;
174 };
175 
176 } // namespace dynamic_graph
177 
178 #endif /* #ifndef DEVICE_HH */
virtual ~Device()
~Device is a default destructor that might overloaded
Definition: device.cpp:118
virtual const std::string & getClassName(void) const
getClassName is an overloaded function from the class Entity.
Definition: device.hh:43
virtual void initialize_from_file(const std::string &yaml_file)
initialize_from_file is the function that initialize the device from a YAML file. ...
Definition: device.cpp:83
virtual void initialize(const YAML::Node &params)
initialize is the function that initialize the device from the YAML paramters
Definition: device.cpp:89
Definition: periodic-call.hh:26
PeriodicCall periodic_call_after_
periodic_call_after_ handle the synchronous command call on the device between getting the sensor dat...
Definition: device.hh:168
void execute_graph_deprecated()
execute_graph is a fonction that execute the graph.
Definition: device.hh:108
Definition: device.hh:29
std::map< std::string, dynamicgraph::Vector > VectorDGMap
VectorDGMap is a shortcut for the very long type of the map.
Definition: tools.hh:22
virtual void get_controls_to_map(VectorDGMap &motor_controls)
get_controls_to_map is a parser that feed the map "controls" with the output of the DynamicGraph...
Definition: device.cpp:305
YAML::Node params_
params is a YAML node that allow the creation of a modular device
Definition: device.hh:173
this is this package namespace in order to avoid naming conflict
Definition: device.hh:22
virtual void set_sensors_from_map(const VectorDGMap &sensors)
set_sensors_from_map is a parser that feed the map "sensors" with the hardware sensor readings...
Definition: device.cpp:196
PeriodicCall periodic_call_before_
periodic_call_before_ handle the synchronous command call on the device between getting the sensor da...
Definition: device.hh:161
virtual void execute_graph()
execute_graph is a fonction that execute the graph.
Definition: device.cpp:221
static const std::string CLASS_NAME
This is the name of the classe that is used to store the object in the dynamic graph.
Definition: device.hh:36
Device(const std::string &input_name)
Device is the constructor.
Definition: device.cpp:44
DeviceInSignalMap motor_controls_in_
motor_control_in_ is the output motor control for each joint.
Definition: device.hh:147
void initialize_maps(const YAML::Node &sensors_and_controls)
parse_yaml_file fill in the internal maps for sensors and controls.
Definition: device.cpp:146
VectorDGMap sensors_map_
sensors_map_ is a map of dynamicgraph::Vector.
Definition: device.hh:136
VectorDGMap motor_controls_map_
motor_controls_map_ is a map of dynamicgraph::Vector.
Definition: device.hh:153
DeviceOutSignalMap sensors_out_
sensors_out_ is a map of device output signals.
Definition: device.hh:130