00001 /** 00002 * @file GT2003MotionNetSpecialActions/MotionNetNode.h 00003 * 00004 * Contains class MotionNetNode 00005 * 00006 * @author Uwe Düffert, Martin Lötzsch, Max Risler 00007 */ 00008 00009 #ifndef __MOTIONNETNODE_H_ 00010 #define __MOTIONNETNODE_H_ 00011 00012 #include "Representations/Motion/MotionRequest.h" 00013 #include "Representations/Motion/JointData.h" 00014 #include "Representations/Motion/PIDData.h" 00015 00016 #define INVAL 10000 00017 #define DEFLT 10000 00018 00019 /** 00020 * Represents a node of the motion net. 00021 * The motion net is organised in an array of nodes (MotionNetNode). 00022 * 00023 * @author Uwe Düffert <dueffert@informatik.hu-berlin.de> 00024 */ 00025 typedef struct MotionNetNode 00026 { 00027 public: 00028 enum NodeType { 00029 //! the current node is a conditional transition 00030 typeConditionalTransition, 00031 //! the current node is a transition 00032 typeTransition, 00033 //! the current node is a motor data vector 00034 typeData, 00035 //! the current node is a pid data vector 00036 typePID 00037 }; 00038 00039 //! Represent a set of values from a data line 00040 short d[24]; 00041 /* 00042 //possible content: 00043 {typeData, d[0]..d[19], interpolationMode, dataRepetitionCounter, execMotionRequest} 00044 {typeConditionalTransition, to_motion, via_label, 20*0, execMotionRequest} 00045 {typeTransition, to_label, 21*0, execMotionRequest} 00046 {typePIDData, joint, p, i, d, 18*0, execMotionRequest} 00047 */ 00048 00049 void toJointData(JointData& jointData, long& dataRepetitionCounter, bool& interpolationMode) 00050 { 00051 //head 00052 jointData.data[JointData::neckTilt] = d[1]*1000; 00053 jointData.data[JointData::headPan] = d[2]*1000; 00054 jointData.data[JointData::headTilt] = d[3]*1000; 00055 //mouth 00056 jointData.data[JointData::mouth] = d[4]*1000; 00057 //tail 00058 jointData.data[JointData::tailPan] = d[5]*1000; 00059 jointData.data[JointData::tailTilt] = d[6]*1000; 00060 //legs 00061 for (int i=0;i<12;i++) 00062 jointData.data[JointData::legFR1 + i] = d[i + 7]*1000; 00063 //ears 00064 jointData.data[JointData::earL] = d[19]*1000; 00065 jointData.data[JointData::earR] = d[20]*1000; 00066 //timing information 00067 interpolationMode = (d[21] == 1); 00068 dataRepetitionCounter = d[22]; 00069 } 00070 00071 void toPIDData(PIDData& pidData) 00072 { 00073 PIDData defaultPid; 00074 short pv = (d[2] == DEFLT) ? defaultPid.p[d[1]] : d[2]; 00075 short iv = (d[3] == DEFLT) ? defaultPid.i[d[1]] : d[3]; 00076 short dv = (d[4] == DEFLT) ? defaultPid.d[d[1]] : d[4]; 00077 pidData.setValues((JointData::JointID)d[1],pv,iv,dv); 00078 } 00079 00080 void toExecutedMotionRequest(MotionRequest& execMR) 00081 { 00082 if (d[23]>=0) 00083 execMR.motionType = MotionRequest::specialAction; 00084 execMR.specialActionRequest.specialActionType = (SpecialActionRequest::SpecialActionID)d[23]; 00085 } 00086 00087 } MotionNetNode; 00088 00089 #endif
1.3.6