Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 #ifndef INCLUDED_HeadPointerMC_h 00003 #define INCLUDED_HeadPointerMC_h 00004 00005 #include "MotionCommand.h" 00006 #include "OutputCmd.h" 00007 #include "Shared/RobotInfo.h" 00008 00009 //! This class gives some quick and easy functions to point the head at things 00010 class HeadPointerMC : public MotionCommand { 00011 public: 00012 //! constructor, defaults to active, BodyRelative, all joints at 0 00013 HeadPointerMC(); 00014 //! destructor 00015 virtual ~HeadPointerMC() {} 00016 00017 //! Various modes the head can be in. In the future may want to add ability to explicitly track an object or point in the world model 00018 enum CoordFrame_t { 00019 BodyRelative, //!<holds neck at a specified position, like a PostureEngine, but neck specific 00020 GravityRelative //!<uses accelerometers to keep a level head, doesn't apply for pan joint, but in future could use localization for pan 00021 }; 00022 00023 void setWeight(double w); //!< sets the weight values for all the neck joints 00024 inline void setWeight(RobotInfo::TPROffset_t i, double weight) { dirty=true; headJoints[i].weight=weight; } //!< set a specific head joint weight, pass one of RobotInfo::TPROffset_t, not a full offset! 00025 inline void setActive(bool a) { active=a; } //!< sets #active flag, see isDirty() 00026 inline bool getActive() const { return active; } //!< returns #active flag, see isDirty() 00027 00028 //! converts a value @a v in @a srcmode to a value in @a tgtmode that would leave the joint angle for joint @a i constant (you probably won't need to call this directly) 00029 inline double convert(RobotInfo::TPROffset_t i, double v, CoordFrame_t srcmode, CoordFrame_t tgtmode) const { 00030 return (srcmode==tgtmode)?v:convFromBodyRelative(i,convToBodyRelative(i, v, srcmode),tgtmode); 00031 } 00032 00033 //!Note that none of these are @c virtual, so you don't have to checkout to use them, you @e should be able to use MotionManager::peekMotion() 00034 //!@name Joint Accessors 00035 void setJoints(double tilt, double pan, double roll); //!< Directly sets the neck values, uses current mode 00036 void setMode(CoordFrame_t m, bool convert=true); //!< sets all the joints to the given mode, will convert the values to the new mode if @a convert is true 00037 void setJointMode(RobotInfo::TPROffset_t i, CoordFrame_t m, bool convert=true); //!< set a specific head joint's mode, will convert from previous mode's value to next mode's value if convert is true. Pass one of RobotInfo::TPROffset_t, not a full offset! 00038 inline void setJointValue(RobotInfo::TPROffset_t i, double value) { dirty=true; headValues[i]=value;} //!< set a specific head joint's value (for whatever mode it's in), pass one of RobotInfo::TPROffset_t, not a full offset! 00039 inline void setJointValueAndMode(RobotInfo::TPROffset_t i, double value, CoordFrame_t m) { dirty=true; headValues[i]=value; headModes[i]=m; } //!< set a specific head joint, pass one of RobotInfo::TPROffset_t, not a full offset! 00040 inline void setJointValueFromMode(RobotInfo::TPROffset_t i, double value, CoordFrame_t m) { dirty=true; headValues[i]=convert(i,value,m,headModes[i]); } //!< set a specific head joint auto converting @a value from mode @a m to the current mode, pass one of RobotInfo::TPROffset_t, not a full offset! 00041 inline CoordFrame_t getJointMode(RobotInfo::TPROffset_t i) const { return headModes[i]; } //!< returns the current mode for joint @a i (use RobotInfo::TPROffset_t, not global offset) 00042 inline double getJointValue(RobotInfo::TPROffset_t i) const { return headValues[i]; } //!< returns the current value (relative to the current mode) of joint @a i, use getOutputCmd() if you want to know the actual @b target joint value (to get the actual current joint position, look in WorldState 00043 //@} 00044 00045 //!@name Inherited: 00046 virtual int updateOutputs( ); //!< Updates where the head is looking 00047 virtual const OutputCmd& getOutputCmd(unsigned int i); //!< returns one of the #headJoints entries or ::unusedJoint if not a head joint 00048 virtual int isDirty() { return (dirty && active)?1:0; } //!< true if a change has been made since the last updateJointCmds() and we're active 00049 virtual int isAlive() { return true; } 00050 //@} 00051 00052 protected: 00053 double convToBodyRelative(RobotInfo::TPROffset_t i, double v, CoordFrame_t mode) const; //!< converts to a body relative measurement for joint @a i 00054 double convFromBodyRelative(RobotInfo::TPROffset_t i, double v, CoordFrame_t mode) const; //!< converts from a body relative measurement for joint @a i 00055 00056 bool dirty; //!< true if a change has been made since last call to updateJointCmds() 00057 bool active; //!< set by accessor functions, defaults to true 00058 OutputCmd headJoints[NumHeadJoints]; //!< stores the current target head angles 00059 double headValues[NumHeadJoints]; //!< stores the target value of each joint, relative to #headModes 00060 CoordFrame_t headModes[NumHeadJoints]; //!< stores the current mode of each joint, for instance so tilt can be GravityRelative while pan is static 00061 static const OutputCmd unused; //!< handy when we need a reference to an unused joint 00062 }; 00063 00064 /*! @file 00065 * @brief Describes HeadPointerMC, a class for various ways to control where the head is looking 00066 * @author ejt (Creator) 00067 * 00068 * $Author: ejt $ 00069 * $Name: tekkotsu-1_4_1 $ 00070 * $Revision: 1.5 $ 00071 * $State: Exp $ 00072 * $Date: 2003/07/07 01:00:08 $ 00073 */ 00074 00075 #endif 00076
Tekkotsu v1.4 |
Generated Sat Jul 19 00:06:30 2003 by Doxygen 1.3.2 |