moveCommand.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00018 #ifndef __MOVE_COMMAND_H__
00019 #define __MOVE_COMMAND_H__
00020 
00021 #include <schunk_powercube_chain/datastructsManipulator.h>
00022 #include <schunk_powercube_chain/TimeStamp.h>
00023 
00024 class moveCommand
00025 {
00026 public:
00027   moveCommand() {;}
00028   virtual ~moveCommand() {;}
00029 
00031   //               Child Classes have to define these:                   //
00033 
00037   virtual double getPos(double TimeElapsed) = 0;
00038 
00042   virtual double getVel(double TimeElapsed) = 0;
00043 
00047   virtual double getTotalTime() = 0;
00048 
00050   //                Functions useful for simulation:                     //
00051   //          start() has to be called before the other functions        //
00053 
00057   virtual void start()
00058   {
00059     m_timeStarted.SetNow();
00060   }
00061 
00065   virtual bool isActive()
00066   {
00067     m_now.SetNow();
00068     return (m_now - m_timeStarted > getTotalTime()) ? false : true;
00069     std::cerr << "========Total Time: " << getTotalTime() << "\n";
00070   }
00071 
00075   virtual double pos()
00076   {
00077     m_now.SetNow();
00078     return getPos(m_now - m_timeStarted);
00079   }
00080 
00084   virtual double vel()
00085   {
00086     m_now.SetNow();
00087     return getVel(m_now - m_timeStarted);
00088   }
00089 
00093   virtual double timeRemaining()
00094   {
00095     m_now.SetNow();
00096     return (m_timeStarted - m_now) + getTotalTime();
00097   }
00098 
00099 protected:
00100   TimeStamp m_timeStarted;
00101   TimeStamp m_now;
00102 };
00103 
00104 class RampCommand : public moveCommand
00105 {
00106 public:
00107   RampCommand(double x0, double v0, double xtarget, double amax, double vmax);
00108   RampCommand(const RampCommand& rc);
00109 
00110   virtual RampCommand& operator=(const RampCommand& rc);
00111 
00112   virtual ~RampCommand()
00113   {
00114     if (m_nachumkehr)
00115       delete m_nachumkehr;
00116   }
00117 
00121   virtual double getPos(double TimeElapsed);
00122   double getPos()
00123   {
00124     return moveCommand::pos();
00125   }
00126 
00130   virtual double getVel(double TimeElapsed);
00131   double getVel()
00132   {
00133     return moveCommand::vel();
00134   }
00135 
00139   virtual double getTotalTime();
00140 
00141   virtual bool inPhase1()
00142   {
00143     m_now.SetNow();
00144     return (m_now - m_timeStarted <= m_T1) ? true : false;
00145   }
00146   virtual bool inPhase3()
00147   {
00148     m_now.SetNow();
00149     return (m_now - m_timeStarted > m_T1 + m_T2 && m_now - m_timeStarted < m_T1 + m_T2 + m_T3) ? true : false;
00150   }
00151 
00155   virtual double T1()
00156   {
00157     return (m_umkehr) ? (m_T1 + m_nachumkehr->T1()) : m_T1;
00158   }
00159   virtual double T2()
00160   {
00161     return (m_umkehr) ? m_nachumkehr->T2() : m_T2;
00162   }
00163   virtual double T3()
00164   {
00165     return (m_umkehr) ? m_nachumkehr->T3() : m_T3;
00166   }
00167 
00171   static void calculateAV(double x0, double v0, double xtarget, double time, double T3, double amax, double vmax,
00172                           double& a, double& v);
00173 
00174 private:
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


schunk_powercube_chain
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:18