orca-robotics


INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

REPOSITORY
Interfaces
Components
Libraries
Utilities
Software Map

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard
Wiki
login/pass: orca/orca

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

segwayrmp/hwthread.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2008 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 SEGWAYRMP_HARDWARE_THREAD_H
00012 #define SEGWAYRMP_HARDWARE_THREAD_H
00013 
00014 #include <memory>
00015 #include <orcaice/subsystemthread.h>
00016 #include <orcaice/context.h>
00017 #include <hydrointerfaces/segwayrmp.h>
00018 #include <hydrodll/dynamicload.h>
00019 
00020 #include <gbxsickacfr/gbxiceutilacfr/store.h>
00021 #include <orcarobotdriverutil/statemachine.h>
00022 #include <gbxsickacfr/gbxiceutilacfr/timer.h>
00023 #include "estopinterface.h"
00024 #include "setpoint.h"
00025 
00026 namespace segwayrmp {
00027 
00028 
00029 //
00030 // @brief The thread that runs the driver
00031 //
00032 // @author Alex Brooks
00033 //
00034 class HwThread : public orcaice::SubsystemThread
00035 {
00036 
00037 public: 
00038 
00039     // this is a subset of configuration parameters which is checked by the hardware driver
00040     struct Config
00041     {
00042         double maxForwardSpeed;
00043         double maxReverseSpeed;
00044         double maxTurnrate;
00045         double maxForwardAcceleration;
00046         double maxReverseAcceleration;
00047         double maxLateralAcceleration;
00048     };
00049 
00050     // these config settings are checked and possibly limited based on hardware capabilities
00051     HwThread( Config& config, const orcaice::Context &context );
00052 
00053     // local interface, used by NetThread
00054 
00055     // used by NetThread to pass commands, events and get data
00056     void setCommand( const hydrointerfaces::SegwayRmp::Command &command );
00057 
00058     int getData( hydrointerfaces::SegwayRmp::Data &data, int timeoutMs )
00059         {
00060             return dataStore_.getNext( data, timeoutMs );
00061         }
00062 
00063 private: 
00064 
00065     // from SubsystemThread
00066     virtual void work();
00067 
00068     // Keeps trying until success or isStopping()
00069     void enableDriver();
00070     void writeCommand( hydrointerfaces::SegwayRmp::Command &command );
00071 
00072     // Checks with the driver, and sets the stateMachine_ accordingly.
00073     void checkStatus();
00074 
00075     // Faults can be detected in either read or write threads: have to be careful.
00076     orcarobotdriverutil::StateMachine stateMachine_;
00077 
00078     // Stores the data most recently received from the hardware
00079     gbxiceutilacfr::Store<hydrointerfaces::SegwayRmp::Data>    dataStore_;
00080     // Stores incoming commands
00081     gbxiceutilacfr::Store<hydrointerfaces::SegwayRmp::Command> commandStore_;
00082 
00083     bool isMotionEnabled_;
00084     bool driveInReverse_;
00085 
00086     std::auto_ptr<EStopInterface> estopInterface_;
00087     std::auto_ptr<SetPoint> speedSetPoint_;
00088 
00089     // Looks for late writes (which will cause timeouts in the segway)
00090     gbxiceutilacfr::Timer writeTimer_;
00091 
00092     // The library that contains the driver factory (must be declared first so it's destructed last!!!)
00093     std::auto_ptr<hydrodll::DynamicallyLoadedLibrary> driverLib_;
00094     // Generic driver for the hardware
00095     std::auto_ptr<hydrointerfaces::SegwayRmp> driver_;
00096 
00097     orcaice::Context context_;
00098 };
00099 
00100 } // namespace
00101 
00102 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5