Robotsystem of the Robot Group Leipzig: angularmotor.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

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