bhspeedgen.h

00001 /***************************************************************************
00002                           bhspeedgen.h
00003                              -------------------
00004     copyright            : (c) 2004 Tim Baier
00005     email                : tbaier@informatik.uni-hamburg.de
00006  ***************************************************************************/
00007 
00008 #ifndef BHSPEEDGEN_H
00009 #define BHSPEEDGEN_H
00010 
00011 #include <iostream>
00012 #include <math.h>
00013 
00014 #include "bhspeedprofiler.h"
00015 
00016 
00017 
00018 #define PROFILE_STUCK_CURE
00019 
00020 class BHSpeedGen : public BHSpeedProfiler
00021 {
00022  
00023  public:
00024   
00025   //
00026   // turn towards a fixed angle
00027   //
00028   
00029   BHSpeedGen (const double vMax,
00030               const double aMax,
00031               const double interval,
00032               const double endPos,
00033               const bool fineTune = true);
00034   
00035 #if 0
00036   //
00037   // turn towards a fixed point. this is something different than the above
00038   // because during turning the position may change due to wheel slippage.
00039   //
00040   
00041   BHSpeedGen ( const double vRotMax,
00042                const double aRotMax,
00043                const double interval,
00044                const double xHead,
00045                const double yHead,
00046                const bool fineTune = true);
00047 #endif
00048 
00049   virtual ~BHSpeedGen (void);
00050   
00051   virtual bool step (void);
00052 
00053   void setPos(const double pos); 
00054   void setVel(const double vel);
00055   
00056   void setTarget(const double pos); 
00057   
00058   void abort();
00059   void resetAbort();
00060 
00061   double getVel();
00062 
00063  protected:
00064   
00065   // if in angle mode, use `_ae', else use `_xe'/`_ye'
00066   
00067   double EndPos;
00068 
00069   double _te;
00070   //  double _lastRotVel;
00071   //  double _lastRotPos;
00072   
00073   bool _running;
00074   bool _profileDone;
00075   bool _controllerDone;
00076   bool _abort;
00077 
00078 
00079   bool _fineTune;
00080   //  double _a1;
00081   int _fadeOut;
00082   
00083   virtual double ComputeProfile (void);
00084   virtual bool IntegrateProfile (void);
00085     
00086   double _targErrLast;
00087   double _targErrSum;
00088   double _targGain;
00089       
00090   double _p0;
00091   double Pos;
00092   double Vel;
00093 
00094   double  _rotVel;
00095   // bool _velocitiesChanged;
00096   volatile bool _motorStopped;
00097 
00098   
00099 };
00100 
00101 inline void BHSpeedGen::setPos(const double pos)
00102 {
00103   Pos = pos;
00104 }
00105 
00106 inline void BHSpeedGen::setVel(const double vel)
00107 {
00108   _rotVel = vel;
00109 }
00110 
00111 inline double BHSpeedGen::getVel()
00112 {
00113   return _rotVel;
00114 }
00115   
00116 inline void  BHSpeedGen::abort()
00117 {
00118   _abort = true;
00119 }
00120 
00121 
00122   
00123 inline void  BHSpeedGen::resetAbort()
00124 {
00125   _abort = false;
00126 }
00127 
00128 
00129 inline void  BHSpeedGen::setTarget(const double target)
00130 {
00131   EndPos = target;
00132 }
00133 
00134 
00135 #endif //BHSPEEDGEN_H


tams Tim Baier bhandlib v0.25
Generated Wed Aug 16 14:57:09 2006 by doxygen 1.4.7