Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 #ifndef INCLUDED_EmergencyStopMC_h 00002 #define INCLUDED_EmergencyStopMC_h 00003 00004 #include "PostureMC.h" 00005 #include "LedEngine.h" 00006 00007 //!overrides all joints with high priority freeze, blinks tail pink/red/blue cycle 00008 /*! Uses MotionCommand::kEmergencyPriority. Monitors the feedback on joints and 00009 * adjusts joints to react to pressures above a certain threshold. This allows 00010 * you to mold the body while it's in this mode, while retaining enough stiffness 00011 * to hold against gravity. 00012 * 00013 * This MotionCommand is intended to always be left running. It polls WorldState::state 00014 * for a double-tap on the back button, which causes it to set its joint values. 00015 * to whatever their current state is. LEDs are left blank, except the tail, 00016 * which is used to indicate that the emergency stop is on. 00017 * 00018 * A second double-tap will cause it to set all joints to 0 weight 00019 * 00020 * The tail LEDs only ever go up to .5, so that if you really care whether the tail 00021 * light was set by an underlying behavior/motion, you should be able to tell by 00022 * looking closely (if blue is going from .5 to 1, that's because it's already set) 00023 */ 00024 class EmergencyStopMC : public PostureMC { 00025 public: 00026 EmergencyStopMC(); //!< constructor 00027 virtual ~EmergencyStopMC() {} //!< destructor 00028 virtual int updateOutputs(); //!< checks for feedback or double tap 00029 00030 virtual void takeSnapshot(); //!< records current positions of joints 00031 00032 void setActive(bool a); //!< allows you to modify #active 00033 bool getActive() { return active; } //!< returns #active 00034 void setStopped(bool p, bool sound=true); //!< allows you to modify #paused 00035 bool getStopped() const { return paused; } //!< returns #paused 00036 void setDblTapDuration(unsigned int d) { duration=d; } //!< sets #duration 00037 unsigned int getDblTapDuration() const { return duration; } //!< returns #duration 00038 void setResetSensitivity(float r) { pidcutoff=static_cast<unsigned char>(r*255); } //!< takes a value [0,1] to set #pidcutoff 00039 float getResetSensitivity() { return pidcutoff/255.0; } //!< returns a value [0-1], corresponding to #pidcutoff 00040 00041 protected: 00042 void freezeJoints(); //!< code to execute when locking joints 00043 void releaseJoints(); //!< code to execute when releasing joints 00044 static bool trigger(); //!< true when the trigger condition is active 00045 00046 bool paused; //!< true if the joints are current locked up 00047 bool stilldown; //!< true if the back button was down on last updateJointCmds 00048 bool active; //!< true if the EmergencyStopMC is monitoring the back button (if false, won't pause on a double-tap) 00049 unsigned int period; //!< period of cycles on tail LEDs 00050 unsigned int timeoflastbtn; //!< time of the last button press 00051 unsigned int timeofthisbtn; //!< time of the current button press 00052 unsigned int timeoflastfreeze; //!< the time estop was last turned on 00053 unsigned int duration; //!<the maximum time (in milliseconds) of consecutive button-down's to count as a double tap 00054 unsigned char piddutyavgs[NumPIDJoints]; //!< a running average of PID feedback ("duty"), so one bad reading doesn't cause a movement, need a consistent pressure 00055 unsigned char pidcutoff; //!<abs pid duty cycle above which we just reset joint to current 00056 LedEngine ledengine; //!< used to do LED effects on the tail 00057 }; 00058 00059 /*! @file 00060 * @brief Describes EmergencyStopMC, overrides all joints, allows modelling, blinks tail 00061 * @author ejt (Creator) 00062 * 00063 * $Author: ejt $ 00064 * $Name: tekkotsu-2_0 $ 00065 * $Revision: 1.10 $ 00066 * $State: Exp $ 00067 * $Date: 2004/01/18 10:16:57 $ 00068 */ 00069 00070 #endif
Tekkotsu v2.0 |
Generated Wed Jan 21 03:20:28 2004 by Doxygen 1.3.4 |