Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

UPennWalkMC.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_UPennWalkMC_h_
00003 #define INCLUDED_UPennWalkMC_h_
00004 
00005 #include "Motion/MotionCommand.h"
00006 #include "Motion/MotionManager.h"
00007 
00008 //! Uses the UPennalizers' 2004 RoboCup code to compute walking gaits
00009 
00010 /*! This class is ported from University of Pennsylvania's 2004 Robosoccer entry, and falls under their license:
00011     =========================================================================
00012     This software is distributed under the GNU General Public License,
00013     version 2.  If you do not have a copy of this licence, visit
00014     www.gnu.org, or write: Free Software Foundation, 59 Temple Place,
00015     Suite 330 Boston, MA 02111-1307 USA.  This program is distributed
00016     in the hope that it will be useful, but WITHOUT ANY WARRANTY,
00017     including MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018     ========================================================================= */
00019 
00020 class UPennWalkMC : public MotionCommand {
00021 public:
00022   //! constructor
00023   UPennWalkMC();
00024 
00025   virtual int updateOutputs() {
00026     /*if(sqrt(xVel*xVel+yVel*yVel+aVel*aVel)<.01)
00027       StandLegs(xVel,yVel,aVel);
00028       else */
00029     WalkLegs(xVel,yVel,aVel);
00030     return NumLegJoints;
00031   }
00032 
00033   virtual int isDirty() { return true; }
00034   virtual int isAlive() { return true; }
00035 
00036   void setTargetVelocity(float x, float y, float a) { xVel=-y; yVel=x; aVel=a; }
00037 
00038 protected:
00039   void SetLegJoints(double * x);
00040 
00041   inline static double clip(double x, double min=-1.0, double max=1.0)
00042   {
00043     if (x < min) return min;
00044     if (x > max) return max;
00045     return x;
00046   }
00047 
00048   void SetStanceParameters(double bodyTilt, double shoulderHeight,
00049                            double foreX0, double foreY0,
00050                            double hindX0, double hindY0);
00051   
00052   void SetWalkSpeeds(int quarterPeriod, double maxDistance,
00053                      double foreLiftInitial, double foreLiftFinal,
00054                      double hindLiftInitial, double hindLiftFinal);
00055   
00056   void SetWalkWorkspace(double foreXMin, double foreXMax,
00057                         double foreYMin, double foreYMax,
00058                         double hindXMin, double hindXMax,
00059                         double hindYMin, double hindYMax);
00060   
00061   //! Calculate 12 leg joint angles from leg positions
00062   /*! Note positions are relative to stance parameters
00063    *  so all zero inputs -> stance angles */
00064   void LegPositionsToAngles(double *a);
00065 
00066   void StandLegs(double x=0, double y=0, double z=0);
00067 
00068   int  GetWalkPhase();
00069 
00070   void SetWalkPhase(int phase);
00071 
00072   void WalkLegs(double xWalk=0.0, double yWalk=0.0, double aWalk=0.0);
00073 
00074   float xVel;
00075   float yVel;
00076   float aVel;
00077 
00078   double body_tilt, shoulder_height;
00079   double fore_x0, fore_y0;
00080   double hind_x0, hind_y0;
00081 
00082   int walk_phase, walk_phase_direction, walk_quarter_period;
00083   double walk_max_distance;
00084   double walk_fore_lift_initial, walk_fore_lift_final;
00085   double walk_hind_lift_initial, walk_hind_lift_final;
00086   double walk_current_x[NumLegs], walk_current_y[NumLegs];
00087   double walk_fore_xmin, walk_fore_xmax, walk_fore_ymin, walk_fore_ymax;
00088   double walk_hind_xmin, walk_hind_xmax, walk_hind_ymin, walk_hind_ymax;
00089 
00090 };
00091 
00092 /*! @file
00093  * @brief Defines UPennWalkMC, which uses the UPennalizers' 2004 RoboCup code to compute walking gaits
00094  * @author UPennalizers 2004 (Creator)
00095  * @author ejt (Ported)
00096  *
00097  * The UPennalizers code was released under the GPL:\n
00098  *  ------------------------------------------------------------------------- \n
00099  *    This software is distributed under the GNU General Public License,      \n
00100  *    version 2.  If you do not have a copy of this licence, visit            \n
00101  *    www.gnu.org, or write: Free Software Foundation, 59 Temple Place,       \n
00102  *    Suite 330 Boston, MA 02111-1307 USA.  This program is distributed       \n
00103  *    in the hope that it will be useful, but WITHOUT ANY WARRANTY,           \n
00104  *    including MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.          \n
00105  *  ------------------------------------------------------------------------- \n
00106  */
00107 
00108 #endif
00109 

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:52 2016 by Doxygen 1.6.3