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

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7