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
|
hydrointerfaces/segwayrmp.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_INTERFACES_SEGWAYRMP_H 00012 #define HYDRO_INTERFACES_SEGWAYRMP_H 00013 00014 #include <hydroutil/context.h> 00015 00016 namespace hydrointerfaces 00017 { 00018 00043 class SOEXPORT SegwayRmp 00044 { 00045 00046 public: 00047 00049 class Data 00050 { 00051 public: 00053 int seconds; 00055 int useconds; 00057 double x; 00059 double y; 00061 double roll; 00063 double pitch; 00065 double yaw; 00067 double vx; 00069 double droll; 00071 double dpitch; 00073 double dyaw; 00075 double leftTorque; 00077 double rightTorque; 00079 double mainvolt; 00081 double uivolt; 00082 00084 bool hasWarnings; 00086 bool hasFaults; 00088 std::string warnFaultReason; 00089 00091 std::string toString() const; 00092 }; 00093 00095 class Command 00096 { 00097 public: 00098 Command( double speed, double turnrate ) 00099 : vx(speed), w(turnrate) {} 00100 Command() {} 00101 00103 double vx; 00105 double w; 00106 00108 std::string toString() const; 00109 }; 00110 00112 class Capabilities 00113 { 00114 public: 00116 double maxForwardSpeed; 00118 double maxReverseSpeed; 00120 double maxTurnrate; 00122 double maxLateralAcceleration; 00123 00124 bool isSane() const; 00125 std::string toString() const; 00126 }; 00127 00128 virtual ~SegwayRmp() {} 00129 00135 virtual void enable()=0; 00136 00138 virtual void read( Data &data )=0; 00139 00141 virtual void write( const Command& command )=0; 00142 00144 virtual Capabilities capabilities() const=0; 00145 }; 00146 00148 class SOEXPORT SegwayRmpFactory { 00149 public: 00150 virtual ~SegwayRmpFactory() {}; 00152 virtual SegwayRmp *createDriver( const std::string &powerbaseName, const hydroutil::Context& context ) const=0; 00153 }; 00154 00155 // Streaming operators 00156 inline std::ostream &operator<<( std::ostream &s, const SegwayRmp::Data &data ) 00157 { return s << data.toString(); } 00158 inline std::ostream &operator<<( std::ostream &s, const SegwayRmp::Command &cmd ) 00159 { return s << cmd.toString(); } 00160 inline std::ostream &operator<<( std::ostream &s, const SegwayRmp::Capabilities &c ) 00161 { return s << c.toString(); } 00162 00165 void constrain( SegwayRmp::Capabilities &capabilities, 00166 const SegwayRmp::Capabilities &limits ); 00167 00168 bool operator==( const SegwayRmp::Capabilities &c1, const SegwayRmp::Capabilities &c2 ); 00169 00170 bool commandPossible( const hydrointerfaces::SegwayRmp::Command &cmd, 00171 const hydrointerfaces::SegwayRmp::Capabilities &capabilities ); 00172 00173 void limit( hydrointerfaces::SegwayRmp::Command &cmd, 00174 const hydrointerfaces::SegwayRmp::Capabilities &capabilities ); 00175 00177 } // namespace 00178 00179 // Function for dynamically instantiating drivers. 00180 // A driver must have a function like so: 00181 // extern "C" { 00182 // hydrointerfaces::SegwayRmpFactory *createSegwayRmpDriverFactory(); 00183 // } 00184 typedef hydrointerfaces::SegwayRmpFactory *SegwayRmpDriverFactoryMakerFunc(); 00185 00186 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)