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