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
|
hydrodrivers/hydrosegwayrmpacfr/driver.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef HYDRO_SEGWAYRMP_ACFR_H 00012 #define HYDRO_SEGWAYRMP_ACFR_H 00013 00014 #include <hydrointerfaces/segwayrmp.h> 00015 #include "rmpdriverconfig.h" 00016 #include "rmpio.h" 00017 #include "rxdata.h" 00018 #include "unitconverter.h" 00019 #include <memory> 00020 00021 namespace segwayrmpacfr 00022 { 00023 00024 // 00025 // Knows how to talk Segway's protocol. 00026 // 00027 // All public member functions throw exceptions on error conditions. 00028 // 00029 class Driver : public hydrointerfaces::SegwayRmp 00030 { 00031 public: 00032 00033 Driver( const std::string &powerbaseName, const hydroutil::Context& context ); 00034 virtual ~Driver(); 00035 00036 // from SegwayRmp 00037 virtual void enable(); 00038 virtual void read( Data& data ); 00039 virtual void write( const Command& command ); 00040 virtual hydrointerfaces::SegwayRmp::Capabilities capabilities() const; 00041 00042 // Custom method 00043 // Shuts down the motors 00044 void shutdown(); 00045 00046 private: 00047 00048 void setMaxVelocityScaleFactor( double scale ); 00049 void setMaxTurnrateScaleFactor( double scale ); 00050 void setMaxAccelerationScaleFactor( double scale ); 00051 void setMaxCurrentLimitScaleFactor( double scale ); 00052 void resetAllIntegrators(); 00053 00054 void setGainSchedule( int sched ); 00055 void enableBalanceMode( bool enable ); 00056 00057 double maxSpeed() const; 00058 // max turnrate depends on the speed 00059 double maxTurnrate( double speed ) const; 00060 00061 void applyScaling( const Command& original, Command &scaledCommand ); 00062 00063 // Checks that we're allowed to command the RMP in this operational mode (balance/tractor). 00064 // Throws exceptions if we're trying to do the wrong thing. 00065 void checkOperationalMode(); 00066 00067 // Reads a set of CAN packets, returns the result 00068 RxData readData(); 00069 void calculateIntegratedOdometry( const RxData &prevData, const RxData &thisData ); 00070 // fills up the Data class (understood externally) 00071 Data getData(); 00072 00073 void sendMotionCommandPacket( const Command& command ); 00074 void sendStatusCommandPacket( ConfigurationCommand commandId, uint16_t param ); 00075 00076 // The RMP reports its last received command. Check that this is what we sent. 00077 void checkReceivedCommand( const RxData &rxData ); 00078 00079 // Configuration 00080 RmpDriverConfig config_; 00081 00082 // driver/hardware interface 00083 std::auto_ptr<RmpIo> rmpIo_; 00084 00085 // integrated odometry (in SI units) 00086 double odomX_; 00087 double odomY_; 00088 double odomYaw_; 00089 00090 // Converts between units 00091 std::auto_ptr<UnitConverter> converter_; 00092 00093 // Most-recently-received data 00094 std::auto_ptr<RxData> rxData_; 00095 00096 // For logging CAN data for debugging 00097 std::auto_ptr<std::ofstream> canDataFile_; 00098 00099 const std::string powerbaseName_; 00100 00101 hydroutil::Context context_; 00102 }; 00103 00104 // Used for dynamically loading driver 00105 class Factory : public hydrointerfaces::SegwayRmpFactory 00106 { 00107 public: 00108 hydrointerfaces::SegwayRmp* 00109 createDriver( const std::string &powerbaseName, const hydroutil::Context &context ) const 00110 { 00111 return new Driver( powerbaseName, context ); 00112 } 00113 }; 00114 00115 } // namespace 00116 00117 // Used for dynamically loading driver 00118 extern "C" { 00119 hydrointerfaces::SegwayRmpFactory *createSegwayRmpDriverFactory(); 00120 } 00121 00122 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)