Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

local_vector_driver.h

Go to the documentation of this file.
00001 /*
00002 Object Oriented Mobile Robot Model (OOMRM) C++  Library Copyright (C) 2002-2005  Derek Jones
00003 
00004 This library is free software; you can redistribute it  and/or
00005 modify it under the terms of the GNU Lesser General Public
00006 License  as published by the Free Software Foundation; either
00007 version 2.1 of the  License, or (at your option) any later version.
00008 
00009 This library is  distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY;  without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A  PARTICULAR PURPOSE.  See the GNU
00012 Lesser General Public License for more  details.
00013 
00014 You should have received a copy of the GNU Lesser General  Public
00015 License along with this library; if not, write to the Free  Software
00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   02111-1307  USA
00017 
00018 
00019  * $Id: local_vector_driver.h,v 1.2 2007/09/26 05:12:59 derek Exp $
00020 */
00021 
00022 #ifndef GEOMETRY_DRIVER_H
00023 #define GEOMETRY_DRIVER_H
00024 #include <sine.h>
00025 #include <primitive_driver.h>
00026 #include <point.h>
00027 #include <opid.h>
00029 
00050 class Geometry_Driver : public Primitive_Driver
00051 {
00052 public:
00053   friend void task_local_vector_driver(void*);
00054 //  friend void task_keep_straight(void);
00055 //  friend void task_motion_driver(void);
00057 
00070   Geometry_Driver(IOLINE Pencoder, IOLINE Sencoder, IOLINE f,PORT ,IOLINE tpu,
00071                 IOLINE Pencoder,IOLINE Sencoder, IOLINE rf,PORT rfp, IOLINE rtpu,  uint8 subclass=0); //, MILLIMETER b);
00073   /*
00074   Two ways of travel:
00075     - portion of a circular arc: the radius is set to center of circle forming path robot will travel.
00076     - straight distance: the radius parameter is set to distance to travel. (radians ignored).
00077   \param idir (MOTION) direction of travel
00078   \param s (SPEED) speed of travel (mm/sec)
00079   \param radius (MILLIMETER)    -       radius of turn. Only applicable for turn right/left. (turn is made around this point--0 degree is pivot; infinite is straight line).
00080   \param idirection (DEGREE)  - current direction of travel.
00081   \param c RADIAN amount to arc (0=none PI/2= 90 degree 2*PI=full circle etc.)
00082   */
00083 //  void        travel(MOTION idir,ENCODER_TYPE s, ENCODER_TYPE radius, FIXED_RADIAN idirection, FIXED_RADIAN c=FIXED_PIDIV2); // 1.570796);
00084   void  travel(MOTION idir,ENCODER_TYPE s, ENCODER_TYPE radius, FIXED_RADIAN idirection, FIXED_RADIAN c); //=FIXED_PIDIV2); // 1.570796);
00086   void travel(MOTION idir,ENCODER_TYPE EU_s, const point& P2, FIXED_RADIAN Fidirection);
00088   void travel(MOTION idir,ENCODER_TYPE EU_s, MILLIMETER idistance);
00090   void travel(MOTION idir);
00092   void travel(MOTION idir, SPEED speed, const point& P1, const point& P2, int weight);
00094 
00097   void heading(ENCODER_TYPE s, FIXED_RADIAN destination);
00099 
00100   void keep_straight(void);
00102   int offset(void);
00104   DEGREE face(void);
00105 //  void segment_path(int& dx, int& dy, oPID& pid, bool& lpower, bool& rpower);
00106   // Control function to maintain a circular path.
00107 //  void circular_path(int&, int&,oPID&,bool&,bool&);
00109   void linear_path(int&, int&,oPID&,bool&,bool&);
00111   bool complete();
00113   void control_points(const point& p1, const point& p2);
00115   #ifdef DOS
00116   // The static allows the simulator to read all values from shared memory.
00117   static MILLIMETER distance(void);
00118   static MILLIMETER get_actual_speed(void);
00119   static MILLIMETER x0();
00120   static MILLIMETER y0();
00121   static MILLIMETER current_distance();
00122   static RADIAN get_stop(void);
00123   static MILLIMETER get_global_speed(void);
00124   // application must manually call the WSwrite to update values into shared memory.
00125   void WSwrite(void);
00126   int Label;
00127 protected:
00128   ENCODER_TYPE   EU_distance;           // distance from initial position to destination (waypoint).
00129   #endif
00130   FIXED_RADIAN        F_STOP;           // angle to stop at while turning.
00131   bool          _complete;              // Has the commmand been completed. (moved to state_flags)
00132   ENCODER_TYPE  EU_global_speed;
00133   MILLIMETER    MM_current_distance;
00134   point         _p1;            // control point.
00135   point         _p2;            // destination point.
00136   float         _weight;                // weight (larger value tracks closer to control point).
00137   FIXED_METER   FM_offset;  // how much off from line.
00138   ENCODER_TYPE  EU_centerx; // center of turn for left/right turns.
00139   ENCODER_TYPE  EU_centery;
00140   ENCODER_TYPE    EU_distance2go;
00141   Geometry_Driver(void);
00142   FIXED_RADIAN          F_Tradian;
00143   ENCODER_TYPE          EU_x0;  // defines a starting location x,y coordinates (P0)
00144   ENCODER_TYPE          EU_y0;
00145   static foo2 callback(void);
00146 private:
00147   void prestuff(ENCODER_TYPE EU_S);
00148   void poststuff(MOTION idir, ENCODER_TYPE EU_left, ENCODER_TYPE EU_right);
00149 };
00151 typedef Geometry_Driver Local_Vector_Driver;
00152 #endif

Generated on Mon Oct 8 19:32:19 2007 for OOMRM Mapping API by doxygen1.3