arm2segm.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 * * 00022 * $Log: arm2segm.h,v $ 00023 * Revision 1.7 2006/08/11 15:44:52 martius 00024 * *** empty log message *** 00025 * 00026 * Revision 1.6 2006/07/20 17:19:43 martius 00027 * removed using namespace std from matrix.h 00028 * 00029 * Revision 1.5 2006/07/14 12:23:38 martius 00030 * selforg becomes HEAD 00031 * 00032 * Revision 1.4.4.7 2006/06/25 16:57:11 martius 00033 * abstractrobot is configureable 00034 * name and revision 00035 * 00036 * Revision 1.4.4.6 2006/03/30 12:34:56 martius 00037 * documentation updated 00038 * 00039 * Revision 1.4.4.5 2006/01/03 13:18:51 fhesse 00040 * cleaned up 00041 * TO do: in the long run robot disappears (huge sensorvalues) 00042 * 00043 * Revision 1.4.4.4 2006/01/03 10:01:46 fhesse 00044 * moved to osg 00045 * 00046 * Revision 1.4.4.3 2005/11/16 11:26:52 martius 00047 * moved to selforg 00048 * 00049 * Revision 1.4.4.2 2005/11/15 12:29:26 martius 00050 * new selforg structure and OdeAgent, OdeRobot ... 00051 * 00052 * Revision 1.4.4.1 2005/11/14 17:37:17 martius 00053 * moved to selforg 00054 * 00055 * Revision 1.4 2005/10/06 17:14:24 martius 00056 * switched to stl lists 00057 * 00058 * Revision 1.3 2005/09/22 12:24:36 martius 00059 * removed global variables 00060 * OdeHandle and GlobalData are used instead 00061 * sensor prepared 00062 * 00063 * Revision 1.2 2005/09/20 11:17:29 fhesse 00064 * smaller changes, needs clean up and comments 00065 * 00066 * Revision 1.1 2005/07/28 10:22:55 fhesse 00067 * initial version, 00068 * known bugs: when calling show params an 00069 * "pure virtual function called" error happens 00070 * 00071 * 00072 * * 00073 ***************************************************************************/ 00074 #ifndef __ARM2SEGM_H 00075 #define __ARM2SEGM_H 00076 00077 #include "oderobot.h" 00078 #include <selforg/configurable.h> 00079 #include <vector> 00080 00081 #include "primitive.h" 00082 #include "joint.h" 00083 00084 #include "angularmotor.h" 00085 namespace lpzrobots{ 00086 00087 typedef struct { 00088 double max_force; // maximal force for motors 00089 int segmentsno; // number of segments 00090 00091 double base_mass; // mass of base 00092 double base_length; 00093 double base_width; 00094 00095 double arm_mass; // mass of arms 00096 double arm_width; 00097 double arm_length; 00098 double arm_offset; // used for placing of arms 00099 00100 double joint_offset; // used for placing of arms 00101 } Arm2SegmConf; 00102 00103 00104 00105 class Arm2Segm : public OdeRobot{ 00106 public: 00107 00108 Arm2Segm(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const Arm2SegmConf); 00109 00110 virtual ~Arm2Segm(){}; 00111 00112 static Arm2SegmConf getDefaultConf(){ 00113 Arm2SegmConf conf; 00114 conf.max_force=5; // maximal force for motors 00115 conf.segmentsno=4; // number of segments 00116 conf.base_mass=0.5; // mass of base segment 00117 conf.base_length= 0.4; // length of base segment 00118 conf.base_width= 0.1; // width of base segment 00119 conf.arm_mass=0.1; // mass of arm elements 00120 conf.arm_width=0.2; // width (thickness) of arms 00121 conf.arm_length = 1.2; // length of arms 00122 conf.arm_offset= 0.03; // offset between arms (so that they do not touch) 00123 conf.joint_offset=0.2; // overlapping of arms (to have area for joints) 00124 return conf; 00125 } 00126 00127 /// update the subcomponents 00128 virtual void update(); 00129 00130 /** sets the pose of the vehicle 00131 @param pose desired 4x4 pose matrix 00132 */ 00133 virtual void place(const osg::Matrix& pose); 00134 00135 /** returns actual sensorvalues 00136 @param sensors sensors scaled to [-1,1] 00137 @param sensornumber length of the sensor array 00138 @return number of actually written sensors 00139 */ 00140 virtual int getSensors(sensor* sensors, int sensornumber); 00141 00142 /** sets actual motorcommands 00143 @param motors motors scaled to [-1,1] 00144 @param motornumber length of the motor array 00145 */ 00146 virtual void setMotors(const motor* motors, int motornumber); 00147 00148 /** returns number of sensors 00149 */ 00150 virtual int getSensorNumber(){ 00151 return sensorno; 00152 }; 00153 00154 /** returns number of motors 00155 */ 00156 virtual int getMotorNumber(){ 00157 return motorno; 00158 }; 00159 00160 /** returns a vector with the positions of all segments of the robot 00161 @param poslist vector of positions (of all robot segments) 00162 @return length of the list 00163 */ 00164 virtual int getSegmentsPosition(std::vector<Position> &poslist); 00165 00166 /** the main object of the robot, which is used for position and speed tracking */ 00167 virtual Primitive* getMainPrimitive() const; 00168 00169 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00170 /** this function is called in each timestep. It should perform robot-internal checks, 00171 like space-internal collision detection, sensor resets/update etc. 00172 @param globalData structure that contains global data from the simulation environment 00173 */ 00174 virtual void doInternalStuff(const GlobalData& globalData); 00175 00176 /** The list of all parameters with there value as allocated lists. 00177 @return list of names 00178 */ 00179 paramlist getParamList() const; 00180 00181 virtual paramval getParam(const paramkey& key) const; 00182 00183 virtual bool setParam(const paramkey& key, paramval val); 00184 00185 00186 protected: 00187 00188 /** creates vehicle at desired pose 00189 @param pose 4x4 pose matrix 00190 */ 00191 virtual void create(const osg::Matrix& pose); 00192 00193 /** destroys vehicle and space 00194 */ 00195 virtual void destroy(); 00196 00197 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00198 00199 dSpaceID parentspace; 00200 00201 Arm2SegmConf conf; 00202 00203 std::vector <Primitive*> objects; 00204 std::vector <Joint*> joints; 00205 std::vector <AngularMotor1Axis*> amotors; 00206 00207 std::string name; 00208 paramval speed; 00209 paramval factorSensors; 00210 00211 int sensorno; //number of sensors 00212 int motorno; // number of motors 00213 00214 bool created; // true if robot was created 00215 }; 00216 }; 00217 #endif

Generated on Tue Jan 16 02:14:34 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8