moveCommand.h
Go to the documentation of this file.
00001 
00060 #ifndef __MOVE_COMMAND_H__
00061 #define __MOVE_COMMAND_H__
00062 
00063 #include <schunk_powercube_chain/datastructsManipulator.h>
00064 #include <schunk_powercube_chain/TimeStamp.h>
00065 
00066 class moveCommand
00067 {
00068 public:
00069         moveCommand() {;}
00070         virtual ~moveCommand() {;}
00071 
00073         //               Child Classes have to define these:                   //
00075 
00079         virtual double getPos(double TimeElapsed)=0;
00080 
00084         virtual double getVel(double TimeElapsed)=0;
00085 
00089         virtual double getTotalTime()=0;
00090 
00092         //                Functions useful for simulation:                     //
00093         //          start() has to be called before the other functions        //
00095 
00099         virtual void start() { m_timeStarted.SetNow(); }
00100 
00104         virtual bool isActive() { m_now.SetNow(); return ( m_now-m_timeStarted > getTotalTime() )?false:true;
00105                                                           std::cerr << "========Total Time: " << getTotalTime() << "\n";}
00106 
00110         virtual double pos() { m_now.SetNow(); return getPos( m_now-m_timeStarted ); }
00111 
00115         virtual double vel() { m_now.SetNow(); return getVel( m_now-m_timeStarted ); }
00116 
00120         virtual double timeRemaining() { m_now.SetNow(); return (m_timeStarted - m_now) + getTotalTime(); }
00121 
00122 protected:
00123         TimeStamp m_timeStarted;
00124         TimeStamp m_now;
00125 };
00126 
00127 
00128 
00129 class RampCommand : public moveCommand
00130 {
00131 public:
00132         RampCommand(double x0, double v0, double xtarget, double amax, double vmax);
00133         RampCommand(const RampCommand& rc);
00134 
00135         virtual RampCommand& operator=(const RampCommand& rc);
00136 
00137         virtual ~RampCommand() { if (m_nachumkehr) delete m_nachumkehr; }
00138 
00142         virtual double getPos(double TimeElapsed);
00143         double getPos() { return moveCommand::pos(); }
00144 
00148         virtual double getVel(double TimeElapsed);
00149         double getVel() { return moveCommand::vel(); }
00150 
00154         virtual double getTotalTime();
00155 
00156         virtual bool inPhase1() { m_now.SetNow(); return ( m_now-m_timeStarted <= m_T1 )?true:false; }
00157         virtual bool inPhase3()
00158         { m_now.SetNow(); return ( m_now-m_timeStarted > m_T1 + m_T2 && m_now-m_timeStarted < m_T1 + m_T2 + m_T3)?true:false; }
00159 
00163         virtual double T1() { return (m_umkehr)?(m_T1 + m_nachumkehr->T1()):m_T1; }
00164         virtual double T2() { return (m_umkehr)?m_nachumkehr->T2():m_T2; }
00165         virtual double T3() { return (m_umkehr)?m_nachumkehr->T3():m_T3; }
00166 
00170         static void calculateAV(double x0, double v0, double xtarget, double time, double T3, double amax,
00171                                                     double vmax, double& a, double& v);
00172 
00173 private:
00174 
00175         static std::ofstream debug;
00176 
00177         double m_x0, m_v0;
00178         double m_xtarget;
00179         double m_amax, m_vmax;
00180 
00181         double m_T1, m_T2, m_T3;
00182         double m_a1, m_v2, m_a3;
00183         bool m_umkehr;
00184         RampCommand * m_nachumkehr;
00185 };
00186 
00187 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


schunk_powercube_chain
Author(s): Florian Weisshardt
autogenerated on Tue Mar 5 2013 14:44:46