Libbarrett  1.2.4
include/barrett/products/safety_module.h
Go to the documentation of this file.
00001 
00033 #ifndef BARRETT_PRODUCTS_SAFETY_MODULE_H_
00034 #define BARRETT_PRODUCTS_SAFETY_MODULE_H_
00035 
00036 
00037 #include <string>
00038 
00039 #include <barrett/products/puck.h>
00040 #include <barrett/products/abstract/special_puck.h>
00041 
00042 
00043 namespace barrett {
00044 
00045 
00046 class SafetyModule : public SpecialPuck {
00047 public:
00051         enum SafetyMode {
00052                 ESTOP, IDLE, ACTIVE
00053         };
00054 
00058         SafetyModule(Puck* puck = NULL);
00059         ~SafetyModule() {}
00063         enum SafetyMode getMode(bool realtime = false) const;
00067         void waitForMode(enum SafetyMode mode,
00068                         bool printMessage = true, double pollingPeriod_s = 0.25);
00072         enum SafetyMode waitForModeChange(double pollingPeriod_s = 0.25);
00076         static const char* getSafetyModeStr(enum SafetyMode mode) {
00077                 return safetyModeStrs[mode];
00078         }
00084         void setMode(enum SafetyMode mode) { p->setProperty(Puck::MODE, mode); }
00088         bool wamIsZeroed() const { return p->getProperty(Puck::ZERO) == 1; }
00092         void setWamZeroed(bool zeroed = true) const {
00093                 p->setProperty(Puck::ZERO, zeroed);
00094         }
00098         void ignoreNextVelocityFault();
00102         void setDefaultSafetyLimits();
00107         void setTorqueLimit(double fault, double warning = -1.0, int ipnm = Puck::DEFAULT_IPNM);
00112         void setVelocityLimit(double fault, double warning = -1.0);
00113 
00117         struct PendantState {
00118                 enum Button { ESTOP, ACTIVATE, IDLE, NONE };
00119                 enum Parameter { SAFE, WARNING, FAULT };
00120                 enum ParameterNames {
00121                         VELOCITY, TORQUE, VOLTAGE, HEARTBEAT, OTHER,
00122                         NUM_PARAMS
00123                 };
00124 
00125                 enum Button pressedButton;
00126                 bool activateLight;
00127                 bool idleLight;
00128                 char displayedCharacter;
00129                 enum Parameter safetyParameters[NUM_PARAMS];
00130 
00131                 bool allSafe() const;
00132                 bool hasFaults() const;
00133 
00134                 std::string toString() const;
00135                 char decodeDisplayedCharacter() const;
00136         };
00141         void getPendantState(PendantState* ps, bool realtime = false) const;
00142 
00143 protected:
00144         static const int VELOCITY_FAULT_HISTORY_BUFFER_SIZE = 5;
00145 
00146 private:
00147         static const char safetyModeStrs[][15];
00148 };
00149 
00150 
00151 }
00152 
00153 
00154 #endif /* BARRETT_PRODUCTS_SAFETY_MODULE_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines