sliderwheelie.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * frankguettler@gmx.de * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 * * 00023 * $Log: sliderwheelie.h,v $ 00024 * Revision 1.7 2006/12/21 11:43:05 martius 00025 * commenting style for doxygen //< -> ///< 00026 * new sensors for spherical robots 00027 * 00028 * Revision 1.6 2006/09/21 22:09:58 martius 00029 * collision for mesh 00030 * 00031 * Revision 1.5 2006/09/21 16:17:18 der 00032 * *** empty log message *** 00033 * 00034 * Revision 1.4 2006/09/21 08:15:15 martius 00035 * with sliders inside a segment 00036 * 00037 * Revision 1.3 2006/07/20 17:19:44 martius 00038 * removed using namespace std from matrix.h 00039 * 00040 * Revision 1.2 2006/07/14 12:23:42 martius 00041 * selforg becomes HEAD 00042 * 00043 * Revision 1.1.2.3 2006/06/25 21:57:20 martius 00044 * abstractrobot is configureable 00045 * name and revision 00046 * 00047 * Revision 1.1.2.2 2006/06/20 07:18:29 robot3 00048 * -added cvs log 00049 * -changed some behaviour of wheelie 00050 * 00051 * * 00052 ***************************************************************************/ 00053 #ifndef __SLIDERWHEELIE_H 00054 #define __SLIDERWHEELIE_H 00055 00056 #include<vector> 00057 #include<assert.h> 00058 00059 #include "oderobot.h" 00060 #include"primitive.h" 00061 #include "joint.h" 00062 #include "angularmotor.h" 00063 00064 #include "hingeservo.h" 00065 #include "sliderservo.h" 00066 00067 00068 namespace lpzrobots { 00069 00070 typedef struct { 00071 public: 00072 int segmNumber; ///< number of snake elements 00073 double segmLength; ///< length of one snake element 00074 double segmDia; ///< diameter of a snake element 00075 double segmMass; ///< mass of one snake element 00076 double motorPower; ///< power of the motors / servos 00077 double powerRatio; ///< ratio of motorpower for hinge vs. slider 00078 double sensorFactor; ///< scale for sensors 00079 double frictionGround; ///< friction with ground 00080 double frictionJoint; ///< friction within joint 00081 double jointLimit; ///< maximal angle for the joints (M_PI/2 = 90 degree) 00082 double sliderLength; ///< length of the slider in segmLength 00083 } SliderWheelieConf; 00084 00085 00086 /** 00087 * This is a class, which models an annular robot. 00088 * It consists of a number of equal elements, each linked 00089 * by a joint powered by 1 servo 00090 **/ 00091 class SliderWheelie : public OdeRobot 00092 { 00093 private: 00094 bool created; 00095 00096 std::vector <Primitive*> objects; 00097 std::vector <Joint*> joints; 00098 std::vector <AngularMotor*> frictionmotors; 00099 SliderWheelieConf conf; 00100 00101 std::vector <HingeServo*> hingeServos; 00102 std::vector <SliderServo*> sliderServos; 00103 00104 public: 00105 SliderWheelie(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00106 const SliderWheelieConf& conf, const std::string& name, 00107 const std::string& revision = ""); 00108 00109 virtual ~SliderWheelie(); 00110 00111 static SliderWheelieConf getDefaultConf(){ 00112 SliderWheelieConf conf; 00113 conf.segmNumber = 8; // number of snake elements 00114 conf.segmLength = 0.4; // length of one snake element 00115 conf.segmDia = 0.2; // diameter of a snake element 00116 conf.segmMass = 0.4; // mass of one snake element 00117 conf.motorPower = 0.2; // power of the servos 00118 conf.powerRatio = 2; // power of the servos 00119 conf.sensorFactor = 1; // scale for sensors 00120 conf.frictionGround = 0.8; // friction with ground 00121 conf.frictionJoint = 0.0; // friction within joint 00122 conf.jointLimit = M_PI/4; 00123 conf.sliderLength = 1; 00124 return conf; 00125 } 00126 00127 virtual void place(const osg::Matrix& pose); 00128 00129 virtual void update(); 00130 00131 void doInternalStuff(const GlobalData& global); 00132 00133 bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00134 00135 virtual void setMotors ( const motor* motors, int motornumber ); 00136 00137 virtual int getSensors ( sensor* sensors, int sensornumber ); 00138 00139 virtual int getSensorNumber() { assert(created); return hingeServos.size()+sliderServos.size(); } 00140 00141 virtual int getMotorNumber(){ assert(created); return hingeServos.size()+sliderServos.size(); } 00142 00143 virtual Primitive* getMainPrimitive() const { 00144 if(!objects.empty()){ 00145 // int half = objects.size()/2; 00146 // return (objects[half]); 00147 return (objects[0]); 00148 }else return 0; 00149 } 00150 00151 virtual paramlist getParamList() const; 00152 00153 virtual paramval getParam(const paramkey& key) const; 00154 00155 virtual bool setParam(const paramkey& key, paramval val); 00156 00157 private: 00158 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00159 00160 virtual void create(const osg::Matrix& pose); 00161 virtual void destroy(); 00162 }; 00163 00164 } 00165 00166 #endif

Generated on Tue Jan 16 02:14:38 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8