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 __ARM2SEGM_H 00025 #define __ARM2SEGM_H 00026 00027 #include "oderobot.h" 00028 #include <selforg/configurable.h> 00029 #include <vector> 00030 00031 #include "primitive.h" 00032 #include "joint.h" 00033 00034 #include "angularmotor.h" 00035 namespace lpzrobots{ 00036 00037 typedef struct { 00038 double max_force; // maximal force for motors 00039 int segmentsno; // number of segments 00040 00041 double base_mass; // mass of base 00042 double base_length; 00043 double base_width; 00044 00045 double arm_mass; // mass of arms 00046 double arm_width; 00047 double arm_length; 00048 double arm_offset; // used for placing of arms 00049 00050 double joint_offset; // used for placing of arms 00051 } Arm2SegmConf; 00052 00053 00054 00055 class Arm2Segm : public OdeRobot{ 00056 public: 00057 00058 Arm2Segm(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const Arm2SegmConf); 00059 00060 virtual ~Arm2Segm(){}; 00061 00062 static Arm2SegmConf getDefaultConf(){ 00063 Arm2SegmConf conf; 00064 conf.max_force=5; // maximal force for motors 00065 conf.segmentsno=4; // number of segments 00066 conf.base_mass=0.5; // mass of base segment 00067 conf.base_length= 0.4; // length of base segment 00068 conf.base_width= 0.1; // width of base segment 00069 conf.arm_mass=0.1; // mass of arm elements 00070 conf.arm_width=0.2; // width (thickness) of arms 00071 conf.arm_length = 1.2; // length of arms 00072 conf.arm_offset= 0.03; // offset between arms (so that they do not touch) 00073 conf.joint_offset=0.2; // overlapping of arms (to have area for joints) 00074 return conf; 00075 } 00076 00077 /// update the subcomponents 00078 virtual void update(); 00079 00080 /** sets the pose of the vehicle 00081 @param pose desired 4x4 pose matrix 00082 */ 00083 virtual void place(const osg::Matrix& pose); 00084 00085 /** returns actual sensorvalues 00086 @param sensors sensors scaled to [-1,1] 00087 @param sensornumber length of the sensor array 00088 @return number of actually written sensors 00089 */ 00090 virtual int getSensors(sensor* sensors, int sensornumber); 00091 00092 /** sets actual motorcommands 00093 @param motors motors scaled to [-1,1] 00094 @param motornumber length of the motor array 00095 */ 00096 virtual void setMotors(const motor* motors, int motornumber); 00097 00098 /** returns number of sensors 00099 */ 00100 virtual int getSensorNumber(){ 00101 return sensorno; 00102 }; 00103 00104 /** returns number of motors 00105 */ 00106 virtual int getMotorNumber(){ 00107 return motorno; 00108 }; 00109 00110 /** returns a vector with the positions of all segments of the robot 00111 @param poslist vector of positions (of all robot segments) 00112 @return length of the list 00113 */ 00114 virtual int getSegmentsPosition(std::vector<Position> &poslist); 00115 00116 /** the main object of the robot, which is used for position and speed tracking */ 00117 virtual Primitive* getMainPrimitive() const; 00118 00119 virtual void doInternalStuff(GlobalData& globalData); 00120 00121 protected: 00122 00123 /** creates vehicle at desired pose 00124 @param pose 4x4 pose matrix 00125 */ 00126 virtual void create(const osg::Matrix& pose); 00127 00128 /** destroys vehicle and space 00129 */ 00130 virtual void destroy(); 00131 00132 dSpaceID parentspace; 00133 00134 Arm2SegmConf conf; 00135 00136 00137 00138 std::vector <AngularMotor1Axis*> amotors; 00139 00140 std::string name; 00141 paramval speed; 00142 paramval factorSensors; 00143 00144 int sensorno; //number of sensors 00145 int motorno; // number of motors 00146 00147 bool created; // true if robot was created 00148 }; 00149 }; 00150 #endif