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

Generated on Tue Sep 16 22:00:22 2008 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7