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
|
robot2d/hwthread.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 ROBOT2D_HARDWARE_THREAD_H 00012 #define ROBOT2D_HARDWARE_THREAD_H 00013 00014 #include <memory> 00015 #include <orcaice/subsystemthread.h> 00016 #include <orcaice/context.h> 00017 #include <hydrointerfaces/robot2d.h> 00018 #include <hydrodll/dynamicload.h> 00019 #include <gbxsickacfr/gbxiceutilacfr/store.h> 00020 #include <hydrorobotdriverutil/statemachine.h> 00021 00022 namespace robot2d { 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::Robot2d::Command &command ); 00039 00040 // Return valus same as gbxiceutilacfr::Store. 00041 int getData( hydrointerfaces::Robot2d::Data &data, int timeoutMs ) 00042 { 00043 return dataStore_.getNext( data, timeoutMs ); 00044 } 00045 00046 private: 00047 // from SubsystemThread 00048 virtual void work(); 00049 00050 // Keeps trying until success or isStopping() 00051 void enableDriver(); 00052 00053 // Faults can be detected in either read or write threads: have to be careful. 00054 hydrorobotdriverutil::StateMachine stateMachine_; 00055 00056 // Stores the data most recently received from the hardware 00057 gbxiceutilacfr::Store<hydrointerfaces::Robot2d::Data> dataStore_; 00058 // Stores incoming commands 00059 gbxiceutilacfr::Store<hydrointerfaces::Robot2d::Command> commandStore_; 00060 00061 bool isMotionEnabled_; 00062 00063 // The library that contains the driver factory (must be declared first so it's destructed last!!!) 00064 std::auto_ptr<hydrodll::DynamicallyLoadedLibrary> driverLib_; 00065 // Generic driver for the hardware 00066 std::auto_ptr<hydrointerfaces::Robot2d> driver_; 00067 00068 orcaice::Context context_; 00069 }; 00070 00071 } // namespace 00072 00073 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)