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

SourceForge.net Logo
Project
Download
Mailing lists

 

         

hydrodrivers/hydrobicycleplayerclient/driver.h

00001 /*
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_BICYCLE_PLAYER_CLIENT_H
00012 #define HYDRO_BICYCLE_PLAYER_CLIENT_H
00013 
00014 #include <hydrointerfaces/bicycle.h>
00015 #include <memory>
00016 
00017 // Player proxies
00018 namespace PlayerCc
00019 {
00020 class PlayerClient;
00021 class Position2dProxy;
00022 class Position1dProxy;
00023 }
00024 
00025 namespace bicycleplayerclient
00026 {
00027 
00028 class Driver : public hydrointerfaces::Bicycle
00029 {
00030 public:
00031 
00032     Driver( const hydroutil::Context& context );
00033     virtual ~Driver();
00034 
00035     // from Bicycle
00036     virtual void enable();
00037     virtual bool read( Data& data );
00038     virtual void write( const Command& command );
00039     virtual void getStatus( std::string &status, bool &isWarn, bool &isFault );
00040 
00041 private:
00042     //
00043     // Convenience structure to hold all the config parameters.
00044     // All units are S.I.
00045     //
00046     class Config 
00047     {
00048     public:
00049         Config();
00050     
00051         const char *host;
00052         int port;
00053         bool usePlayerTimestamp;
00054         int position2dIndex;
00055         int position1dIndex; // -1 if not used
00056         
00057         // the following parameter is used when position1dIndex = -1
00058 
00059         // if set to non-zero, the driver simulates a maximum steer angle rate
00060         // in the commands sent to Player, which is useful under Stage, given
00061         // that carlike models repond immediately to steer angle commands
00062         double simulatedMaxSteerAngleRate;
00063     
00064         void fromProperties( const hydroutil::Properties& props );
00065         std::string toString();
00066     };
00067 
00068     virtual void disable();
00069 
00070     bool enabled_;
00071     std::auto_ptr<PlayerCc::PlayerClient> robot_;
00072     std::auto_ptr<PlayerCc::Position2dProxy> positionProxy_;
00073     
00074     // additional proxy to obtain current steer angle from Player (optional)
00075     std::auto_ptr<PlayerCc::Position1dProxy> currentSteerAngleProxy_;
00076 
00077     // if no proxy is available to obtain real steer angles, just simulate it
00078     double simulatedCurrentSteerAngle_;
00079     double simulatedCurrentSteerAngleTimestamp_; // in seconds
00080     double simulatedTargetSteerAngle_;
00081 
00082     // configuration
00083     Config config_;
00084     
00085     hydroutil::Context context_;
00086 };
00087 
00088 // Used for dynamically loading driver
00089 class Factory : public hydrointerfaces::BicycleFactory
00090 {
00091 public:
00092     hydrointerfaces::Bicycle *createDriver( const hydroutil::Context &context ) const
00093     {
00094         return new Driver( context );
00095     }
00096 };
00097 
00098 } // namespace
00099 
00100 // Used for dynamically loading driver
00101 extern "C" {
00102     hydrointerfaces::BicycleFactory *createBicycleDriverFactory();
00103 }
00104 
00105 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5