Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
caterpillar.h
Go to the documentation of this file.
1 /**************************************************************************/
2 /*schlangeservo.h */
3 /*Snake with PID Servo motors (just motor per joint) */
4 /*@author Georg Martius */
5 /* */
6 /**************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2005-2011 LpzRobots development team *
9  * Georg Martius <georg dot martius at web dot de> *
10  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
11  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
12  * Ralf Der <ralfder at mis dot mpg dot de> *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the *
26  * Free Software Foundation, Inc., *
27  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28  * *
29  ***************************************************************************/
30 #ifndef __CATERPILLAR_H
31 #define __CATERPILLAR_H
32 
33 #include "defaultCaterpillar.h"
34 #include "twoaxisservo.h"
35 #include "oneaxisservo.h"
36 
37 namespace lpzrobots {
38 
39  /**
40  * This is a class, which models a snake like robot.
41  * It consists of a number of equal elements, each linked
42  * by a joint powered by 2 servos
43  **/
45  {
46  private:
47  std::vector <UniversalServo*> universalServos;
48  std::vector <SliderServo*> sliderServos;
49 
50  public:
52  const CaterPillarConf& conf, const std::string& name);
53 
54  virtual ~CaterPillar();
55 
56  /**
57  *Reads the actual motor commands from an array,
58  *an sets all motors of the snake to this values.
59  *It is an linear allocation.
60  *@param motors pointer to the array, motor values are scaled to [-1,1]
61  *@param motornumber length of the motor array
62  **/
63  virtual void setMotorsIntern( const double* motors, int motornumber );
64 
65  /**
66  *Writes the sensor values to an array in the memory.
67  *@param sensors pointer to the array
68  *@param sensornumber length of the sensor array
69  *@return number of actually written sensors
70  **/
71  virtual int getSensorsIntern( double* sensors, int sensornumber );
72 
73  /** returns number of sensors
74  */
75  virtual int getSensorNumberIntern() { assert(created); return 2*universalServos.size()+sliderServos.size(); }
76 
77  /** returns number of motors
78  */
79  virtual int getMotorNumberIntern(){ assert(created); return 2*universalServos.size()+sliderServos.size(); }
80 
81  /******** CONFIGURABLE ***********/
82  virtual void notifyOnChange(const paramkey& key);
83 
84  private:
85  virtual void create(const osg::Matrix& pose);
86  virtual void destroy();
87  };
88 
89 }
90 
91 #endif
Data structure for accessing the ODE.
Definition: odehandle.h:44
Matrixd Matrix
Definition: osgforwarddecl.h:47
CaterPillarConf conf
Definition: defaultCaterpillar.h:77
charArray paramkey
Definition: avrtypes.h:36
virtual int getSensorNumberIntern()
returns number of sensors
Definition: caterpillar.h:75
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
bool created
Definition: defaultCaterpillar.h:74
CaterPillar(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const CaterPillarConf &conf, const std::string &name)
Definition: caterpillar.cpp:32
virtual void notifyOnChange(const paramkey &key)
Is called when a parameter was changes via setParam().
Definition: caterpillar.cpp:136
virtual ~CaterPillar()
Definition: caterpillar.cpp:38
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
virtual void setMotorsIntern(const double *motors, int motornumber)
Reads the actual motor commands from an array, an sets all motors of the snake to this values...
Definition: caterpillar.cpp:48
This is a class, which models a snake like robot.
Definition: defaultCaterpillar.h:70
This is a class, which models a snake like robot.
Definition: caterpillar.h:44
std::list< MotorAttachment > motors
Definition: oderobot.h:270
virtual int getMotorNumberIntern()
returns number of motors
Definition: caterpillar.h:79
Definition: defaultCaterpillar.h:50
virtual int getSensorsIntern(double *sensors, int sensornumber)
Writes the sensor values to an array in the memory.
Definition: caterpillar.cpp:69