Home
FAQ
Player
Utilities
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

SegwayRMP.hh

Go to the documentation of this file.
00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: Model for a SickLMS200
00022  * Author: Andrew Howard
00023  * Date: 8 May 2003
00024  * CVS: $Id: SegwayRMP.hh,v 1.16 2004/11/16 04:47:08 inspectorg Exp $
00025  */
00026 
00027 #ifndef SEGWAYRMP_HH
00028 #define SEGWAYRMP_HH
00029 
00030 #include "Model.hh"
00031 
00032 // Forward declarations
00033 class Body;
00034 class HingeJoint;
00035 class SliderJoint;
00036 class Geom;
00037 class SphereGeom;
00038 class GeomData;
00039 
00040 typedef struct gz_position gz_position_t;
00041 
00042 
00043 class SegwayRMP : public Model
00044 {
00045   // Construct, destructor
00046   public: SegwayRMP(World *world);
00047   public: virtual ~SegwayRMP();
00048 
00049   // Load the model
00050   public: virtual int Load( WorldFile *file, WorldFileNode *node );
00051 
00052   // Initialize the model
00053   public: virtual int Init( WorldFile *file, WorldFileNode *node );
00054 
00055   // Finalize the model
00056   public: virtual int Fini();
00057 
00058   // Update the model state
00059   public: virtual void Update( double step );
00060 
00061   // Update the odometry
00062   private: void UpdateOdometry( double step );
00063 
00064   // Load ODE stuff
00065   private: int OdeLoad( WorldFile *file, WorldFileNode *node );
00066 
00067   // Initialize ODE
00068   private: int OdeInit( WorldFile *file, WorldFileNode *node );
00069 
00070   // Finalize ODE
00071   private: int OdeFini();
00072 
00073   // Initialize the external interface
00074   private: int IfaceInit();
00075 
00076   // Finalize the external interface
00077   private: int IfaceFini();
00078 
00079   // Get commands from the external interface
00080   private: void IfaceGetCmd();
00081   
00082   // Update the data in the external interface
00083   private: void IfacePutData();
00084   
00085   // Robot parameters
00086   private: double wheelSep, wheelDiam;
00087   
00088   // ODE components
00089   private: Body *base, *top, *tires[2];
00090   private: SliderJoint *topJoint;
00091   private: HingeJoint *tireJoints[2];
00092 
00093   // External interface
00094   private: gz_position_t *iface;
00095 
00096   // Wheel speeds
00097   private: double wheelSpeed[2];
00098            double desLinVel, curLinVel;
00099            double desAngVel;
00100            double maxLinVel;
00101            double maxLinAcc;
00102 
00103   // Control class
00104   private: class PID
00105   {
00106     public:
00107     PID(double Kp, double Ki, double Kd) : Kp(Kp), Ki(Ki), Kd(Kd) , e(0), de(0), ie(0) {}
00108     double Kp,Ki,Kd;
00109     double e, de, ie;
00110     double s(double e) { de = e - this->e; ie += e; this->e = e; return Kp*e + Ki*ie + Kd*de; }
00111   };
00112 
00113   // States for the segway control
00114   class ControlState
00115   {
00116     public:
00117     ControlState() : dist(0), vel(0), pitch(0), dpitch(0), yaw(0), dyaw(0) {}
00118     double dist, vel;
00119     double pitch, dpitch;
00120     double yaw, dyaw;
00121   };
00122   
00123   // Control
00124   private: PID* angVelPID;
00125            PID* linVelPID;
00126            ControlState* desState;
00127            ControlState* curState;
00128 
00129   // Odometric pose estimate
00130   private: double odomPose[3];
00131   private: double odomOrient[2];
00132 };
00133 
00134 #endif


Last updated $Date: 2004/12/21 01:49:15 $
Generated on Sun May 22 18:39:08 2005 for Gazebo by doxygen 1.4.2