INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

gbxsickacfr/driver.h

00001 /*
00002  * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
00003  *               http://gearbox.sf.net/
00004  * Copyright (c) 2004-2010 Alex Brooks
00005  *
00006  * This distribution is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef GBX_SICK_ACFR_H
00012 #define GBX_SICK_ACFR_H
00013 
00014 #include <gbxsickacfr/serialhandler.h>
00015 #include <gbxutilacfr/tracer.h>
00016 #include <gbxutilacfr/status.h>
00017 #include <memory>
00018 
00019 namespace gbxsickacfr {
00020 
00022 class Config
00023 {   
00024 public:
00025     Config();
00026     bool isValid() const;
00027     std::string toString() const;
00028     bool operator==( const Config & other );
00029     bool operator!=( const Config & other );
00030 
00032     std::string device;
00034     int baudRate;
00036     double minRange;
00038     double maxRange;
00040     double fieldOfView;
00042     double startAngle;
00044     int    numberOfSamples;
00045 };
00046 
00048 class Data
00049 {
00050 public:
00051     Data()
00052         : haveWarnings(false)
00053         {}
00054 
00055     float         *ranges;
00056     unsigned char *intensities;
00057     int            timeStampSec;
00058     int            timeStampUsec;
00059     bool           haveWarnings;
00061     std::string    warnings;
00062 };
00063 
00065 class Driver
00066 {
00067 
00068 public: 
00069 
00075     Driver( const Config        &config,
00076             gbxutilacfr::Tracer &tracer,
00077             gbxutilacfr::Status &status );
00078 
00086     void read( Data &data );
00087 
00088 private: 
00089 
00090     // Waits up to maxWaitMs for a rxMsg of a particular type.
00091     // Returns true iff it got the rxMsg it wanted.
00092     bool waitForRxMsgType( uChar type, TimedLmsRxMsg &rxMsg, int maxWaitMs );
00093     // Returns: true if ack or nack received.
00094     // (and sets receivedAck: true = ACK, false=NACK)
00095     bool waitForAckOrNack( bool &receivedAck );
00096 
00097     LmsRxMsgPtr askLaserForStatusData();
00098     LmsRxMsgPtr askLaserForConfigData();
00099 
00100     LmsConfigurationData desiredConfiguration();
00101     bool isAsDesired( const LmsConfigurationData &lmsConfig );
00102 
00103     int guessLaserBaudRate();
00104 
00105     // Connects to the laser, sets params, and starts continuous mode.
00106     void initLaser();
00107 
00108     TimedLmsRxMsg sendAndExpectRxMsg( const std::vector<uChar> &commandAndData,
00109                                       bool ignoreErrorConditions=false );
00110 
00111     std::string errorConditions();
00112 
00113     uChar desiredMeasuredValueUnit();
00114     uint16_t desiredAngularResolution();
00115 
00116     void setBaudRate( int baudRate );
00117 
00118     Config config_;
00119 
00120     std::auto_ptr<SerialHandler> serialHandler_;
00121 
00122     std::vector<uChar> commandAndData_;
00123     std::vector<uChar> telegramBuffer_;
00124 
00125     gbxutilacfr::Tracer& tracer_;
00126     gbxutilacfr::Status& status_;
00127 };
00128 
00129 } // namespace
00130 
00131 #endif
 

Generated for GearBox by  doxygen 1.4.5