Robotsystem of the Robot Group Leipzig: truckmesh.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Examples

- Search for |

- File List
- File Members

# truckmesh.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *                                                                         *
    00003  *  TruckMesh robot, an example for using Meshes for robot bodies          *
    00004  *  basic code taken from the nimm4 robot                                  *
    00005  *                                                                         *
    00006  **************************************************************************/
    00007 /***************************************************************************
    00008  *   Copyright (C) 2005 by Robot Group Leipzig                             *
    00009  *    martius@informatik.uni-leipzig.de                                    *
    00010  *    fhesse@informatik.uni-leipzig.de                                     *
    00011  *    der@informatik.uni-leipzig.de                                        *
    00012  *    frankguettler@gmx.de                                                 *
    00013  *                                                                         *
    00014  *   This program is free software; you can redistribute it and/or modify  *
    00015  *   it under the terms of the GNU General Public License as published by  *
    00016  *   the Free Software Foundation; either version 2 of the License, or     *
    00017  *   (at your option) any later version.                                   *
    00018  *                                                                         *
    00019  *   This program is distributed in the hope that it will be useful,       *
    00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00022  *   GNU General Public License for more details.                          *
    00023  *                                                                         *
    00024  *   You should have received a copy of the GNU General Public License     *
    00025  *   along with this program; if not, write to the                         *
    00026  *   Free Software Foundation, Inc.,                                       *
    00027  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00028  *                                                                         *
    00029  *   $Log: truckmesh.h,v $
    00030  *   Revision 1.2  2006/07/14 12:23:42  martius
    00031  *   selforg becomes HEAD
    00032  *
    00033  *   Revision 1.1.2.3  2006/07/06 12:33:31  robot3
    00034  *   -mass of the truck can be set by the constructor now
    00035  *   -code cleaned up
    00036  *   -all 6 wheels have now contact to the ground (instead of only 4)
    00037  *
    00038  *   Revision 1.1.2.2  2006/06/29 16:36:46  robot3
    00039  *   -controller now gets 6 wheels for control
    00040  *   -wheels are on the right position now
    00041  *
    00042  *   Revision 1.1.2.1  2006/06/27 15:19:52  robot3
    00043  *   truckmesh uses a mesh for the body of the robot
    00044  *
    00045  *   Revision 1.5.4.13  2006/06/25 16:57:14  martius
    00046  *   abstractrobot is configureable
    00047  *   name and revision
    00048  *
    00049  *   Revision 1.5.4.12  2006/04/04 14:13:24  fhesse
    00050  *   documentation improved
    00051  *
    00052  *   Revision 1.5.4.11  2006/03/31 16:20:28  fhesse
    00053  *   class Joint; changed to: class Hinge2Joint;
    00054  *
    00055  *   Revision 1.5.4.10  2006/03/30 12:34:56  martius
    00056  *   documentation updated
    00057  *
    00058  *   Revision 1.5.4.9  2005/12/15 17:04:08  martius
    00059  *   Primitives are not longer inherited from OSGPrimitive, moreover
    00060  *   they aggregate them.
    00061  *   Joint have better getter and setter
    00062  *
    00063  *   Revision 1.5.4.8  2005/12/14 15:37:09  martius
    00064  *   robots are working with osg
    00065  *
    00066  *   Revision 1.5.4.7  2005/12/13 18:11:40  martius
    00067  *   still trying to port robots
    00068  *
    00069  *   Revision 1.5.4.6  2005/12/12 23:41:19  martius
    00070  *   added Joint wrapper
    00071  *
    00072  *   Revision 1.5.4.5  2005/12/11 23:35:08  martius
    00073  *   *** empty log message ***
    00074  *
    00075  *   Revision 1.5.4.4  2005/12/06 10:13:25  martius
    00076  *   openscenegraph integration started
    00077  *
    00078  *   Revision 1.5.4.3  2005/11/16 11:26:52  martius
    00079  *   moved to selforg
    00080  *
    00081  *   Revision 1.5.4.2  2005/11/15 12:29:26  martius
    00082  *   new selforg structure and OdeAgent, OdeRobot ...
    00083  *
    00084  *   Revision 1.5.4.1  2005/11/14 17:37:18  martius
    00085  *   moved to selforg
    00086  *
    00087  *   Revision 1.5  2005/10/27 16:10:41  fhesse
    00088  *   nimm4 as example
    00089  *
    00090  *   Revision 1.4  2005/09/22 12:24:37  martius
    00091  *   removed global variables
    00092  *   OdeHandle and GlobalData are used instead
    00093  *   sensor prepared
    00094  *
    00095  *   Revision 1.3  2005/08/31 11:14:06  martius
    00096  *   removed unused vars
    00097  *
    00098  *   Revision 1.2  2005/08/03 20:38:56  martius
    00099  *   added textures and correct placement
    00100  *
    00101  *   Revision 1.1  2005/07/29 15:13:11  martius
    00102  *   a robot with 4 independent wheels
    00103  *
    00104  *                                                                 *
    00105  ***************************************************************************/
    00106 #ifndef __TRUCKMESH_H
    00107 #define __TRUCKMESH_H
    00108
    00109 #include "oderobot.h"
    00110
    00111 namespace lpzrobots {
    00112
    00113   class Primitive;
    00114   class Hinge2Joint;
    00115
    00116   /** Robot that looks like a Nimm 2 Bonbon :-)
    00117       4 wheels and a truck mesh like body
    00118   */
    00119   class TruckMesh : public OdeRobot{
    00120   public:
    00121
    00122     /**
    00123      * constructor of TruckMesh robot
    00124      * @param odeHandle data structure for accessing ODE
    00125      * @param osgHandle ata structure for accessing OSG
    00126      * @param size scaling of robot
    00127      * @param force maximal used force to realize motorcommand
    00128      * @param speed factor for changing speed of robot
    00129      */
    00130     TruckMesh(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const std::string& name,
    00131               GlobalData& global, double size=1, double force=3, double speed=15, double mass=1);
    00132
    00133
    00134    virtual ~TruckMesh(){};
    00135
    00136     /**
    00137      * updates the OSG nodes of the vehicle
    00138      */
    00139     virtual void update();
    00140
    00141
    00142     /** sets the pose of the vehicle
    00143         @param pose desired pose matrix
    00144     */
    00145     virtual void place(const osg::Matrix& pose);
    00146
    00147     /** returns actual sensorvalues
    00148         @param sensors sensors scaled to [-1,1]
    00149         @param sensornumber length of the sensor array
    00150         @return number of actually written sensors
    00151     */
    00152     virtual int getSensors(sensor* sensors, int sensornumber);
    00153
    00154     /** sets actual motorcommands
    00155         @param motors motors scaled to [-1,1]
    00156         @param motornumber length of the motor array
    00157     */
    00158     virtual void setMotors(const motor* motors, int motornumber);
    00159
    00160     /** returns number of sensors
    00161      */
    00162     virtual int getSensorNumber(){
    00163       return sensorno;
    00164     };
    00165
    00166     /** returns number of motors
    00167      */
    00168     virtual int getMotorNumber(){
    00169       return motorno;
    00170     };
    00171
    00172     /** checks for internal collisions and treats them.
    00173      *  In case of a treatment return true (collision will be ignored by other objects
    00174      *  and the default routine)  else false (collision is passed to other objects and
    00175      *  (if not treated) to the default routine).
    00176      */
    00177     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
    00178
    00179     /** this function is called in each timestep. It should perform robot-internal checks,
    00180         like space-internal collision detection, sensor resets/update etc.
    00181         @param globalData structure that contains global data from the simulation environment
    00182     */
    00183     virtual void doInternalStuff(const GlobalData& globalData);
    00184
    00185
    00186   protected:
    00187     /** the main object of the robot, which is used for position and speed tracking */
    00188     virtual Primitive* getMainPrimitive() const { return object[0]; }
    00189
    00190     /** creates vehicle at desired pose
    00191         @param pose 4x4 pose matrix
    00192     */
    00193     virtual void create(const osg::Matrix& pose);
    00194
    00195     /** destroys vehicle and space
    00196      */
    00197     virtual void destroy();
    00198
    00199     /** additional things for collision handling can be done here
    00200      */
    00201     static void mycallback(void *data, dGeomID o1, dGeomID o2);
    00202
    00203     double length;     // chassis length
    00204     double width;      // chassis width
    00205     double middlewidth; // chassis middle position of width
    00206     double middlelength; // chassis middle position of length
    00207     double height;     // chassis height
    00208     double radius;     // wheel radius
    00209     double wheelthickness; // thickness of the wheels
    00210     double cmass;      // chassis mass
    00211     double wmass;      // wheel mass
    00212     int sensorno;      // number of sensors
    00213     int motorno;       // number of motors
    00214     int segmentsno;    // number of motorsvehicle segments
    00215     double speed;      // factor for adjusting speed of robot
    00216
    00217     bool drawBoundings; // if bounding shapes of the body are drawed
    00218     double max_force;  // maximal force for motors
    00219
    00220     bool created;      // true if robot was created
    00221
    00222     Primitive* object[7];  // 1 mesh, 6 wheels
    00223     Hinge2Joint* joint[6]; // joints between mesh and each wheel
    00224
    00225     GlobalData global;
    00226
    00227   };
    00228
    00229 }
    00230
    00231 #endif