00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #ifndef __MOVE_COMMAND_H__
00055 #define __MOVE_COMMAND_H__
00056
00057 #include <cob_powercube_chain/datastructsManipulator.h>
00058 #include <cob_powercube_chain/TimeStamp.h>
00059
00060 class moveCommand
00061 {
00062 public:
00063 moveCommand() {;}
00064 virtual ~moveCommand() {;}
00065
00067
00069
00071 virtual double getPos(double TimeElapsed)=0;
00072
00074 virtual double getVel(double TimeElapsed)=0;
00075
00077 virtual double getTotalTime()=0;
00078
00080
00081
00083
00085 virtual void start() { m_timeStarted.SetNow(); }
00086
00088 virtual bool isActive() { m_now.SetNow(); return ( m_now-m_timeStarted > getTotalTime() )?false:true; std::cerr << "========Total Time: " << getTotalTime() << "\n";}
00089
00091 virtual double pos() { m_now.SetNow(); return getPos( m_now-m_timeStarted ); }
00092
00094 virtual double vel() { m_now.SetNow(); return getVel( m_now-m_timeStarted ); }
00095
00097 virtual double timeRemaining() { m_now.SetNow(); return (m_timeStarted - m_now) + getTotalTime(); }
00098
00099 protected:
00100 TimeStamp m_timeStarted;
00101 TimeStamp m_now;
00102 };
00103
00104
00105
00106 class RampCommand : public moveCommand
00107 {
00108 public:
00109 RampCommand(double x0, double v0, double xtarget, double amax, double vmax);
00110 RampCommand(const RampCommand& rc);
00111
00112 virtual RampCommand& operator=(const RampCommand& rc);
00113
00114 virtual ~RampCommand() { if (m_nachumkehr) delete m_nachumkehr; }
00115
00117 virtual double getPos(double TimeElapsed);
00118 double getPos() { return moveCommand::pos(); }
00119
00121 virtual double getVel(double TimeElapsed);
00122 double getVel() { return moveCommand::vel(); }
00123
00125 virtual double getTotalTime();
00126
00127 virtual bool inPhase1() { m_now.SetNow(); return ( m_now-m_timeStarted <= m_T1 )?true:false; }
00128
00129 virtual bool inPhase3()
00130 { m_now.SetNow(); return ( m_now-m_timeStarted > m_T1 + m_T2 && m_now-m_timeStarted < m_T1 + m_T2 + m_T3)?true:false; }
00131
00133 virtual double T1() { return (m_umkehr)?(m_T1 + m_nachumkehr->T1()):m_T1; }
00134 virtual double T2() { return (m_umkehr)?m_nachumkehr->T2():m_T2; }
00135 virtual double T3() { return (m_umkehr)?m_nachumkehr->T3():m_T3; }
00136
00138 static void calculateAV(double x0, double v0, double xtarget, double time, double T3, double amax, double vmax, double& a, double& v);
00139
00140 private:
00141
00142 static std::ofstream debug;
00143
00144 double m_x0, m_v0;
00145 double m_xtarget;
00146 double m_amax, m_vmax;
00147
00148 double m_T1, m_T2, m_T3;
00149 double m_a1, m_v2, m_a3;
00150 bool m_umkehr;
00151 RampCommand * m_nachumkehr;
00152 };
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00166
00167
00169
00170
00172
00173
00175
00176
00177
00178
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 #endif