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

Modules/MotionControl/MotionStabilizer.cpp

Go to the documentation of this file.
00001 /**
00002 * @file MotionStabilizer.cpp
00003 * 
00004 * Implementation of class MotionStabilizer
00005 *
00006 * @author Jan Hoffmann
00007 */
00008 
00009 #include "MotionStabilizer.h"
00010 
00011 MotionStabilizer::MotionStabilizer() : 
00012 accelX (0, 0.05, 0, 0, -20, 20, 500000),
00013 accelY (0, 0.05, 0, 0, -20, 20, 500000),
00014 accelZ (-9.81, 0.05, 0, 0, -20, 20, 500000),
00015 xFore (1, .9, 0, 0, .2, 10, 500000),
00016 xHind (1, .9, 0, 0, .2, 10, 500000),
00017 yLeft (1, .9, 0, 0, .2, 10, 500000),
00018 yRight (1, .9, 0, 0, .2, 10, 500000),
00019 stabilizerScale(5.0)
00020 {
00021 }
00022 
00023 bool MotionStabilizer::stabilize(
00024                                  MotionRequest::MotionID lastMotionType,
00025                                  const MotionRequest& motionRequest, 
00026                                  JointData& jointData, 
00027                                  OdometryData& odometryData,
00028                                  const SensorDataBuffer& sensorDataBuffer)
00029 {
00030   if(lastMotionType != MotionRequest::walk) return false;   
00031   if (!motionRequest.stabilize) return 0;
00032 
00033   for (int frame = 0; frame < sensorDataBuffer.numOfFrames; frame++) 
00034   {    
00035     accelX.approximateVal(sensorDataBuffer.frame[frame].data[SensorData::accelerationX]/1000000.0); 
00036     accelY.approximateVal(sensorDataBuffer.frame[frame].data[SensorData::accelerationY]/1000000.0); 
00037     accelZ.approximateVal(sensorDataBuffer.frame[frame].data[SensorData::accelerationZ]/1000000.0); 
00038   }
00039  
00040     
00041   xFore.approximateVal(1-(accelX.getVal() - 2)/stabilizerScale);
00042   xHind.approximateVal(1+(accelX.getVal() - 2)/stabilizerScale);
00043 
00044   yLeft.approximateVal(1-(accelY.getVal())/stabilizerScale);
00045   yRight.approximateVal(1+(accelY.getVal())/stabilizerScale);
00046 
00047 
00048   /* fore legs */
00049   jointData.data[JointData::legFR1]  = (long )((double )jointData.data[JointData::legFR1] * yRight.getVal() * xFore.getVal());
00050   jointData.data[JointData::legFR2] *= 1;
00051   jointData.data[JointData::legFR3]  = (long )((double )jointData.data[JointData::legFR3] * yRight.getVal() * xFore.getVal());
00052 
00053   jointData.data[JointData::legFL1]  = (long )((double )jointData.data[JointData::legFL1] * yLeft.getVal() * xFore.getVal());
00054   jointData.data[JointData::legFL2] *= 1;
00055   jointData.data[JointData::legFL3]  = (long )((double )jointData.data[JointData::legFL3] * yLeft.getVal() * xFore.getVal());
00056 
00057   /* hind legs */
00058   jointData.data[JointData::legHR1]  = (long )((double )jointData.data[JointData::legHR1] * yRight.getVal() * xHind.getVal());
00059   jointData.data[JointData::legHR2] *= 1;
00060   jointData.data[JointData::legHR3]  = (long )((double )jointData.data[JointData::legHR3] * yRight.getVal() * xHind.getVal());
00061 
00062   jointData.data[JointData::legHL1]  = (long )((double )jointData.data[JointData::legHL1] * yLeft.getVal() * xHind.getVal());
00063   jointData.data[JointData::legHL2] *= 1;
00064   jointData.data[JointData::legHL3]  = (long )((double )jointData.data[JointData::legHL3] * yLeft.getVal() * xHind.getVal());
00065 
00066   return true;
00067 }
00068 
00069 
00070 /*
00071  * Change log :
00072  * 
00073  * $Log: MotionStabilizer.cpp,v $
00074  * Revision 1.1.1.1  2004/05/22 17:20:37  cvsadm
00075  * created new repository GT2004_WM
00076  *
00077  * Revision 1.1  2003/10/06 14:10:13  cvsadm
00078  * Created GT2004 (M.J.)
00079  *
00080  * Revision 1.1.1.1  2003/07/02 09:40:24  cvsadm
00081  * created new repository for the competitions in Padova from the 
00082  * tamara CVS (Tuesday 2:00 pm)
00083  *
00084  * removed unused solutions
00085  *
00086  * Revision 1.10  2003/06/13 17:05:43  jhoffman
00087  * largely simplified code
00088  *
00089  * Revision 1.9  2003/05/23 13:08:26  goehring
00090  * Number of Sensorvalues changed from 4 to numOfValues (BETA)
00091  *
00092  * Revision 1.8  2003/05/23 11:30:12  goehring
00093  * MotionStabilizer signature changed
00094  *
00095  * Revision 1.7  2003/05/23 09:36:51  goehring
00096  * MotionStabilizer gets all 4 Sensor Values
00097  *
00098  * Revision 1.6  2003/02/17 10:57:33  dueffert
00099  * warnings removed
00100  *
00101  * Revision 1.5  2002/12/13 09:53:50  jhoffman
00102  * works a lot better now, cleaning up still needs to be done
00103  *
00104  * Revision 1.4  2002/11/19 17:38:31  dueffert
00105  * doxygen bugs corrected
00106  *
00107  * Revision 1.3  2002/11/19 15:43:03  dueffert
00108  * doxygen comments corrected
00109  *
00110  * Revision 1.2  2002/09/22 18:40:53  risler
00111  * added new math functions, removed GTMath library
00112  *
00113  * Revision 1.1  2002/09/10 15:36:15  cvsadm
00114  * Created new project GT2003 (M.L.)
00115  * - Cleaned up the /Src/DataTypes directory
00116  * - Removed challenge related source code
00117  * - Removed processing of incoming audio data
00118  * - Renamed AcousticMessage to SoundRequest
00119  *
00120  * Revision 1.1.1.1  2002/05/10 12:40:15  cvsadm
00121  * Moved GT2002 Project from ute to tamara.
00122  *
00123  * Revision 1.5  2002/04/25 14:50:36  kallnik
00124  * changed double/float to double
00125  * added several #include GTMath
00126  *
00127  * PLEASE use double
00128  *
00129  * Revision 1.4  2002/04/23 15:08:44  risler
00130  * changed MotionRequest: walk instead of normalWalk,... and walkType added
00131  *
00132  * Revision 1.3  2002/04/23 15:00:06  jhoffman
00133  * changes and additions
00134  *
00135  * Revision 1.2  2002/04/05 14:08:56  jhoffman
00136  * stabilizer stuff
00137  *
00138  * Revision 1.1  2002/04/04 15:24:09  jhoffman
00139  * added motion stabilizer to motion control
00140  *
00141  *
00142  *
00143  */

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