00001 /************************************************************************/ 00002 /*schlangevelocity.h */ 00003 /*Snake with powered by setting angular velocities */ 00004 /* */ 00005 /************************************************************************/ 00006 /*************************************************************************** 00007 * Copyright (C) 2005 by Robot Group Leipzig * 00008 * martius@informatik.uni-leipzig.de * 00009 * fhesse@informatik.uni-leipzig.de * 00010 * der@informatik.uni-leipzig.de * 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 * This program is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU General Public License * 00023 * along with this program; if not, write to the * 00024 * Free Software Foundation, Inc., * 00025 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00026 * * 00027 * $Log: schlangevelocity.h,v $ 00028 * Revision 1.1.2.3 2006/03/30 12:34:57 martius 00029 * documentation updated 00030 * 00031 * Revision 1.1.2.2 2006/02/01 18:33:40 martius 00032 * use Axis type for Joint axis. very important, since otherwise Vec3 * pose is not the right direction vector anymore 00033 * 00034 * Revision 1.1.2.1 2006/01/10 13:55:12 fhesse 00035 * snake powered by directly setting angular velocities 00036 * * 00037 * * 00038 * * 00039 ***************************************************************************/ 00040 #ifndef __SCHLANGEVELOCITY_H 00041 #define __SCHLANGEVELOCITY_H 00042 00043 #include "schlange.h" 00044 00045 namespace lpzrobots { 00046 00047 /** 00048 * This is a class, which models a snake like robot. 00049 * It consists of a number of equal elements, each linked 00050 * by a joint powered by directly setting the angular velocities of the joints 00051 **/ 00052 class SchlangeVelocity: public Schlange 00053 { 00054 private: 00055 paramval factor_motors; 00056 paramval factor_sensors; 00057 paramval friction_joint; 00058 00059 00060 public: 00061 SchlangeVelocity ( const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00062 const SchlangeConf& conf, const char* name); 00063 00064 static SchlangeConf getDefaultConf(){ 00065 SchlangeConf conf; 00066 conf.segmNumber = 10; // number of snake elements 00067 conf.segmLength = 0.8; // length of one snake element 00068 conf.segmDia = 0.2; // diameter of a snake element 00069 conf.segmMass = 0.4; // mass of one snake element 00070 conf.motorPower = 0.3; // power of motors 00071 conf.frictionGround = 0.1; // friction with ground 00072 conf.jointLimit = M_PI/4; 00073 return conf; 00074 } 00075 00076 virtual ~SchlangeVelocity(); 00077 00078 /** 00079 *Reads the actual motor commands from an array, 00080 *an sets all motors of the snake to this values. 00081 *It is an linear allocation. 00082 *@param motors pointer to the array, motor values are scaled to [-1,1] 00083 *@param motornumber length of the motor array 00084 **/ 00085 virtual void setMotors ( const motor* motors, int motornumber ); 00086 00087 /** 00088 *Writes the sensor values to an array in the memory. 00089 *@param sensors pointer to the array 00090 *@param sensornumber length of the sensor array 00091 *@return number of actually written sensors 00092 **/ 00093 virtual int getSensors ( sensor* sensors, int sensornumber ); 00094 00095 /** returns number of sensors 00096 */ 00097 virtual int getSensorNumber() { assert(created); return joints.size() * 2; } 00098 00099 /** returns number of motors 00100 */ 00101 virtual int getMotorNumber(){ assert(created); return joints.size() * 2; } 00102 00103 private: 00104 virtual void create(const osg::Matrix& pose); 00105 virtual void destroy(); 00106 }; 00107 00108 } 00109 00110 #endif