PortHandler.h
Go to the documentation of this file.
1 #ifndef __PORT_HANDLER_H__
2 #define __PORT_HANDLER_H__
3 
4 #include <rtm/idl/InterfaceDataTypes.hh>
5 #include "hrpsys/idl/HRPDataTypes.hh"
6 #include "hrpsys/idl/pointcloud.hh"
7 #include "BodyRTC.h"
8 
9 namespace hrp{
10  class ForceSensor;
11  class RateGyroSensor;
12  class AccelSensor;
13  class RangeSensor;
14  class VisionSensor;
15 };
16 
18 {
19 public:
20  virtual void update()=0;
21 };
22 
24 {
25 public:
26  virtual void update(double time)=0;
27 };
28 
29 template<class T>
30 class InPortHandler : public InPortHandlerBase
31 {
32 public:
33  InPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName) :
34  m_port(i_portName, m_data){
35  i_rtc->addInPort(i_portName, m_port);
36  }
37 protected:
38  T m_data;
39  RTC::InPort<T> m_port;
40 };
41 
42 template<class T>
44 {
45 public:
47  const char *i_portName) :
48  m_port(i_portName, m_data){
49  i_rtc->addOutPort(i_portName, m_port);
50  }
51  void write(double time){
52  m_data.tm.sec = time;
53  m_data.tm.nsec = (time - m_data.tm.sec)*1e9;
54  m_port.write();
55  }
56 protected:
57  T m_data;
58  RTC::OutPort<T> m_port;
59 };
60 
61 class JointInPortHandler : public InPortHandler<RTC::TimedDoubleSeq>
62 {
63 public:
65  const char *i_portName,
66  const std::vector<hrp::Link *> &i_joints,
67  std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo);
68 protected:
69  std::vector<hrp::Link *> m_joints;
70  std::vector<OpenHRP::RobotHardwareService::SwitchStatus> &m_servo;
71 };
72 
73 class JointOutPortHandler : public OutPortHandler<RTC::TimedDoubleSeq>
74 {
75 public:
77  const char *i_portName,
78  const std::vector<hrp::Link *> &i_joints);
79 protected:
80  std::vector<hrp::Link *> m_joints;
81 };
82 
84 {
85 public:
87  const char *i_portName,
88  const std::vector<hrp::Link *> &i_joints,
89  std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo);
90  void update();
91 };
92 
94 {
95 public:
97  const char *i_portName,
98  const std::vector<hrp::Link *> &i_joints);
99  void update(double time);
100 };
101 
103 {
104 public:
106  const char *i_portName,
107  const std::vector<hrp::Link *> &i_joints,
108  std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo);
109  void update();
110 };
111 
113 {
114 public:
116  const char *i_portName,
117  const std::vector<hrp::Link *> &i_joints);
118  void update(double time);
119 };
120 
122 {
123 public:
125  const char *i_portName,
126  const std::vector<hrp::Link *> &i_joints,
127  std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo);
128  void update();
129 };
130 
132 {
133 public:
135  const char *i_portName,
136  const std::vector<hrp::Link *> &i_joints);
137  void update(double time);
138 };
139 
141 {
142 public:
144  const char *i_portName,
145  const std::vector<hrp::Link *> &i_joints,
146  std::vector<OpenHRP::RobotHardwareService::SwitchStatus> *i_servo);
147  void update();
148 };
149 
151 {
152 public:
154  const char *i_portName,
155  const std::vector<hrp::Link *> &i_joints);
156  void update(double time);
157 private:
159 };
160 
161 class AbsTransformInPortHandler : public InPortHandler<RTC::TimedPose3D>
162 {
163 public:
165  const char *i_portName,
166  hrp::Link *i_link);
167  void update();
168 private:
169  hrp::Link *m_link;
170 };
171 
172 class AbsVelocityInPortHandler : public InPortHandler<RTC::TimedDoubleSeq>
173 {
174 public:
176  const char *i_portName,
177  hrp::Link *i_link);
178  void update();
179 private:
181 };
182 
183 class AbsAccelerationInPortHandler : public InPortHandler<RTC::TimedDoubleSeq>
184 {
185 public:
187  const char *i_portName,
188  hrp::Link *i_link);
189  void update();
190 private:
192 };
193 
194 class FrameRateInPortHandler : public InPortHandler<RTC::TimedDouble>
195 {
196 public:
198  const char *i_portName,
199  hrp::VisionSensor *i_sensor);
200  void update();
201 private:
203 };
204 
205 class LightSwitchInPortHandler : public InPortHandler<RTC::TimedBoolean>
206 {
207 public:
209  const char *i_portName,
210  hrp::Light *i_light);
211  void update();
212 private:
214 };
215 
216 class AbsTransformOutPortHandler : public OutPortHandler<RTC::TimedPose3D>
217 {
218 public:
220  const char *i_portName,
221  hrp::Link *i_link);
223  const char *i_portName,
224  hrp::Sensor *i_sensor);
225  void update(double time);
226 private:
227  hrp::Link *m_link;
228  hrp::Sensor *m_sensor;
229 };
230 
231 class AbsVelocityOutPortHandler : public OutPortHandler<RTC::TimedDoubleSeq>
232 {
233 public:
235  const char *i_portName,
236  hrp::Link *i_link);
237  void update(double time);
238 private:
240 };
241 
243  public OutPortHandler<RTC::TimedDoubleSeq>
244 {
245 public:
247  const char *i_portName,
248  hrp::Link *i_link);
249  void update(double time);
250 private:
252 };
253 
254 template<class T, class S>
256 {
257 public:
259  const char *i_portName, T *i_sensor) :
260  OutPortHandler<S>(i_rtc, i_portName),
261  m_sensor(i_sensor){
262  }
263 protected:
265 };
266 
268  public SensorPortHandler<hrp::ForceSensor, RTC::TimedDoubleSeq>
269 {
270 public:
272  const char *i_portName,
273  hrp::ForceSensor *i_sensor);
274  void update(double time);
275 };
276 
278  public SensorPortHandler<hrp::RateGyroSensor, RTC::TimedAngularVelocity3D>
279 {
280 public:
282  const char *i_portName,
283  hrp::RateGyroSensor *i_sensor);
284  void update(double time);
285 private:
286 };
287 
289  public SensorPortHandler<hrp::AccelSensor, RTC::TimedAcceleration3D>
290 {
291 public:
293  const char *i_portName,
294  hrp::AccelSensor *i_sensor);
295  void update(double time);
296 private:
297 };
298 
300  public SensorPortHandler<hrp::RangeSensor, RTC::RangeData>
301 {
302 public:
304  const char *i_portName,
305  hrp::RangeSensor *i_sensor);
306  void update(double time);
307 private:
308 };
309 
311  public SensorPortHandler<hrp::VisionSensor, Img::TimedCameraImage>
312 {
313 public:
315  const char *i_portName,
316  hrp::VisionSensor *i_sensor);
317  void update(double time);
318 private:
319 };
320 
322  public SensorPortHandler<hrp::VisionSensor, PointCloudTypes::PointCloud>
323 {
324 public:
326  const char *i_portName,
327  hrp::VisionSensor *i_sensor);
328  void update(double time);
329 private:
330  std::string m_pcFormat;
331 };
332 
333 class EmergencySignalPortHandler : public OutPortHandler<RTC::TimedLong>
334 {
335 public:
337  const char *i_portName,
338  BodyRTC *i_body);
339  void update(double time);
340 protected:
342 };
343 
344 class ServoStatePortHandler : public OutPortHandler<OpenHRP::TimedLongSeqSeq>
345 {
346 public:
348  const char *i_portName,
349  BodyRTC *i_body);
350  void update(double time);
351 protected:
353  OpenHRP::RobotHardwareService::RobotState* rs;
354 };
355 
356 #endif
bool addOutPort(const char *name, OutPortBase &outport)
SensorPortHandler(RTC::DataFlowComponentBase *i_rtc, const char *i_portName, T *i_sensor)
Definition: PortHandler.h:258
std::vector< OpenHRP::RobotHardwareService::SwitchStatus > & m_servo
Definition: PortHandler.h:70
OpenHRP::RobotHardwareService::RobotState * rs
Definition: PortHandler.h:353
std::vector< hrp::Link * > m_joints
Definition: PortHandler.h:80
hrp::VisionSensor * m_sensor
Definition: PortHandler.h:202
std::string m_pcFormat
Definition: PortHandler.h:330
bool addInPort(const char *name, InPortBase &inport)
std::vector< hrp::Link * > m_joints
Definition: PortHandler.h:69


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50