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

# nimm4.h

Go to the documentation of this file.

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