00001 /*************************************************************************** 00002 * Copyright (C) 2005-2011 LpzRobots development team * 00003 * Georg Martius <georg dot martius at web dot de> * 00004 * Frank Guettler <guettler at informatik dot uni-leipzig dot de * 00005 * Frank Hesse <frank at nld dot ds dot mpg dot de> * 00006 * Ralf Der <ralfder at mis dot mpg dot 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 ***************************************************************************/ 00024 #ifndef __FORMEL1_H 00025 #define __FORMEL1_H 00026 00027 #include "oderobot.h" 00028 00029 namespace lpzrobots { 00030 00031 class Primitive; 00032 class Joint; 00033 00034 /** Robot that looks like a Nimm 2 Bonbon :-) 00035 4 wheels and a capsule like body 00036 */ 00037 class Formel1 : public OdeRobot{ 00038 public: 00039 00040 Formel1(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00041 double size=1, double force=3, double speed=15, bool sphereWheels=true); 00042 00043 virtual ~Formel1(){}; 00044 00045 /** 00046 * updates the OSG nodes of the vehicle 00047 */ 00048 virtual void update(); 00049 00050 00051 /** sets the pose of the vehicle 00052 @param pose desired pose matrix 00053 */ 00054 virtual void place(const osg::Matrix& pose); 00055 00056 /** returns actual sensorvalues 00057 @param sensors sensors scaled to [-1,1] 00058 @param sensornumber length of the sensor array 00059 @return number of actually written sensors 00060 */ 00061 virtual int getSensors(sensor* sensors, int sensornumber); 00062 00063 /** sets actual motorcommands 00064 @param motors motors scaled to [-1,1] 00065 @param motornumber length of the motor array 00066 */ 00067 virtual void setMotors(const motor* motors, int motornumber); 00068 00069 /** returns number of sensors 00070 */ 00071 virtual int getSensorNumber(){ 00072 return sensorno; 00073 }; 00074 00075 /** returns number of motors 00076 */ 00077 virtual int getMotorNumber(){ 00078 return motorno; 00079 }; 00080 00081 /** this function is called in each timestep. It should perform robot-internal checks, 00082 like space-internal collision detection, sensor resets/update etc. 00083 @param globalData structure that contains global data from the simulation environment 00084 */ 00085 virtual void doInternalStuff(GlobalData& globalData); 00086 00087 00088 protected: 00089 /** the main object of the robot, which is used for position and speed tracking */ 00090 virtual Primitive* getMainPrimitive() const { return object[0]; } 00091 00092 /** creates vehicle at desired pose 00093 @param pose 4x4 pose matrix 00094 */ 00095 virtual void create(const osg::Matrix& pose); 00096 00097 /** destroys vehicle and space 00098 */ 00099 virtual void destroy(); 00100 00101 /** additional things for collision handling can be done here 00102 */ 00103 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00104 00105 double length; // chassis length 00106 double width; // chassis width 00107 double height; // chassis height 00108 double radius; // wheel radius 00109 double wheelthickness; // thickness of the wheels 00110 bool sphereWheels; // draw spherical wheels? 00111 double cmass; // chassis mass 00112 double wmass; // wheel mass 00113 int sensorno; //number of sensors 00114 int motorno; // number of motors 00115 int segmentsno; // number of motorsvehicle segments 00116 double speed; // 00117 00118 double max_force; // maximal force for motors 00119 00120 bool created; // true if robot was created 00121 00122 Primitive* object[5]; // 1 capsule, 4 wheels 00123 Hinge2Joint* joint[4]; // joints between cylinder and each wheel 00124 00125 }; 00126 00127 } 00128 00129 00130 #endif