Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Representations/Motion/JointData.h

Go to the documentation of this file.

    00001 /**
    00002 * @file JointData.h
    00003 *
    00004 * Definition of JointData struct.
    00005 * The jointdata struct is a non NDA violating description of join vector data
    00006 *
    00007 * @author Max Risler
    00008 */
    00009 #ifndef __JOINTDATA_H__
    00010 #define __JOINTDATA_H__
    00011
    00012 /** Invalid motor data value.
    00013  * If this value was returned by motion module for the head,
    00014  * other head movement is possible */
    00015 static const long jointDataInvalidValue = 10000000;
    00016
    00017 #include "Tools/Streams/InOut.h"
    00018 #include "Tools/Streams/Streamable.h"
    00019
    00020 /**
    00021 * One joint data set. Containing values for all used joints.
    00022 * @author Max Risler
    00023 */
    00024 struct JointData : public Streamable
    00025 {
    00026   void serialize(In* in, Out* out)
    00027   {
    00028     STREAM_REGISTER_BEGIN();
    00029     STREAM(data[neckTilt]);
    00030     STREAM(data[headPan]);
    00031     STREAM(data[headTilt]);
    00032     STREAM(data[mouth]);
    00033     STREAM(data[earL]);
    00034     STREAM(data[earR]);
    00035     STREAM(data[legFR1]);
    00036     STREAM(data[legFR2]);
    00037     STREAM(data[legFR3]);
    00038     STREAM(data[legFL1]);
    00039     STREAM(data[legFL2]);
    00040     STREAM(data[legFL3]);
    00041     STREAM(data[legHR1]);
    00042     STREAM(data[legHR2]);
    00043     STREAM(data[legHR3]);
    00044     STREAM(data[legHL1]);
    00045     STREAM(data[legHL2]);
    00046     STREAM(data[legHL3]);
    00047     STREAM(data[tailPan]);
    00048     STREAM(data[tailTilt]);
    00049     STREAM_REGISTER_FINISH();
    00050   }
    00051
    00052 public:
    00053   /**
    00054    * enum describing indexes of joints
    00055    */
    00056   enum JointID {
    00057     headTilt210,
    00058     neckTilt = headTilt210,
    00059     headPan210,
    00060     headPan = headPan210,
    00061     headRoll210,
    00062     headTilt = headRoll210,
    00063     mouth,
    00064     earL, earR,
    00065     legFR1, legFR2, legFR3,
    00066     legFL1, legFL2, legFL3,
    00067     legHR1, legHR2, legHR3,
    00068     legHL1, legHL2, legHL3,
    00069     tailPan, tailTilt,
    00070       numOfJoint
    00071   };
    00072
    00073   /** The joint data values */
    00074   long data[numOfJoint];
    00075
    00076   /** Default constructor */
    00077   JointData(long headTiltValue = jointDataInvalidValue,
    00078     long headPanValue = jointDataInvalidValue,
    00079     long headRollValue = jointDataInvalidValue,
    00080     long mouthValue = jointDataInvalidValue,
    00081     long earLValue = jointDataInvalidValue,
    00082     long earRValue = jointDataInvalidValue,
    00083     long legFR1Value = jointDataInvalidValue,
    00084     long legFR2Value = jointDataInvalidValue,
    00085     long legFR3Value = jointDataInvalidValue,
    00086     long legFL1Value = jointDataInvalidValue,
    00087     long legFL2Value = jointDataInvalidValue,
    00088     long legFL3Value = jointDataInvalidValue,
    00089     long legHR1Value = jointDataInvalidValue,
    00090     long legHR2Value = jointDataInvalidValue,
    00091     long legHR3Value = jointDataInvalidValue,
    00092     long legHL1Value = jointDataInvalidValue,
    00093     long legHL2Value = jointDataInvalidValue,
    00094     long legHL3Value = jointDataInvalidValue,
    00095     long tailPanValue = jointDataInvalidValue,
    00096     long tailTiltValue = jointDataInvalidValue
    00097   );
    00098
    00099   /** Assignment operator */
    00100   JointData& operator=(const JointData& other);
    00101
    00102   /** Copy constructor */
    00103   JointData(const JointData& other);
    00104
    00105   /** returns the name of a joint */
    00106   static const char* getJointName(JointID joint)
    00107   {
    00108     switch (joint)
    00109     {
    00110     case headTilt210: return "neckTilt (headTilt210)";
    00111     case headPan210: return "headPan";
    00112     case headRoll210: return "headTilt (headRoll210)";
    00113     case mouth: return "mouth";
    00114     case earL: return "earL";
    00115     case earR: return "earR";
    00116     case legFR1: return "legFR1";
    00117     case legFR2: return "legFR2";
    00118     case legFR3: return "legFR3";
    00119     case legFL1: return "legFL1";
    00120     case legFL2: return "legFL2";
    00121     case legFL3: return "legFL3";
    00122     case legHR1: return "legHR1";
    00123     case legHR2: return "legHR2";
    00124     case legHR3: return "legHR3";
    00125     case legHL1: return "legHL1";
    00126     case legHL2: return "legHL2";
    00127     case legHL3: return "legHL3";
    00128     case tailPan: return "tailPan";
    00129     case tailTilt: return "tailTilt";
    00130     default: return "";
    00131     }
    00132   }
    00133
    00134   static JointID getIDFromName(const char* jointName);
    00135 };
    00136
    00137 /**
    00138  * Streaming operator that reads a JointData from a stream.
    00139  * @param stream The stream from which is read.
    00140  * @param jointData The JointData object.
    00141  * @return The stream.
    00142  */
    00143 //In& operator>>(In& stream,JointData& jointData);
    00144
    00145 /**
    00146  * Streaming operator that writes a JointData to a stream.
    00147  * @param stream The stream to write on.
    00148  * @param jointData The JointData object.
    00149  * @return The stream.
    00150  */
    00151 //Out& operator<<(Out& stream, const JointData& jointData);
    00152
    00153 #endif //__JOINTDATA_H__