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

Generated on Tue Apr 4 19:05:03 2006 for Robotsystem from Robot Group Leipzig by  doxygen 1.4.5