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
31namespace 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. */
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. */
54 const char * tostring_StandupEnum(StandupEnum value) const;
55
56 private:
57 /** Internal data storage, do NOT modify! */
58 typedef struct {
59 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
60 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
61 bool moving; /**< True if the robot is moving. */
62 bool arms_enabled; /**<
63 If true the arms are controlled during walking for balancing.
64 */
65 uint32_t msgid; /**<
66 The ID of the message that is currently being
67 processed, or 0 if no message is being processed.
68 */
69 } HumanoidMotionInterface_data_t;
70
71 HumanoidMotionInterface_data_t *data;
72
73 interface_enum_map_t enum_map_LegEnum;
74 interface_enum_map_t enum_map_StandupEnum;
75 public:
76 /* messages */
77 class StopMessage : public Message
78 {
79 private:
80 /** Internal data storage, do NOT modify! */
81 typedef struct {
82 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
83 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
84 } StopMessage_data_t;
85
86 StopMessage_data_t *data;
87
88 interface_enum_map_t enum_map_LegEnum;
89 interface_enum_map_t enum_map_StandupEnum;
90 public:
93
94 explicit StopMessage(const StopMessage *m);
95 /* Methods */
96 virtual Message * clone() const;
97 };
98
100 {
101 private:
102 /** Internal data storage, do NOT modify! */
103 typedef struct {
104 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
105 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
106 float distance; /**< Distance in m to walk. */
107 } WalkStraightMessage_data_t;
108
109 WalkStraightMessage_data_t *data;
110
111 interface_enum_map_t enum_map_LegEnum;
112 interface_enum_map_t enum_map_StandupEnum;
113 public:
114 WalkStraightMessage(const float ini_distance);
117
118 explicit WalkStraightMessage(const WalkStraightMessage *m);
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 /** Internal data storage, do NOT modify! */
130 typedef struct {
131 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
132 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
133 float distance; /**< Distance in m to walk. */
134 } WalkSidewaysMessage_data_t;
135
136 WalkSidewaysMessage_data_t *data;
137
138 interface_enum_map_t enum_map_LegEnum;
139 interface_enum_map_t enum_map_StandupEnum;
140 public:
141 WalkSidewaysMessage(const float ini_distance);
144
145 explicit WalkSidewaysMessage(const WalkSidewaysMessage *m);
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 /** Internal data storage, do NOT modify! */
157 typedef struct {
158 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
159 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
160 float angle; /**< Angle in radians to turn over the way. */
161 float radius; /**< Radius in m of the circle in m. */
162 } WalkArcMessage_data_t;
163
164 WalkArcMessage_data_t *data;
165
166 interface_enum_map_t enum_map_LegEnum;
167 interface_enum_map_t enum_map_StandupEnum;
168 public:
169 WalkArcMessage(const float ini_angle, const float ini_radius);
172
173 explicit 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 /** Internal data storage, do NOT modify! */
188 typedef struct {
189 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
190 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
191 float x; /**<
192 Fraction of MaxStepX. Use negative for backwards. [-1.0 to 1.0].
193 */
194 float y; /**<
195 Fraction of MaxStepY. Use negative for right. [-1.0 to 1.0].
196 */
197 float theta; /**<
198 Fraction of MaxStepTheta. Use negative for clockwise [-1.0 to 1.0].
199 */
200 float speed; /**<
201 Fraction of MaxStepFrequency [0.0 to 1.0].
202 */
203 } WalkVelocityMessage_data_t;
204
205 WalkVelocityMessage_data_t *data;
206
207 interface_enum_map_t enum_map_LegEnum;
208 interface_enum_map_t enum_map_StandupEnum;
209 public:
210 WalkVelocityMessage(const float ini_x, const float ini_y, const float ini_theta, const float ini_speed);
213
214 explicit WalkVelocityMessage(const WalkVelocityMessage *m);
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 /** Internal data storage, do NOT modify! */
235 typedef struct {
236 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
237 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
238 float angle; /**< Angle in radians to turn. */
239 } TurnMessage_data_t;
240
241 TurnMessage_data_t *data;
242
243 interface_enum_map_t enum_map_LegEnum;
244 interface_enum_map_t enum_map_StandupEnum;
245 public:
246 TurnMessage(const float ini_angle);
247 TurnMessage();
248 ~TurnMessage();
249
250 explicit 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 /** Internal data storage, do NOT modify! */
262 typedef struct {
263 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
264 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
265 int32_t leg; /**< Leg to kick with */
266 float strength; /**< Kick strength */
267 } KickMessage_data_t;
268
269 KickMessage_data_t *data;
270
271 interface_enum_map_t enum_map_LegEnum;
272 interface_enum_map_t enum_map_StandupEnum;
273 public:
274 KickMessage(const LegEnum ini_leg, const float ini_strength);
275 KickMessage();
276 ~KickMessage();
277
278 explicit 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 /** Internal data storage, do NOT modify! */
293 typedef struct {
294 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
295 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
296 } ParkMessage_data_t;
297
298 ParkMessage_data_t *data;
299
300 interface_enum_map_t enum_map_LegEnum;
301 interface_enum_map_t enum_map_StandupEnum;
302 public:
303 ParkMessage();
304 ~ParkMessage();
305
306 explicit ParkMessage(const ParkMessage *m);
307 /* Methods */
308 virtual Message * clone() const;
309 };
310
311 class GetUpMessage : public Message
312 {
313 private:
314 /** Internal data storage, do NOT modify! */
315 typedef struct {
316 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
317 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
318 } GetUpMessage_data_t;
319
320 GetUpMessage_data_t *data;
321
322 interface_enum_map_t enum_map_LegEnum;
323 interface_enum_map_t enum_map_StandupEnum;
324 public:
325 GetUpMessage();
327
328 explicit GetUpMessage(const GetUpMessage *m);
329 /* Methods */
330 virtual Message * clone() const;
331 };
332
333 class StandupMessage : public Message
334 {
335 private:
336 /** Internal data storage, do NOT modify! */
337 typedef struct {
338 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
339 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
340 int32_t from_pos; /**< Position from where to standup. */
341 } StandupMessage_data_t;
342
343 StandupMessage_data_t *data;
344
345 interface_enum_map_t enum_map_LegEnum;
346 interface_enum_map_t enum_map_StandupEnum;
347 public:
348 StandupMessage(const StandupEnum ini_from_pos);
351
352 explicit 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
361 {
362 private:
363 /** Internal data storage, do NOT modify! */
364 typedef struct {
365 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
366 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
367 float yaw; /**< Desired yaw (horizontal orientation). */
368 float pitch; /**< Desired pitch (vertical orientation). */
369 float speed; /**< Maximum speed in [0.0..1.0]. */
370 } MoveHeadMessage_data_t;
371
372 MoveHeadMessage_data_t *data;
373
374 interface_enum_map_t enum_map_LegEnum;
375 interface_enum_map_t enum_map_StandupEnum;
376 public:
377 MoveHeadMessage(const float ini_yaw, const float ini_pitch, const float ini_speed);
380
381 explicit MoveHeadMessage(const MoveHeadMessage *m);
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
GetUpMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
KickMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_strength(const float new_strength)
Set strength value.
size_t maxlenof_strength() const
Get maximum length of strength value.
void set_leg(const LegEnum new_leg)
Set leg value.
size_t maxlenof_leg() const
Get maximum length of leg value.
MoveHeadMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_speed() const
Get maximum length of speed value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_pitch() const
Get maximum length of pitch value.
void set_speed(const float new_speed)
Set speed value.
void set_pitch(const float new_pitch)
Set pitch value.
size_t maxlenof_yaw() const
Get maximum length of yaw value.
ParkMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
StandupMessage Fawkes BlackBoard Interface Message.
void set_from_pos(const StandupEnum new_from_pos)
Set from_pos value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_from_pos() const
Get maximum length of from_pos value.
StopMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
TurnMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_angle() const
Get maximum length of angle value.
virtual Message * clone() const
Clone this message.
void set_angle(const float new_angle)
Set angle value.
WalkArcMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_angle() const
Get maximum length of angle value.
void set_angle(const float new_angle)
Set angle value.
void set_radius(const float new_radius)
Set radius value.
size_t maxlenof_radius() const
Get maximum length of radius value.
virtual Message * clone() const
Clone this message.
WalkSidewaysMessage Fawkes BlackBoard Interface Message.
void set_distance(const float new_distance)
Set distance value.
size_t maxlenof_distance() const
Get maximum length of distance value.
virtual Message * clone() const
Clone this message.
WalkStraightMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_distance() const
Get maximum length of distance value.
void set_distance(const float new_distance)
Set distance value.
virtual Message * clone() const
Clone this message.
WalkVelocityMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_speed() const
Get maximum length of speed value.
void set_speed(const float new_speed)
Set speed value.
void set_theta(const float new_theta)
Set theta value.
size_t maxlenof_x() const
Get maximum length of x value.
size_t maxlenof_theta() const
Get maximum length of theta value.
size_t maxlenof_y() const
Get maximum length of y value.
virtual Message * clone() const
Clone this message.
HumanoidMotionInterface Fawkes BlackBoard Interface.
uint32_t msgid() const
Get msgid value.
size_t maxlenof_moving() const
Get maximum length of moving value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
bool is_arms_enabled() const
Get arms_enabled value.
size_t maxlenof_msgid() const
Get maximum length of msgid value.
void set_msgid(const uint32_t new_msgid)
Set msgid value.
bool is_moving() const
Get moving value.
void set_moving(const bool new_moving)
Set moving value.
virtual Message * create_message(const char *type) const
Create message based on type name.
LegEnum
Type to determinate leg side.
size_t maxlenof_arms_enabled() const
Get maximum length of arms_enabled value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
const char * tostring_StandupEnum(StandupEnum value) const
Convert StandupEnum constant to string.
StandupEnum
From which position to standup.
@ STANDUP_DETECT
Detect via accelerometer.
@ STANDUP_BACK
Standup from lying on the back.
@ STANDUP_FRONT
Standup from lying on the tummy.
virtual void copy_values(const Interface *other)
Copy values from other interface.
void set_arms_enabled(const bool new_arms_enabled)
Set arms_enabled value.
const char * tostring_LegEnum(LegEnum value) const
Convert LegEnum constant to string.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Fawkes library namespace.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:54