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

 

         

bicycle/hwthread.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 BICYCLE_HARDWARE_THREAD_H
00012 #define BICYCLE_HARDWARE_THREAD_H
00013 
00014 #include <memory>
00015 #include <orcaice/subsystemthread.h>
00016 #include <orcaice/context.h>
00017 #include <hydrointerfaces/bicycle.h>
00018 #include <hydrodll/dynamicload.h>
00019 #include <gbxsickacfr/gbxiceutilacfr/store.h>
00020 #include <hydrorobotdriverutil/statemachine.h>
00021 
00022 namespace bicycle {
00023 
00024 //
00025 // @brief The thread that runs the driver
00026 //
00027 // @author Alex Brooks
00028 //
00029 class HwThread : public orcaice::SubsystemThread
00030 {
00031 
00032 public: 
00033 
00034     HwThread( const orcaice::Context &context );
00035 
00036     // local interface, used by NetThread
00037 
00038     void setCommand( const hydrointerfaces::Bicycle::Command &command );
00039 
00040     // read-only access to the last received command (through setCommand)
00041     // returns false if no command was received yet
00042     bool getLastCommand( hydrointerfaces::Bicycle::Command &command ) const;
00043 
00044     // gives access to the internal data store
00045     gbxiceutilacfr::Store<hydrointerfaces::Bicycle::Data> &dataStore()
00046         {
00047             return dataStore_;
00048         }
00049 
00050 private: 
00051     // from SubsystemThread
00052     virtual void work();
00053 
00054     // Keeps trying until success or isStopping()
00055     void enableDriver();
00056 
00057     // Faults can be detected in either read or write threads: have to be careful.
00058     hydrorobotdriverutil::StateMachine stateMachine_;
00059 
00060     // Stores the data most recently received from the hardware
00061     gbxiceutilacfr::Store<hydrointerfaces::Bicycle::Data>    dataStore_;
00062     // Stores incoming commands
00063     gbxiceutilacfr::Store<hydrointerfaces::Bicycle::Command> commandStore_;
00064 
00065     bool isMotionEnabled_;
00066 
00067     // The library that contains the driver factory (must be declared first so it's destructed last!!!)
00068     std::auto_ptr<hydrodll::DynamicallyLoadedLibrary> driverLib_;
00069     // Generic driver for the hardware
00070     std::auto_ptr<hydrointerfaces::Bicycle> driver_;
00071 
00072     orcaice::Context context_;
00073 };
00074 
00075 } // namespace
00076 
00077 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5