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

Representations/Motion/PIDData.cpp

Go to the documentation of this file.
00001 /**
00002 * @file PIDData.cpp
00003 *
00004 * Implementation of class PIDData
00005 * 
00006 * @author Max Risler
00007 */
00008 
00009 #include "PIDData.h"
00010 #include "Platform/SystemCall.h"
00011 #include "Tools/RobotConfiguration.h"
00012 
00013 PIDData::PIDData()
00014 {
00015   setToDefaults();
00016 }
00017 
00018 PIDData& PIDData::operator=(const PIDData& other)
00019 {
00020   for (int j = 0; j < JointData::numOfJoint; j++)
00021   {
00022     p[j] = other.p[j];
00023     i[j] = other.i[j];
00024     d[j] = other.d[j];
00025   }
00026   return *this;
00027 }
00028 
00029 PIDData::PIDData(const PIDData& other)
00030 {
00031   *this = other;
00032 }
00033 
00034 void PIDData::setToDefaults()
00035 {
00036   bool isERS210 = getRobotConfiguration().getRobotDesign() == RobotDesign::ERS210;
00037   static const int pERS210[] = {0x0A,0x0D,0x0A,0x0E,0x00,0x00,0x16,0x14,0x23,0x16,0x14,0x23,0x16,0x14,0x23,0x16,0x14,0x23,0x0A,0x07},
00038                    iERS210[] = {0x08,0x08,0x08,0x08,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00},
00039                    dERS210[] = {0x0C,0x0B,0x0C,0x10,0x00,0x00,0x08,0x06,0x05,0x08,0x06,0x05,0x08,0x06,0x05,0x08,0x06,0x05,0x18,0x11},
00040                    pERS7[] =   {0x0A,0x08,0x08,0x08,0x00,0x00,0x1C,0x14,0x1C,0x1C,0x14,0x1C,0x1C,0x14,0x1C,0x1C,0x14,0x1C,0x0A,0x0A},
00041                    iERS7[] =   {0x04,0x02,0x04,0x00,0x00,0x00,0x08,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x08,0x04,0x04},
00042                    dERS7[] =   {0x02,0x04,0x02,0x04,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x04,0x04};
00043   const int* pp = isERS210 ? pERS210 : pERS7,
00044            * ii = isERS210 ? iERS210 : iERS7,
00045            * dd = isERS210 ? dERS210 : dERS7;
00046 
00047   for(int j = 0; j < JointData::numOfJoint; ++j)
00048   {
00049     p[j] = pp[j];
00050     i[j] = ii[j];
00051     d[j] = dd[j];
00052   }
00053 }
00054 
00055 void PIDData::setValues(JointData::JointID joint, int ap, int ai, int ad)
00056 {
00057   p[joint] = ap;
00058   i[joint] = ai;
00059   d[joint] = ad;
00060 }
00061 
00062 void PIDData::setLegFJ1Values(int ap, int ai, int ad)
00063 {
00064   setValues(JointData::legFR1, ap, ai, ad);
00065   setValues(JointData::legFL1, ap, ai, ad);
00066 }
00067 
00068 void PIDData::setLegHJ1Values(int ap, int ai, int ad)
00069 {
00070   setValues(JointData::legHR1, ap, ai, ad);
00071   setValues(JointData::legHL1, ap, ai, ad);
00072 }
00073 
00074 void PIDData::setLegFJ2Values(int ap, int ai, int ad)
00075 {
00076   setValues(JointData::legFR2, ap, ai, ad);
00077   setValues(JointData::legFL2, ap, ai, ad);
00078 }
00079 
00080 void PIDData::setLegHJ2Values(int ap, int ai, int ad)
00081 {
00082   setValues(JointData::legHR2, ap, ai, ad);
00083   setValues(JointData::legHL2, ap, ai, ad);
00084 }
00085 
00086 void PIDData::setLegFJ3Values(int ap, int ai, int ad)
00087 {
00088   setValues(JointData::legFR3, ap, ai, ad);
00089   setValues(JointData::legFL3, ap, ai, ad);
00090 }
00091 
00092 void PIDData::setLegHJ3Values(int ap, int ai, int ad)
00093 {
00094   setValues(JointData::legHR3, ap, ai, ad);
00095   setValues(JointData::legHL3, ap, ai, ad);
00096 }
00097 
00098 In& operator>>(In& stream,PIDData& pidData)
00099 {
00100   for (int i = 0; i < JointData::numOfJoint; i++)
00101   {
00102     stream >> pidData.p[i];
00103     stream >> pidData.i[i];
00104     stream >> pidData.d[i];
00105   }
00106   return stream;
00107 }
00108  
00109 Out& operator<<(Out& stream, const PIDData& pidData)
00110 {
00111   for (int i = 0; i < JointData::numOfJoint; i++)
00112   {
00113     stream << pidData.p[i];
00114     stream << pidData.i[i];
00115     stream << pidData.d[i];
00116   }
00117   return stream;
00118 }
00119 
00120 /*
00121  * Change log :
00122  * 
00123  * $Log: PIDData.cpp,v $
00124  * Revision 1.1.1.1  2004/05/22 17:25:30  cvsadm
00125  * created new repository GT2004_WM
00126  *
00127  * Revision 1.3  2003/12/31 15:29:29  roefer
00128  * Joints and LEDs for ERS-7
00129  *
00130  * Revision 1.2  2003/10/29 13:20:13  juengel
00131  * added method "setToDefaults"
00132  *
00133  * Revision 1.1  2003/10/07 10:07:01  cvsadm
00134  * Created GT2004 (M.J.)
00135  *
00136  * Revision 1.1.1.1  2003/07/02 09:40:22  cvsadm
00137  * created new repository for the competitions in Padova from the 
00138  * tamara CVS (Tuesday 2:00 pm)
00139  *
00140  * removed unused solutions
00141  *
00142  * Revision 1.5  2003/05/16 17:02:17  roefer
00143  * JAM removed
00144  *
00145  * Revision 1.4  2002/11/28 18:12:39  dueffert
00146  * default PID values changed (according to Sony recommendation)
00147  *
00148  * Revision 1.3  2002/11/26 17:17:37  risler
00149  * some comments added
00150  *
00151  * Revision 1.2  2002/11/25 15:16:34  dueffert
00152  * old logs removed
00153  *
00154  * Revision 1.1  2002/11/19 17:13:05  risler
00155  * added datatype PIDData
00156  * support for sending new pid values at runtime
00157  *
00158  */

Generated on Thu Sep 23 19:57:35 2004 for GT2004 by doxygen 1.3.6