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

 

         

pathfollowerinterface.h

00001 #ifndef LOCALNAV_PATHFOLLOWERINTERFACE_H
00002 #define LOCALNAV_PATHFOLLOWERINTERFACE_H
00003 
00004 #include <orcaifaceimpl/pathfollower2d.h>
00005 #include <orcalocalnav/clock.h>
00006 
00007 namespace orcalocalnav {
00008 
00009 //
00010 // @brief Implements the orca::PathFollower2d interface.
00011 //        Basically we just wrap up an orcaifaceimpl version, but since this interface is special
00012 //        we have to add a few things.
00013 //
00014 // @author Alex Brooks
00015 //
00016 class PathFollowerInterface : public orcaifaceimpl::AbstractPathFollowerCallback
00017 {
00018 
00019 public: 
00020 
00021     PathFollowerInterface( const orcalocalnav::Clock &clock,
00022                            const std::string         &interfaceTag,
00023                            const orcaice::Context    &context );
00024 
00025     void initInterface();
00026     void initInterface( gbxutilacfr::Stoppable* activity, const std::string& subsysName="", int retryInterval=2 );
00027 
00028     // Allow localnav's internals to increment the waypoint index
00029     void updateActivationStateAndWaypointIndex( orca::PathActivationEnum activationState,
00030                                                 int                      waypointIndex );
00031     // Allow component internals to check for pending requests.
00032     // Sets pathData on _either_ gotNewPath or gotPathActivation.
00033     void serviceRequests( bool                     &gotNewPath,
00034                           bool                     &gotPathActivation,
00035                           orca::PathFollower2dData &pathData,
00036                           orca::Time               &pathStartTime );
00037 
00038     // From orcaifaceimpl::PathFollowerCallback
00039     virtual void setData( const orca::PathFollower2dData &pathData, bool activateImmediately );
00040     virtual void activateNow();
00041     virtual orca::PathFollower2dState getState();
00042     virtual void setEnabled( bool enabled );
00043     virtual bool enabled();
00044 
00045 private: 
00046 
00047     // Holds new requests from the outside world till we poll for them in another thread.
00048     // Thread-safe
00049     class NewlyArrivedRequestStore {
00050     public:
00051         NewlyArrivedRequestStore()
00052             : haveNewPath_(false),
00053               havePendingActivationRequest_(false)
00054             {}
00055         
00056         // Set functions
00057         void addPathRequest( const orca::PathFollower2dData &pathData, bool activateImmediately );
00058         void addActivationRequest();
00059 
00060         // Get function (we remember what's gotten, only giving it out once)
00061         void get( bool &newPathArrived,
00062                   bool &activationArrived,
00063                   orca::PathFollower2dData &pathData );
00064 
00065     private:
00066         // New paths from the outside world go in here
00067         std::auto_ptr<orca::PathFollower2dData> pendingPathRequest_;
00068         bool haveNewPath_;
00069         bool havePendingActivationRequest_;
00070 
00071         IceUtil::Mutex mutex_;
00072     };
00073     
00074     NewlyArrivedRequestStore newlyArrivedRequestStore_;
00075 
00076     orcaifaceimpl::PathFollower2dImplPtr pathFollower2dImpl_;
00077 
00078     orca::PathFollower2dState  pathFollower2dState_;
00079     orca::Time                 activationTime_;
00080     const orcalocalnav::Clock &clock_;
00081     
00082     // Protects our data
00083     IceUtil::Mutex mutex_;
00084 
00085     orcaice::Context context_;
00086 };
00087 
00088 }
00089 
00090 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5