INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
driverthread.h00001 #ifndef HYDRORMPUTIL_DRIVERTHREAD_H 00002 #define HYDRORMPUTIL_DRIVERTHREAD_H 00003 00004 #include <hydroiceutil/subsystemthread.h> 00005 #include <hydrointerfaces/segwayrmp.h> 00006 #include <hydrorobotdriverutil/statemachine.h> 00007 #include <hydrormputil/stallsensor.h> 00008 00009 namespace hydrormputil { 00010 00011 class Callback { 00012 public: 00013 00014 virtual ~Callback() {} 00015 00017 virtual void hardwareInitialised()=0; 00019 virtual void receiveData( const hydrointerfaces::SegwayRmp::Data &data, 00020 StallType stallType ) = 0; 00021 }; 00022 00023 // 00024 // Note that this class derives from a SubsystemThread defined in libHydroIceUtil, 00025 // not the one from libOrcaIce. See documentation for differences. 00026 // 00027 // @author Alex Brooks 00028 // 00029 class DriverThread : public hydroiceutil::SubsystemThread 00030 { 00031 public: 00032 00034 00035 struct Config { 00036 // If set, the driverthread reverses the controls. 00037 bool driveInReverse; 00038 // Allows testing without fear of it taking off 00039 bool isMotionEnabled; 00040 00041 // These acceleration limits are enforced by the driverthread. 00042 double maxForwardAcceleration; 00043 double maxReverseAcceleration; 00044 00045 // For detection of stalls 00046 StallSensor::Config stallSensorConfig; 00047 }; 00048 00050 00051 DriverThread( const Config &config, 00052 hydrointerfaces::SegwayRmp &segwayRmp, 00053 gbxutilacfr::Tracer &tracer, 00054 gbxutilacfr::Status &status, 00055 Callback &callback, 00056 const std::string &name = "segwayRmpDriverThread" ) 00057 : hydroiceutil::SubsystemThread(tracer,status,name), 00058 callback_(callback), 00059 config_(config), 00060 segwayRmp_(segwayRmp), 00061 tracer_(tracer) 00062 {} 00063 00064 // from SubsystemThread 00065 virtual void initialise() {} 00066 virtual void work(); 00067 virtual void finalise() {} 00068 00069 void setDesiredSpeed( const hydrointerfaces::SegwayRmp::Command &command ); 00070 00071 const hydrorobotdriverutil::StateMachine &stateMachine() 00072 { return stateMachine_; } 00073 00074 private: 00075 00076 void enableHardware(); 00077 void operateHardware(); 00078 00079 // Stores incoming commands that need to be written to the hardware 00080 gbxiceutilacfr::Store<hydrointerfaces::SegwayRmp::Command> commandStore_; 00081 00082 hydrorobotdriverutil::StateMachine stateMachine_; 00083 00084 Callback &callback_; 00085 00086 Config config_; 00087 hydrointerfaces::SegwayRmp &segwayRmp_; 00088 gbxutilacfr::Tracer &tracer_; 00089 }; 00090 00091 } 00092 00093 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)