00001 /** 00002 * @file GT2003MotionNetSpecialActions.h 00003 * 00004 * This file contains a class for GT2003 motion net special actions. 00005 * @author Uwe Düffert, Max Risler 00006 */ 00007 00008 #ifndef __GT2003MotionNetSpecialActions_h_ 00009 #define __GT2003MotionNetSpecialActions_h_ 00010 00011 #include "../SpecialActions.h" 00012 #include "MotionNetData.h" 00013 00014 /** 00015 * This module executes special actions by using the GT2003 00016 * motion net compiler 00017 */ 00018 class GT2003MotionNetSpecialActions : public SpecialActions 00019 { 00020 public: 00021 /* 00022 * Constructor. 00023 * @param interfaces The paramters of the SpecialActions module. 00024 */ 00025 GT2003MotionNetSpecialActions(SpecialActionsInterfaces& interfaces); 00026 00027 /** Executes the special action */ 00028 virtual bool executeParameterized(SpecialActionRequest specialActionRequest, JointData& jointData); 00029 00030 /* 00031 * Determines wether or not a Specialaction can be executed in current phase of Walking cycle 00032 * @param specialActionID SpecialActionID for Specialaction that information for is needed 00033 * @return wether the Specialaction can be executed in current Walkingcycle 00034 */ 00035 virtual bool specialActionIsExecutableInWalkingCycle(int specialActionID, double walkCycle); 00036 00037 /** 00038 * Called from a MessageQueue to distribute messages. 00039 * @param message The message that can be read. 00040 * @return true if the message was read (handled). 00041 */ 00042 virtual bool handleMessage(InMessage& message); 00043 00044 protected: 00045 /** Get motion net motion index from motion type and special action id */ 00046 int getMotionIndex(MotionRequest::MotionID motionType, SpecialActionRequest::SpecialActionID specialActionType); 00047 00048 /** Get motion net motion index from a MotionRequest */ 00049 int getMotionIndex(const SpecialActionRequest& request); 00050 00051 /** Get next motion node from motion net */ 00052 bool getNextData(const SpecialActionRequest& specialActionRequest); 00053 00054 /** Calculates the next joint data vector by interpolating if necessary */ 00055 void calculateJointData(JointData& jointData); 00056 00057 /** The motion data array */ 00058 MotionNetData motionNetData; 00059 00060 /** Current motion net node */ 00061 short currentNode; 00062 00063 //! Current joint data 00064 JointData currentData; 00065 //! Last data for interpolation 00066 JointData lastData; 00067 00068 //! Last data was set 00069 bool lastDataValid; 00070 //! True if values should be interpolated 00071 bool interpolationMode; 00072 00073 //! Length of current data line in cycles 00074 long dataRepetitionLength; 00075 //! Cycle counter for current data line 00076 long dataRepetitionCounter; 00077 00078 /** Odometry table entry 00079 * Contains type of odometry and odometry pose 00080 */ 00081 class OdometryEntry { 00082 public: 00083 /** Enum for odometry types 00084 * none: No odometry, means no movement 00085 * once: Odometry pose is used once the motion is executed 00086 * homegeneous: Odometry pose describes speed and is used each tick 00087 */ 00088 enum OdometryType { 00089 none, 00090 once, 00091 homogeneous 00092 }; 00093 00094 OdometryType type; 00095 OdometryData o; 00096 00097 int walkCycleDissection; 00098 std::vector<int> leaveWalkCycleSections; 00099 00100 OdometryEntry() : type(none), walkCycleDissection(0) {}; 00101 }; 00102 00103 /** Odometry data table 00104 * Contains one entry for each motion 00105 * describing robot movement per tick. 00106 */ 00107 OdometryEntry odometryTable[SpecialActionRequest::numOfSpecialAction + 1]; 00108 00109 /** Head states for each special action */ 00110 MotionInfo motionInfoTable[SpecialActionRequest::numOfSpecialAction + 1]; 00111 00112 /** A table for the executed motion requests */ 00113 MotionRequest executedMotionRequestTable[SpecialActionRequest::numOfSpecialAction + 1]; 00114 00115 /** Odometry of current motion */ 00116 OdometryEntry currentOdometry; 00117 00118 /** Read odometry table from file */ 00119 void readOdometryTable(); 00120 00121 /** type of last executed special action */ 00122 SpecialActionRequest::SpecialActionID lastSpecialActionType; 00123 }; 00124 00125 #endif// __GT2003MotionNetSpecialActions_h_
1.3.6