Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
EmergencyStopMC.hGo to the documentation of this file.00001 #ifndef INCLUDED_EmergencyStopMC_h 00002 #define INCLUDED_EmergencyStopMC_h 00003 00004 #include "PostureMC.h" 00005 #ifdef TGT_HAS_LEDS 00006 # include "LedEngine.h" 00007 #endif 00008 00009 //!overrides all joints with high priority freeze, blinks tail pink/red/blue cycle 00010 /*! Uses MotionCommand::kEmergencyPriority. Monitors the feedback on joints and 00011 * adjusts joints to react to pressures above a certain threshold. This allows 00012 * you to mold the body while it's in this mode, while retaining enough stiffness 00013 * to hold against gravity. 00014 * 00015 * This MotionCommand is intended to always be left running. It polls WorldState::state 00016 * for a double-tap on the back button, which causes it to set its joint values. 00017 * to whatever their current state is. LEDs are left blank, except the tail, 00018 * which is used to indicate that the emergency stop is on. 00019 * 00020 * A second double-tap will cause it to set all joints to 0 weight 00021 * 00022 * The tail LEDs only ever go up to .5, so that if you really care whether the tail 00023 * light was set by an underlying behavior/motion, you should be able to tell by 00024 * looking closely (if blue is going from .5 to 1, that's because it's already set) 00025 */ 00026 class EmergencyStopMC : public PostureMC { 00027 public: 00028 EmergencyStopMC(); //!< constructor 00029 virtual ~EmergencyStopMC() {} //!< destructor 00030 virtual int updateOutputs(); //!< checks for feedback or double tap 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=r; } //!< takes a value to set #pidcutoff 00039 float getResetSensitivity() { return pidcutoff; } //!< returns #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 static const unsigned int FADE_OUT_TIME=400; //!< number of milliseconds to fade out lock on joints 00047 00048 bool paused; //!< true if the joints are current locked up 00049 bool stilldown; //!< true if the back button was down on last updateJointCmds 00050 bool active; //!< true if the EmergencyStopMC is monitoring the back button (if false, won't pause on a double-tap) 00051 unsigned int period; //!< period of cycles on tail LEDs 00052 unsigned int timeoflastbtn; //!< time of the last button press 00053 unsigned int timeofthisbtn; //!< time of the current button press 00054 unsigned int timeoflastfreeze; //!< the time estop was last turned on 00055 unsigned int timeoflastrelease; //!< the time estop was last turned off (may be in the future if still fading out control of joints!) 00056 unsigned int duration; //!<the maximum time (in milliseconds) of consecutive button-down's to count as a double tap 00057 float piddutyavgs[NumPIDJoints]; //!< a running average of PID feedback ("duty"), so one bad reading doesn't cause a movement, need a consistent pressure 00058 float pidcutoff; //!<abs pid duty cycle above which we just reset joint to current 00059 #ifdef TGT_HAS_LEDS 00060 LedEngine ledengine; //!< used to do LED effects on the tail 00061 #endif 00062 }; 00063 00064 /*! @file 00065 * @brief Describes EmergencyStopMC, overrides all joints, allows modelling, blinks tail 00066 * @author ejt (Creator) 00067 */ 00068 00069 #endif |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:58:38 2016 by Doxygen 1.6.3 |