| Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
WheeledWalkMC.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_WheeledWalkMC_h_ 00003 #define INCLUDED_WheeledWalkMC_h_ 00004 00005 #include "Motion/MotionCommand.h" 00006 #include "Motion/MotionManager.h" 00007 #include "Shared/get_time.h" 00008 #include "Shared/RobotInfo.h" 00009 #include "Shared/plist.h" 00010 00011 //! Provides a 'WalkMC' implementation for wheeled robots (diff-drive or theoretically holonomic configurations as well) 00012 /*! Uses kinematic description to determine location and orientation of wheels 00013 * and computes appropriate wheel velocities to produce a target motion. 00014 * Can handle skid-steer (diff drive) type motion, including holonomic wheels, 00015 * but does not handle ackerman style (steered) configurations. 00016 * 00017 * Also does not handle 'slanted' wheels optimally: Assumes wheels are perpendicular 00018 * to the ground, that the base frame Z axis is perpendicular to the ground frame. 00019 * This could be added with a bit more math when computing wheel positions. 00020 * 00021 * This motion command also assumes that wheels are commanded by mm/sec ground 00022 * speed, not rad/sec rotational speed. 00023 * 00024 * For simulation in Mirage, make sure all wheels are marked by adding a Velocity=true 00025 * entry in the ControllerInfo of the corresponding kinematics configuration, and that 00026 * the x and y dimensions of the collision model are set for the wheel radius. 00027 * 00028 * TODO: Test on a holonomic platform, should handle it, but originally only 00029 * tested on diff-drive like Create. Also, perhaps add config settings to override #center and 00030 * a flag to have updateWheelInfo called before each updateOutputs. */ 00031 class WheeledWalkMC : public MotionCommand, public virtual plist::Dictionary { 00032 public: 00033 //! constructor 00034 WheeledWalkMC() : plist::Dictionary(), MotionCommand(), 00035 preferredXVel(), preferredYVel(), preferredAngVel(), 00036 targetVel(), targetAngVel(0), maxVel(), maxAngVel(0), 00037 center(), displacementMode(false), travelTime(0), travelDur(0), dirty(false) 00038 { 00039 addEntry("PreferredXVel",preferredXVel,"optimal X velocity for unspecified displacements (mm/s)"); 00040 addEntry("PreferredYVel",preferredYVel,"optimal Y velocity for unspecified displacements (mm/s)"); 00041 addEntry("PreferredAngVel",preferredAngVel,"optimal angular velocity for unspecified displacements (rad/s)"); 00042 setLoadSavePolicy(FIXED,SYNC); 00043 resetConfig(); 00044 } 00045 00046 void resetConfig(); //!< reset and reload configuration settings, implies call to updateWheelInfo() 00047 00048 virtual int updateOutputs(); 00049 virtual int isDirty() { return dirty; } 00050 virtual int isAlive() { return !displacementMode || getTravelTime()>=travelDur || dirty; } 00051 virtual void start(); 00052 virtual void stop(); 00053 00054 //! Posts a LocomotionEvent and sets velocities to zero. Also forces an output frame setting wheel velocities to zero; needed because if we remove a motion command there may be nothing left to zero the velocities. 00055 virtual void zeroVelocities(); 00056 00057 float getMaxXVel() const { return maxVel[0]; } 00058 float getMaxYVel() const { return maxVel[1]; } 00059 float getMaxAVel() const { return maxAngVel; } 00060 00061 unsigned int getTravelTime() { return get_time()-travelTime; } //!< the amount of time (ms) we have been travelling the current vector 00062 00063 //! Returns the current x and y velocities in mm/sec 00064 const fmat::Column<2>& getTargetVelocity() const { return targetVel; }; 00065 00066 //! Returns the current angular velocity in radians/sec 00067 float getTargetAngVelocity() const { return targetAngVel; } 00068 00069 //! Specify the desired body velocity in x and y (millimeters per second) and angular velocity (radians per second) 00070 virtual void getTargetVelocity(float &xvel, float &yvel, float &avel) { 00071 xvel = targetVel[0]; 00072 yvel = targetVel[1]; 00073 avel = targetAngVel; 00074 } 00075 00076 //! Specify the desired body velocity in x and y (millimeters per second) and angular velocity (radians per second); does not stop automatically 00077 virtual void setTargetVelocity(float xvel, float yvel, float avel); 00078 00079 //! Specify the desired body velocity in x and y (millimeters per second) and angular velocity (radians per second), and amount of time before stopping 00080 virtual void setTargetVelocity(float xvel, float yvel, float avel, float time); 00081 00082 //! Specify the desired body displacement in x and y (millimeters) and a (radians) 00083 /*! Corresponding velocity will be limited to max velocity, so setting time=0 implies max speed */ 00084 virtual void setTargetDisplacement(float xdisp, float ydisp, float adisp, float time=0); 00085 00086 //! Recomputes wheel positions and orientations. Automatically called by constructor, but may need to recall if wheel positions are actuated. 00087 /*! Includes a call to updateWheelVels() in case wheel positions change. */ 00088 virtual void updateWheelInfo(); 00089 00090 plist::Primitive<float> preferredXVel; //!< optimal X velocity for unspecified displacements 00091 plist::Primitive<float> preferredYVel; //!< optimal Y velocity for unspecified displacements 00092 plist::Primitive<float> preferredAngVel; //!< optimal angular velocity for unspecified displacements 00093 00094 protected: 00095 void updateWheelVels(); //!< updates WheelInfo::targetVel values based on #targetVel and #targetAngVel 00096 00097 fmat::Column<2> targetVel; //!< the requested xy velocity of the body (ignoring parameterized body motion, like sway or surge), millimeters per second 00098 float targetAngVel; //!< the requested angular velocity of the body, radians per second 00099 fmat::Column<2> maxVel; //!< maximum velocity in x,y 00100 float maxAngVel; //!< maximum angular velocity 00101 00102 fmat::Column<2> center; //!< point to use as center of rotations, defaults to center of wheels 00103 bool displacementMode; //!< If true, velocity will be set to 0 when clock reaches #arrivalTime 00104 unsigned int travelTime; //!< the time of the last call to setTargetVelocity - handy to check the time we've been traveling current vector 00105 unsigned int travelDur; //!< duration in msecs for the current displacement 00106 bool dirty; //!< set to true by updateWheelVels(), cleared up updateOutputs() 00107 00108 //! stores information about the configuration and current target state of each wheel 00109 struct WheelInfo { 00110 WheelInfo() : valid(false), position(), direction(), targetVel(0) {} 00111 bool valid; //!< set to false if the wheel axle is vertical 00112 fmat::Column<2> position; //!< the center of the wheel's contact 00113 fmat::Column<2> direction; //!< the direction of forward motion produced by this wheel 00114 float targetVel; //!< the current wheel velocity to supply to motman via updateOutputs, is calculated by setTargetVelocity() 00115 }; 00116 WheelInfo wheels[NumWheels]; 00117 }; 00118 00119 /*! @file 00120 * @brief Defines WheeledWalkMC, which provides a 'WalkMC' implementation for wheeled robots (diff-drive or theoretically holonomic configurations as well) 00121 * @author Ethan Tira-Thompson (ejt) (Creator) 00122 */ 00123 00124 #endif |
|
Tekkotsu v5.1CVS |
Generated Fri Mar 16 05:26:54 2012 by Doxygen 1.6.3 |