• Main Page
  • Classes
  • Files
  • File List
  • File Members

qemotortraj.h

Go to the documentation of this file.
00001 //
00002 // begin license header
00003 //  
00004 // This file is part of Terk and TerkOS.
00005 //
00006 // All Terk and TerkOS source code is provided under the terms of the 
00007 // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).  
00008 // Those wishing to use Terk and TerkOS source code, software and/or
00009 // technologies under different licensing terms should contact us at 
00010 // [email protected]. Such licensing terms are available for
00011 // all portions of the Terk and TerkOS codebase presented here.
00012 //
00013 // end license header
00014 //
00015 
00016 #ifndef QEMOTORTRAJ_H
00017 #define QEMOTORTRAJ_H
00018 
00019 #include <pthread.h>
00020 #include "qemotoruser.h"
00021 #include "qemotorrec.h"
00022 
00023 #define QEM_BIT(n)                 (1<<n)
00024 #define QEM_POS_SCALE              8
00025 
00026 
00049 class CQEMotorTraj : public CQEMotorUser, public CQEMotorRec
00050 {
00051 public:
00055   SINGLETON(CQEMotorTraj);
00056 
00063   bool Done(unsigned int axis);
00064 
00070   void Stop(unsigned int axis);
00071 
00099   virtual void Move(unsigned int axis,
00100                     Axis_position endPosition, int velocity, 
00101                     unsigned int acceleration, bool absolute=false);
00114   virtual void MoveVelocity(unsigned int axis,
00115                             int velocity, unsigned int acceleration);
00116 
00117   // CQEMotorRec methods
00118   virtual void Record();
00119   virtual void Play();
00120 
00121 protected:
00122   CQEMotorTraj();
00123   ~CQEMotorTraj();
00124 
00125   // trajectory generating methods
00126   void TrapezoidTrajectory();
00127   void RecordTrajectory();
00128 
00129   // write trajectory waypoints to device
00130   void WriteTrajectory();
00131 
00132   // read positions from motors
00133   void ReadPosition();
00134 
00135   bool m_threadRun;
00136   pthread_mutex_t m_mutex;
00137   pthread_cond_t m_cond;
00138   
00139   pthread_t m_thread;
00140   unsigned char  m_operAxes;
00141   unsigned short m_trajectory;
00142   unsigned short m_velocityTrajectory;
00143 
00144   static void *TrajThread(void *arg);
00145   long long m_trajectoryEndPosition[QEMOT_NUM_MOTORS]; // enc << posScale
00146   int m_trajectoryVelocity[QEMOT_NUM_MOTORS]; // enc/period << posScale
00147   unsigned int m_trajectoryAcceleration[QEMOT_NUM_MOTORS]; // enc/period/period
00148  
00149   // Trajectory generator output   
00150   int           m_generatedTrajectoryVelocity[QEMOT_NUM_MOTORS];   
00151   int           m_generatedTrajectoryVelocityUs[QEMOT_NUM_MOTORS];   
00152   long long     m_generatedTrajectoryPosition[QEMOT_NUM_MOTORS];
00153   Axis_position m_generatedTrajectoryPositionUs[QEMOT_NUM_MOTORS]; 
00154   int           m_accIntegral[QEMOT_NUM_MOTORS]; // enc << posScale
00155   Axis_position m_readPositionUs[QEMOT_NUM_MOTORS];
00156 };
00157 
00158 #endif

Generated on Mon Oct 3 2011 15:36:31 for libqwerk by  doxygen 1.7.1