Robotsystem from Robot Group Leipzig: angularmotor.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

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