Fawkes API  Fawkes Development Version
HumanoidMotionInterface.h
1 
2 /***************************************************************************
3  * HumanoidMotionInterface.h - Fawkes BlackBoard Interface - HumanoidMotionInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2008 Tim Niemueller
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __INTERFACES_HUMANOIDMOTIONINTERFACE_H_
25 #define __INTERFACES_HUMANOIDMOTIONINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(HumanoidMotionInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  /** Type to determinate leg side. */
42  typedef enum {
43  LEG_LEFT /**< Left leg. */,
44  LEG_RIGHT /**< Right leg. */
45  } LegEnum;
46  const char * tostring_LegEnum(LegEnum value) const;
47 
48  /** From which position to standup. */
49  typedef enum {
50  STANDUP_DETECT /**< Detect via accelerometer. */,
51  STANDUP_BACK /**< Standup from lying on the back. */,
52  STANDUP_FRONT /**< Standup from lying on the tummy. */
53  } StandupEnum;
54  const char * tostring_StandupEnum(StandupEnum value) const;
55 
56  private:
57 #pragma pack(push,4)
58  /** Internal data storage, do NOT modify! */
59  typedef struct {
60  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
61  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
62  bool moving; /**< True if the robot is moving. */
63  bool arms_enabled; /**<
64  If true the arms are controlled during walking for balancing.
65  */
66  uint32_t msgid; /**<
67  The ID of the message that is currently being
68  processed, or 0 if no message is being processed.
69  */
70  } HumanoidMotionInterface_data_t;
71 #pragma pack(pop)
72 
73  HumanoidMotionInterface_data_t *data;
74 
75  public:
76  /* messages */
77  class StopMessage : public Message
78  {
79  private:
80 #pragma pack(push,4)
81  /** Internal data storage, do NOT modify! */
82  typedef struct {
83  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
84  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
85  } StopMessage_data_t;
86 #pragma pack(pop)
87 
88  StopMessage_data_t *data;
89 
90  public:
91  StopMessage();
92  ~StopMessage();
93 
94  StopMessage(const StopMessage *m);
95  /* Methods */
96  virtual Message * clone() const;
97  };
98 
100  {
101  private:
102 #pragma pack(push,4)
103  /** Internal data storage, do NOT modify! */
104  typedef struct {
105  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
106  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
107  float distance; /**< Distance in m to walk. */
108  } WalkStraightMessage_data_t;
109 #pragma pack(pop)
110 
111  WalkStraightMessage_data_t *data;
112 
113  public:
114  WalkStraightMessage(const float ini_distance);
117 
119  /* Methods */
120  float distance() const;
121  void set_distance(const float new_distance);
122  size_t maxlenof_distance() const;
123  virtual Message * clone() const;
124  };
125 
127  {
128  private:
129 #pragma pack(push,4)
130  /** Internal data storage, do NOT modify! */
131  typedef struct {
132  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
133  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
134  float distance; /**< Distance in m to walk. */
135  } WalkSidewaysMessage_data_t;
136 #pragma pack(pop)
137 
138  WalkSidewaysMessage_data_t *data;
139 
140  public:
141  WalkSidewaysMessage(const float ini_distance);
144 
146  /* Methods */
147  float distance() const;
148  void set_distance(const float new_distance);
149  size_t maxlenof_distance() const;
150  virtual Message * clone() const;
151  };
152 
153  class WalkArcMessage : public Message
154  {
155  private:
156 #pragma pack(push,4)
157  /** Internal data storage, do NOT modify! */
158  typedef struct {
159  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
160  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
161  float angle; /**< Angle in radians to turn over the way. */
162  float radius; /**< Radius in m of the circle in m. */
163  } WalkArcMessage_data_t;
164 #pragma pack(pop)
165 
166  WalkArcMessage_data_t *data;
167 
168  public:
169  WalkArcMessage(const float ini_angle, const float ini_radius);
170  WalkArcMessage();
171  ~WalkArcMessage();
172 
173  WalkArcMessage(const WalkArcMessage *m);
174  /* Methods */
175  float angle() const;
176  void set_angle(const float new_angle);
177  size_t maxlenof_angle() const;
178  float radius() const;
179  void set_radius(const float new_radius);
180  size_t maxlenof_radius() const;
181  virtual Message * clone() const;
182  };
183 
185  {
186  private:
187 #pragma pack(push,4)
188  /** Internal data storage, do NOT modify! */
189  typedef struct {
190  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
191  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
192  float x; /**<
193  Fraction of MaxStepX. Use negative for backwards. [-1.0 to 1.0].
194  */
195  float y; /**<
196  Fraction of MaxStepY. Use negative for right. [-1.0 to 1.0].
197  */
198  float theta; /**<
199  Fraction of MaxStepTheta. Use negative for clockwise [-1.0 to 1.0].
200  */
201  float speed; /**<
202  Fraction of MaxStepFrequency [0.0 to 1.0].
203  */
204  } WalkVelocityMessage_data_t;
205 #pragma pack(pop)
206 
207  WalkVelocityMessage_data_t *data;
208 
209  public:
210  WalkVelocityMessage(const float ini_x, const float ini_y, const float ini_theta, const float ini_speed);
213 
215  /* Methods */
216  float x() const;
217  void set_x(const float new_x);
218  size_t maxlenof_x() const;
219  float y() const;
220  void set_y(const float new_y);
221  size_t maxlenof_y() const;
222  float theta() const;
223  void set_theta(const float new_theta);
224  size_t maxlenof_theta() const;
225  float speed() const;
226  void set_speed(const float new_speed);
227  size_t maxlenof_speed() const;
228  virtual Message * clone() const;
229  };
230 
231  class TurnMessage : public Message
232  {
233  private:
234 #pragma pack(push,4)
235  /** Internal data storage, do NOT modify! */
236  typedef struct {
237  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
238  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
239  float angle; /**< Angle in radians to turn. */
240  } TurnMessage_data_t;
241 #pragma pack(pop)
242 
243  TurnMessage_data_t *data;
244 
245  public:
246  TurnMessage(const float ini_angle);
247  TurnMessage();
248  ~TurnMessage();
249 
250  TurnMessage(const TurnMessage *m);
251  /* Methods */
252  float angle() const;
253  void set_angle(const float new_angle);
254  size_t maxlenof_angle() const;
255  virtual Message * clone() const;
256  };
257 
258  class KickMessage : public Message
259  {
260  private:
261 #pragma pack(push,4)
262  /** Internal data storage, do NOT modify! */
263  typedef struct {
264  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
265  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
266  int32_t leg; /**< Leg to kick with */
267  float strength; /**< Kick strength */
268  } KickMessage_data_t;
269 #pragma pack(pop)
270 
271  KickMessage_data_t *data;
272 
273  public:
274  KickMessage(const LegEnum ini_leg, const float ini_strength);
275  KickMessage();
276  ~KickMessage();
277 
278  KickMessage(const KickMessage *m);
279  /* Methods */
280  LegEnum leg() const;
281  void set_leg(const LegEnum new_leg);
282  size_t maxlenof_leg() const;
283  float strength() const;
284  void set_strength(const float new_strength);
285  size_t maxlenof_strength() const;
286  virtual Message * clone() const;
287  };
288 
289  class ParkMessage : public Message
290  {
291  private:
292 #pragma pack(push,4)
293  /** Internal data storage, do NOT modify! */
294  typedef struct {
295  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
296  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
297  } ParkMessage_data_t;
298 #pragma pack(pop)
299 
300  ParkMessage_data_t *data;
301 
302  public:
303  ParkMessage();
304  ~ParkMessage();
305 
306  ParkMessage(const ParkMessage *m);
307  /* Methods */
308  virtual Message * clone() const;
309  };
310 
311  class GetUpMessage : public Message
312  {
313  private:
314 #pragma pack(push,4)
315  /** Internal data storage, do NOT modify! */
316  typedef struct {
317  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
318  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
319  } GetUpMessage_data_t;
320 #pragma pack(pop)
321 
322  GetUpMessage_data_t *data;
323 
324  public:
325  GetUpMessage();
326  ~GetUpMessage();
327 
328  GetUpMessage(const GetUpMessage *m);
329  /* Methods */
330  virtual Message * clone() const;
331  };
332 
333  class StandupMessage : public Message
334  {
335  private:
336 #pragma pack(push,4)
337  /** Internal data storage, do NOT modify! */
338  typedef struct {
339  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
340  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
341  int32_t from_pos; /**< Position from where to standup. */
342  } StandupMessage_data_t;
343 #pragma pack(pop)
344 
345  StandupMessage_data_t *data;
346 
347  public:
348  StandupMessage(const StandupEnum ini_from_pos);
349  StandupMessage();
350  ~StandupMessage();
351 
352  StandupMessage(const StandupMessage *m);
353  /* Methods */
354  StandupEnum from_pos() const;
355  void set_from_pos(const StandupEnum new_from_pos);
356  size_t maxlenof_from_pos() const;
357  virtual Message * clone() const;
358  };
359 
360  class MoveHeadMessage : public Message
361  {
362  private:
363 #pragma pack(push,4)
364  /** Internal data storage, do NOT modify! */
365  typedef struct {
366  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
367  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
368  float yaw; /**< Desired yaw (horizontal orientation). */
369  float pitch; /**< Desired pitch (vertical orientation). */
370  float speed; /**< Maximum speed in [0.0..1.0]. */
371  } MoveHeadMessage_data_t;
372 #pragma pack(pop)
373 
374  MoveHeadMessage_data_t *data;
375 
376  public:
377  MoveHeadMessage(const float ini_yaw, const float ini_pitch, const float ini_speed);
378  MoveHeadMessage();
379  ~MoveHeadMessage();
380 
382  /* Methods */
383  float yaw() const;
384  void set_yaw(const float new_yaw);
385  size_t maxlenof_yaw() const;
386  float pitch() const;
387  void set_pitch(const float new_pitch);
388  size_t maxlenof_pitch() const;
389  float speed() const;
390  void set_speed(const float new_speed);
391  size_t maxlenof_speed() const;
392  virtual Message * clone() const;
393  };
394 
395  virtual bool message_valid(const Message *message) const;
396  private:
399 
400  public:
401  /* Methods */
402  bool is_moving() const;
403  void set_moving(const bool new_moving);
404  size_t maxlenof_moving() const;
405  bool is_arms_enabled() const;
406  void set_arms_enabled(const bool new_arms_enabled);
407  size_t maxlenof_arms_enabled() const;
408  uint32_t msgid() const;
409  void set_msgid(const uint32_t new_msgid);
410  size_t maxlenof_msgid() const;
411  virtual Message * create_message(const char *type) const;
412 
413  virtual void copy_values(const Interface *other);
414  virtual const char * enum_tostring(const char *enumtype, int val) const;
415 
416 };
417 
418 } // end namespace fawkes
419 
420 #endif
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
StandupMessage Fawkes BlackBoard Interface Message.
TurnMessage Fawkes BlackBoard Interface Message.
KickMessage Fawkes BlackBoard Interface Message.
float distance(float x1, float y1, float x2, float y2)
Get distance between two 2D cartesian coordinates.
Definition: angle.h:62
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
const char * type() const
Get message type.
Definition: message.cpp:378
size_t maxlenof_arms_enabled() const
Get maximum length of arms_enabled value.
Fawkes library namespace.
void set_arms_enabled(const bool new_arms_enabled)
Set arms_enabled value.
WalkVelocityMessage Fawkes BlackBoard Interface Message.
void set_moving(const bool new_moving)
Set moving value.
GetUpMessage Fawkes BlackBoard Interface Message.
StandupEnum
From which position to standup.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
virtual Message * clone() const
Clone this message.
bool is_arms_enabled() const
Get arms_enabled value.
LegEnum
Type to determinate leg side.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
WalkArcMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_moving() const
Get maximum length of moving value.
HumanoidMotionInterface Fawkes BlackBoard Interface.
const char * tostring_LegEnum(LegEnum value) const
Convert LegEnum constant to string.
const char * tostring_StandupEnum(StandupEnum value) const
Convert StandupEnum constant to string.
virtual Message * create_message(const char *type) const
Create message based on type name.
WalkSidewaysMessage Fawkes BlackBoard Interface Message.
virtual void copy_values(const Interface *other)
Copy values from other interface.
ParkMessage Fawkes BlackBoard Interface Message.
WalkStraightMessage Fawkes BlackBoard Interface Message.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
size_t maxlenof_msgid() const
Get maximum length of msgid value.
bool is_moving() const
Get moving value.
MoveHeadMessage Fawkes BlackBoard Interface Message.
StopMessage Fawkes BlackBoard Interface Message.
uint32_t msgid() const
Get msgid value.