Robot Simulator of the Robotics Group for Self-Organization of Control: truckmesh.h Source File

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