angularmotor.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: angularmotor.h,v $
00023  *   Revision 1.2  2006/07/14 12:23:32  martius
00024  *   selforg becomes HEAD
00025  *
00026  *   Revision 1.1.2.6  2006/03/30 12:34:49  martius
00027  *   documentation updated
00028  *
00029  *   Revision 1.1.2.5  2006/02/23 18:05:30  martius
00030  *   setPower (on all axis the same)
00031  *
00032  *   Revision 1.1.2.4  2006/02/07 15:51:56  martius
00033  *   axis, setpower
00034  *
00035  *   Revision 1.1.2.3  2006/01/31 15:43:47  martius
00036  *   *** empty log message ***
00037  *
00038  *   Revision 1.1.2.2  2006/01/03 10:20:16  fhesse
00039  *   methods of AngularMotor1Axis public now
00040  *
00041  *   Revision 1.1.2.1  2005/12/21 15:38:12  martius
00042  *   angular motors nicely wrapped
00043  *
00044  *                                                                 *
00045  ***************************************************************************/
00046 #ifndef __ANGULARMOTOR_H
00047 #define __ANGULARMOTOR_H
00048 
00049 #include <list>
00050 #include "joint.h"
00051 
00052 namespace lpzrobots {
00053 
00054   /** Abstract angular motor class. This is a wrapper for ODE's AMotor.
00055    */
00056   class AngularMotor {
00057   public:
00058     /// creates a AMotor attached to the same bodies as the given joint.
00059     AngularMotor(const OdeHandle& odeHandle, Joint* joint);
00060 
00061     virtual ~AngularMotor (){}
00062 
00063     /// returns the number of Axis of this Motor
00064     virtual int getNumberOfAxes() = 0;
00065 
00066     /** sets the desired speed of the motor at the given axis.       
00067         @param velocity Desired motor velocity (this will be an angular or linear velocity).
00068     */
00069     virtual void set(int axisNumber, double velocity) = 0;
00070     /** returns the speed (PositionRate) at the given axis, or zero if the axis is out of range*/
00071     virtual double get(int axisNumber) = 0;
00072 
00073     /**  sets the maximal force the motor has
00074      */
00075     virtual void setPower(double power) = 0;
00076 
00077 
00078     /** sets the desired speed of all motor.
00079         @param velocities double array with desired velocities
00080         @param len length of the given array
00081         @return number actually returned velocities
00082     */
00083     virtual int set(const double* velocities, int len);
00084     /** returns the speed (PositionRate) of all axis
00085         @param velocities double array to fill in the velocities
00086         @param len length of the given array
00087         @return number actually returned velocities
00088     */
00089     virtual int get(double* velocities, int len);
00090   
00091   protected:
00092     dJointID motor;  
00093   };
00094 
00095 
00096   /// Angular motor for OneAxisJoints
00097   class AngularMotor1Axis : public AngularMotor {
00098   public:
00099     /** Constuct a motor attached to a OneAxisJoint. It will its axis of course.
00100         @param power The maximum force or torque that the motor will use to achieve the desired velocity. 
00101         This must always be greater than or equal to zero. 
00102         Setting this to zero (the default value) turns off the motor.      
00103     */
00104     AngularMotor1Axis(const OdeHandle& odeHandle, OneAxisJoint* joint, double power);
00105     virtual ~AngularMotor1Axis() {}
00106     
00107     /// returns the number of Axis of this Motor
00108     virtual int getNumberOfAxes() { return 1; };
00109 
00110     /** sets the desired speed of the motor at the given axis.       
00111         @param axisNumber is ignored because have only one axis
00112         @param velocity Desired motor velocity (this will be an angular or linear velocity).
00113     */
00114     virtual void set(int axisNumber, double velocity);
00115     /** returns the speed (PositionRate) at the given axis, or zero if the axis is out of range
00116         @param axisNumber is ignored because have only one axis
00117      */
00118     virtual double get(int axisNumber) ;    
00119 
00120     /**  sets the maximal force the motor has
00121      */
00122     virtual void setPower(double power);
00123     
00124   protected:
00125     OneAxisJoint* joint;  
00126   };
00127 
00128   /// Angular motor for TwoAxisJoints
00129   class AngularMotor2Axis : public AngularMotor {
00130   public:
00131     /** Constuct a motor attached to a TwoAxisJoint. It will its two axis of course.
00132         @param power The maximum force or torque that the motor will use to achieve the desired velocity. 
00133         This must always be greater than or equal to zero. 
00134         Setting this to zero (the default value) turns off the motor.      
00135     */
00136     AngularMotor2Axis(const OdeHandle& odeHandle, TwoAxisJoint* joint, double power1, double power2);
00137     virtual ~AngularMotor2Axis() {}
00138 
00139     /// returns the number of Axis of this Motor
00140     virtual int getNumberOfAxes() { return 2; };
00141 
00142     /** sets the desired speed of the motor at the given axis.       
00143         @param axisNumber either 0 or 1
00144         @param velocity Desired motor velocity (this will be an angular or linear velocity).
00145     */
00146     virtual void set(int axisNumber, double velocity);
00147     /** returns the speed (PositionRate) at the given axis, or zero if the axis is out of range*/
00148     virtual double get(int axisNumber) ;    
00149     
00150     /**  sets the maximal force the motor has
00151      */
00152     virtual void setPower(double power);
00153 
00154   protected:
00155     TwoAxisJoint* joint;      
00156   };
00157 
00158 
00159   /// Angular motor for Ball Joints with Euler control
00160   class AngularMotor3AxisEuler : public AngularMotor {
00161   public:
00162     /** Constuct a motor attached to a BallJoint. 
00163         @param axis1 axis relative to body 1
00164         @param axis3 axis relative to body 2 (must be perpendicular to axis1 
00165         (the axis 2 is calculated automatically)        
00166         @param power The maximum force or torque that the motor will use to achieve the desired velocity. 
00167         This must always be greater than or equal to zero. 
00168         Setting this to zero (the default value) turns off the motor.      
00169     */
00170     AngularMotor3AxisEuler(const OdeHandle& odeHandle, BallJoint* joint, 
00171                            const Axis& axis1, const Axis& axis3, double power);
00172     
00173     /// returns the number of Axis of this Motor
00174     virtual int getNumberOfAxes() { return 3; };
00175 
00176     /** sets the desired speed of the motor at the given axis.       
00177         @param axisNumber either 0 or 1
00178         @param velocity Desired motor velocity (this will be an angular or linear velocity).
00179     */
00180     virtual void set(int axisNumber, double velocity);
00181     /** returns the speed (PositionRate) at the given axis, or zero if the axis is out of range*/
00182     virtual double get(int axisNumber) ;    
00183     
00184     /**  sets the maximal force the motor has
00185      */
00186     virtual void setPower(double power);
00187 
00188   protected:
00189     BallJoint* joint;      
00190   };
00191 
00192   /// Angular motor for arbitrary Joints with custom axis (up to 3)
00193   class AngularMotorNAxis : public AngularMotor {
00194   public:
00195     /** Constuct a motor attached to any Joint (not Sliders!). 
00196         The axis have to be provided by the user.       
00197         @param axis list of axis vector and power If empty then it motor is disabled. 
00198         Power is the maximum force or torque that the motor will use to achieve the desired velocity. 
00199         This must always be greater than or equal to zero. 
00200         Setting this to zero (the default value) turns off the motor.      
00201     */
00202     AngularMotorNAxis(const OdeHandle& odeHandle, Joint* joint, 
00203                       std::list<std::pair<double, Axis > > axis);
00204 
00205     virtual ~AngularMotorNAxis() {}
00206     
00207     /// returns the number of Axis of this Motor
00208     virtual int getNumberOfAxes();
00209 
00210     /** sets the desired speed of the motor at the given axis.       
00211         @param velocity Desired motor velocity (this will be an angular or linear velocity).
00212     */
00213     virtual void set(int axisNumber, double velocity);
00214     /** returns the speed (PositionRate) at the given axis, or zero if the axis is out of range
00215         The problem is, that we don't have actual information available. 
00216         So we return the last set position!.
00217      */
00218     virtual double get(int axisNumber) ;    
00219 
00220     /**
00221        sets the maximal force the motor has
00222      */
00223     virtual void setPower(double power);
00224     
00225   protected:
00226     Joint* joint; 
00227   };
00228 
00229 
00230 
00231 }
00232 #endif

Generated on Mon Aug 7 16:40:14 2006 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7