Fawkes API  Fawkes Development Version
HumanoidMotionInterface.h
00001 
00002 /***************************************************************************
00003  *  HumanoidMotionInterface.h - Fawkes BlackBoard Interface - HumanoidMotionInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2008  Tim Niemueller
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __INTERFACES_HUMANOIDMOTIONINTERFACE_H_
00025 #define __INTERFACES_HUMANOIDMOTIONINTERFACE_H_
00026 
00027 #include <interface/interface.h>
00028 #include <interface/message.h>
00029 #include <interface/field_iterator.h>
00030 
00031 namespace fawkes {
00032 
00033 class HumanoidMotionInterface : public Interface
00034 {
00035  /// @cond INTERNALS
00036  INTERFACE_MGMT_FRIENDS(HumanoidMotionInterface)
00037  /// @endcond
00038  public:
00039   /* constants */
00040 
00041   /** Type to determinate leg side. */
00042   typedef enum {
00043     LEG_LEFT /**< Left leg. */,
00044     LEG_RIGHT /**< Right leg. */
00045   } LegEnum;
00046   const char * tostring_LegEnum(LegEnum value) const;
00047 
00048   /** From which position to standup. */
00049   typedef enum {
00050     STANDUP_DETECT /**< Detect via accelerometer. */,
00051     STANDUP_BACK /**< Standup from lying on the back. */,
00052     STANDUP_FRONT /**< Standup from lying on the tummy. */
00053   } StandupEnum;
00054   const char * tostring_StandupEnum(StandupEnum value) const;
00055 
00056  private:
00057 #pragma pack(push,4)
00058   /** Internal data storage, do NOT modify! */
00059   typedef struct {
00060     int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00061     int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00062     bool moving; /**< True if the robot is moving. */
00063     bool arms_enabled; /**< 
00064       If true the arms are controlled during walking for balancing.
00065      */
00066     uint32_t msgid; /**< 
00067       The ID of the message that is currently being
00068       processed, or 0 if no message is being processed.
00069      */
00070   } HumanoidMotionInterface_data_t;
00071 #pragma pack(pop)
00072 
00073   HumanoidMotionInterface_data_t *data;
00074 
00075  public:
00076   /* messages */
00077   class StopMessage : public Message
00078   {
00079    private:
00080 #pragma pack(push,4)
00081     /** Internal data storage, do NOT modify! */
00082     typedef struct {
00083       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00084       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00085     } StopMessage_data_t;
00086 #pragma pack(pop)
00087 
00088     StopMessage_data_t *data;
00089 
00090    public:
00091     StopMessage();
00092     ~StopMessage();
00093 
00094     StopMessage(const StopMessage *m);
00095     /* Methods */
00096     virtual Message * clone() const;
00097   };
00098 
00099   class WalkStraightMessage : public Message
00100   {
00101    private:
00102 #pragma pack(push,4)
00103     /** Internal data storage, do NOT modify! */
00104     typedef struct {
00105       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00106       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00107       float distance; /**< Distance in m to walk. */
00108     } WalkStraightMessage_data_t;
00109 #pragma pack(pop)
00110 
00111     WalkStraightMessage_data_t *data;
00112 
00113    public:
00114     WalkStraightMessage(const float ini_distance);
00115     WalkStraightMessage();
00116     ~WalkStraightMessage();
00117 
00118     WalkStraightMessage(const WalkStraightMessage *m);
00119     /* Methods */
00120     float distance() const;
00121     void set_distance(const float new_distance);
00122     size_t maxlenof_distance() const;
00123     virtual Message * clone() const;
00124   };
00125 
00126   class WalkSidewaysMessage : public Message
00127   {
00128    private:
00129 #pragma pack(push,4)
00130     /** Internal data storage, do NOT modify! */
00131     typedef struct {
00132       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00133       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00134       float distance; /**< Distance in m to walk. */
00135     } WalkSidewaysMessage_data_t;
00136 #pragma pack(pop)
00137 
00138     WalkSidewaysMessage_data_t *data;
00139 
00140    public:
00141     WalkSidewaysMessage(const float ini_distance);
00142     WalkSidewaysMessage();
00143     ~WalkSidewaysMessage();
00144 
00145     WalkSidewaysMessage(const WalkSidewaysMessage *m);
00146     /* Methods */
00147     float distance() const;
00148     void set_distance(const float new_distance);
00149     size_t maxlenof_distance() const;
00150     virtual Message * clone() const;
00151   };
00152 
00153   class WalkArcMessage : public Message
00154   {
00155    private:
00156 #pragma pack(push,4)
00157     /** Internal data storage, do NOT modify! */
00158     typedef struct {
00159       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00160       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00161       float angle; /**< Angle in radians to turn over the way. */
00162       float radius; /**< Radius in m of the circle in m. */
00163     } WalkArcMessage_data_t;
00164 #pragma pack(pop)
00165 
00166     WalkArcMessage_data_t *data;
00167 
00168    public:
00169     WalkArcMessage(const float ini_angle, const float ini_radius);
00170     WalkArcMessage();
00171     ~WalkArcMessage();
00172 
00173     WalkArcMessage(const WalkArcMessage *m);
00174     /* Methods */
00175     float angle() const;
00176     void set_angle(const float new_angle);
00177     size_t maxlenof_angle() const;
00178     float radius() const;
00179     void set_radius(const float new_radius);
00180     size_t maxlenof_radius() const;
00181     virtual Message * clone() const;
00182   };
00183 
00184   class WalkVelocityMessage : public Message
00185   {
00186    private:
00187 #pragma pack(push,4)
00188     /** Internal data storage, do NOT modify! */
00189     typedef struct {
00190       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00191       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00192       float x; /**< 
00193       Fraction of MaxStepX. Use negative for backwards. [-1.0 to 1.0].
00194      */
00195       float y; /**< 
00196       Fraction of MaxStepY. Use negative for right. [-1.0 to 1.0].
00197      */
00198       float theta; /**< 
00199       Fraction of MaxStepTheta. Use negative for clockwise [-1.0 to 1.0].
00200      */
00201       float speed; /**< 
00202       Fraction of MaxStepFrequency [0.0 to 1.0].
00203      */
00204     } WalkVelocityMessage_data_t;
00205 #pragma pack(pop)
00206 
00207     WalkVelocityMessage_data_t *data;
00208 
00209    public:
00210     WalkVelocityMessage(const float ini_x, const float ini_y, const float ini_theta, const float ini_speed);
00211     WalkVelocityMessage();
00212     ~WalkVelocityMessage();
00213 
00214     WalkVelocityMessage(const WalkVelocityMessage *m);
00215     /* Methods */
00216     float x() const;
00217     void set_x(const float new_x);
00218     size_t maxlenof_x() const;
00219     float y() const;
00220     void set_y(const float new_y);
00221     size_t maxlenof_y() const;
00222     float theta() const;
00223     void set_theta(const float new_theta);
00224     size_t maxlenof_theta() const;
00225     float speed() const;
00226     void set_speed(const float new_speed);
00227     size_t maxlenof_speed() const;
00228     virtual Message * clone() const;
00229   };
00230 
00231   class TurnMessage : public Message
00232   {
00233    private:
00234 #pragma pack(push,4)
00235     /** Internal data storage, do NOT modify! */
00236     typedef struct {
00237       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00238       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00239       float angle; /**< Angle in radians to turn. */
00240     } TurnMessage_data_t;
00241 #pragma pack(pop)
00242 
00243     TurnMessage_data_t *data;
00244 
00245    public:
00246     TurnMessage(const float ini_angle);
00247     TurnMessage();
00248     ~TurnMessage();
00249 
00250     TurnMessage(const TurnMessage *m);
00251     /* Methods */
00252     float angle() const;
00253     void set_angle(const float new_angle);
00254     size_t maxlenof_angle() const;
00255     virtual Message * clone() const;
00256   };
00257 
00258   class KickMessage : public Message
00259   {
00260    private:
00261 #pragma pack(push,4)
00262     /** Internal data storage, do NOT modify! */
00263     typedef struct {
00264       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00265       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00266       int32_t leg; /**< Leg to kick with */
00267       float strength; /**< Kick strength */
00268     } KickMessage_data_t;
00269 #pragma pack(pop)
00270 
00271     KickMessage_data_t *data;
00272 
00273    public:
00274     KickMessage(const LegEnum ini_leg, const float ini_strength);
00275     KickMessage();
00276     ~KickMessage();
00277 
00278     KickMessage(const KickMessage *m);
00279     /* Methods */
00280     LegEnum leg() const;
00281     void set_leg(const LegEnum new_leg);
00282     size_t maxlenof_leg() const;
00283     float strength() const;
00284     void set_strength(const float new_strength);
00285     size_t maxlenof_strength() const;
00286     virtual Message * clone() const;
00287   };
00288 
00289   class ParkMessage : public Message
00290   {
00291    private:
00292 #pragma pack(push,4)
00293     /** Internal data storage, do NOT modify! */
00294     typedef struct {
00295       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00296       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00297     } ParkMessage_data_t;
00298 #pragma pack(pop)
00299 
00300     ParkMessage_data_t *data;
00301 
00302    public:
00303     ParkMessage();
00304     ~ParkMessage();
00305 
00306     ParkMessage(const ParkMessage *m);
00307     /* Methods */
00308     virtual Message * clone() const;
00309   };
00310 
00311   class GetUpMessage : public Message
00312   {
00313    private:
00314 #pragma pack(push,4)
00315     /** Internal data storage, do NOT modify! */
00316     typedef struct {
00317       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00318       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00319     } GetUpMessage_data_t;
00320 #pragma pack(pop)
00321 
00322     GetUpMessage_data_t *data;
00323 
00324    public:
00325     GetUpMessage();
00326     ~GetUpMessage();
00327 
00328     GetUpMessage(const GetUpMessage *m);
00329     /* Methods */
00330     virtual Message * clone() const;
00331   };
00332 
00333   class StandupMessage : public Message
00334   {
00335    private:
00336 #pragma pack(push,4)
00337     /** Internal data storage, do NOT modify! */
00338     typedef struct {
00339       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00340       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00341       int32_t from_pos; /**< Position from where to standup. */
00342     } StandupMessage_data_t;
00343 #pragma pack(pop)
00344 
00345     StandupMessage_data_t *data;
00346 
00347    public:
00348     StandupMessage(const StandupEnum ini_from_pos);
00349     StandupMessage();
00350     ~StandupMessage();
00351 
00352     StandupMessage(const StandupMessage *m);
00353     /* Methods */
00354     StandupEnum from_pos() const;
00355     void set_from_pos(const StandupEnum new_from_pos);
00356     size_t maxlenof_from_pos() const;
00357     virtual Message * clone() const;
00358   };
00359 
00360   class MoveHeadMessage : public Message
00361   {
00362    private:
00363 #pragma pack(push,4)
00364     /** Internal data storage, do NOT modify! */
00365     typedef struct {
00366       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00367       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00368       float yaw; /**< Desired yaw (horizontal orientation). */
00369       float pitch; /**< Desired pitch (vertical orientation). */
00370       float speed; /**< Maximum speed in [0.0..1.0]. */
00371     } MoveHeadMessage_data_t;
00372 #pragma pack(pop)
00373 
00374     MoveHeadMessage_data_t *data;
00375 
00376    public:
00377     MoveHeadMessage(const float ini_yaw, const float ini_pitch, const float ini_speed);
00378     MoveHeadMessage();
00379     ~MoveHeadMessage();
00380 
00381     MoveHeadMessage(const MoveHeadMessage *m);
00382     /* Methods */
00383     float yaw() const;
00384     void set_yaw(const float new_yaw);
00385     size_t maxlenof_yaw() const;
00386     float pitch() const;
00387     void set_pitch(const float new_pitch);
00388     size_t maxlenof_pitch() const;
00389     float speed() const;
00390     void set_speed(const float new_speed);
00391     size_t maxlenof_speed() const;
00392     virtual Message * clone() const;
00393   };
00394 
00395   virtual bool message_valid(const Message *message) const;
00396  private:
00397   HumanoidMotionInterface();
00398   ~HumanoidMotionInterface();
00399 
00400  public:
00401   /* Methods */
00402   bool is_moving() const;
00403   void set_moving(const bool new_moving);
00404   size_t maxlenof_moving() const;
00405   bool is_arms_enabled() const;
00406   void set_arms_enabled(const bool new_arms_enabled);
00407   size_t maxlenof_arms_enabled() const;
00408   uint32_t msgid() const;
00409   void set_msgid(const uint32_t new_msgid);
00410   size_t maxlenof_msgid() const;
00411   virtual Message * create_message(const char *type) const;
00412 
00413   virtual void copy_values(const Interface *other);
00414   virtual const char * enum_tostring(const char *enumtype, int val) const;
00415 
00416 };
00417 
00418 } // end namespace fawkes
00419 
00420 #endif