[4] | 1 | // %flair:license{
|
---|
| 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %flair:license}
|
---|
| 5 | /*!
|
---|
| 6 | * \file HokuyoUTM30Lx.h
|
---|
| 7 | * \brief Classe intégrant le telemetre laser Hokuyo UTM 30lx
|
---|
| 8 | * \author César Richard, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 9 | * \date 2014/07/22
|
---|
| 10 | * \version 1.0
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef HOKUYOUTM30LX_H
|
---|
| 14 | #define HOKUYOUTM30LX_H
|
---|
| 15 |
|
---|
| 16 | #include <Thread.h>
|
---|
| 17 | #include <LaserRangeFinder.h>
|
---|
| 18 | #include <Mutex.h>
|
---|
| 19 |
|
---|
| 20 | #include <queue>
|
---|
| 21 | #include <vector>
|
---|
| 22 |
|
---|
| 23 | namespace flair
|
---|
| 24 | {
|
---|
| 25 | namespace core
|
---|
| 26 | {
|
---|
| 27 | class cvmatrix;
|
---|
| 28 | class FrameworkManager;
|
---|
| 29 | class SerialPort;
|
---|
| 30 | class Mutex;
|
---|
| 31 | }
|
---|
| 32 | namespace gui
|
---|
| 33 | {
|
---|
| 34 | class Tab;
|
---|
| 35 | class TabWidget;
|
---|
| 36 | class RangeFinderPlot;
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | namespace flair
|
---|
| 41 | {
|
---|
| 42 | namespace sensor
|
---|
| 43 | {
|
---|
| 44 | /*! \class HokuyoUTM30Lx
|
---|
| 45 | *
|
---|
| 46 | * \brief Classe intégrant le telemetre laser Hokuyo UTM 30lx
|
---|
| 47 | */
|
---|
| 48 | class HokuyoUTM30Lx : public core::Thread, public LaserRangeFinder
|
---|
| 49 | {
|
---|
| 50 | public:
|
---|
| 51 |
|
---|
| 52 | /*!
|
---|
| 53 | * \brief Constructor
|
---|
| 54 | *
|
---|
| 55 | * Construct a Hokuyo UTM30-Lx.
|
---|
| 56 | *
|
---|
| 57 | * \param parent parent
|
---|
| 58 | * \param name name
|
---|
| 59 | * \param serialport serialport
|
---|
| 60 | * \param priority priority of the Thread
|
---|
| 61 | */
|
---|
| 62 | HokuyoUTM30Lx(const core::FrameworkManager* parent,std::string name,core::SerialPort *serialport,uint8_t priority);
|
---|
| 63 | void getMesure(int startStep, int endStep,int clusterCount, int interval, int scanNumber=0);
|
---|
| 64 | core::cvmatrix* getDatas(void);
|
---|
| 65 |
|
---|
| 66 | /*!
|
---|
| 67 | * \brief Use default plot
|
---|
| 68 | *
|
---|
| 69 | */
|
---|
| 70 | void UseDefaultPlot(void);
|
---|
| 71 | /*!
|
---|
| 72 | * \brief Destructor
|
---|
| 73 | *
|
---|
| 74 | */
|
---|
| 75 | ~HokuyoUTM30Lx();
|
---|
| 76 |
|
---|
| 77 | private:
|
---|
| 78 | core::SerialPort *serialport;
|
---|
| 79 | core::Mutex* bufRetMut;
|
---|
| 80 | core::Mutex* sendingCmdMut;
|
---|
| 81 | gui::Tab* main_tab;
|
---|
| 82 | gui::TabWidget* tab;
|
---|
| 83 | gui::RangeFinderPlot* plot;
|
---|
| 84 |
|
---|
| 85 | //matrix
|
---|
| 86 | core::cvmatrix *output;
|
---|
| 87 |
|
---|
| 88 | std::queue<std::string> bufRet;
|
---|
| 89 |
|
---|
| 90 | /*!
|
---|
| 91 | * \brief Run function
|
---|
| 92 | *
|
---|
| 93 | * Reimplemented from Thread.
|
---|
| 94 | *
|
---|
| 95 | */
|
---|
| 96 | void Run(void);
|
---|
| 97 | /*!
|
---|
| 98 | * \brief Send a command
|
---|
| 99 | * \param command Command to send (see Hokuyo UTM 30-LX doc for more informations)
|
---|
| 100 | * \return Return code
|
---|
| 101 | */
|
---|
| 102 | std::string sendCommand(std::string command);
|
---|
| 103 | /*!
|
---|
| 104 | * \brief Start the laser
|
---|
| 105 | *
|
---|
| 106 | */
|
---|
| 107 | void startLaser(void);
|
---|
| 108 | /*!
|
---|
| 109 | * \brief Stop the laser
|
---|
| 110 | *
|
---|
| 111 | */
|
---|
| 112 | void stopLaser(void);
|
---|
| 113 | /*!
|
---|
| 114 | * \brief Stop and reset the laser's settings
|
---|
| 115 | *
|
---|
| 116 | */
|
---|
| 117 | void resetConfig(void);
|
---|
| 118 | /*!
|
---|
| 119 | * \brief Decode incomming datas
|
---|
| 120 | * \param datas Datas to decode
|
---|
| 121 | * \param startStep Set the first mesured point
|
---|
| 122 | * Decode mesured points from incoming datas and fill the output matrix
|
---|
| 123 | */
|
---|
| 124 | void decodeDatas(std::vector<std::string> datas, int startStep);
|
---|
| 125 | /*!
|
---|
| 126 | * \brief Explode a string into a vector
|
---|
| 127 | * \param str The string to explode
|
---|
| 128 | * \param delimiter The character separating elements
|
---|
| 129 | * \return A vector containing the elements
|
---|
| 130 | */
|
---|
| 131 | static std::vector<std::string> explode(const std::string str, char delimiter);
|
---|
| 132 | /*!
|
---|
| 133 | * \brief Calculate the checksum
|
---|
| 134 | * \param code Data from which calculate
|
---|
| 135 | * \param byte Data's size
|
---|
| 136 | * \return A character corresponding to the code's checksum
|
---|
| 137 | */
|
---|
| 138 | static int encodeSum(const char* code, int byte);
|
---|
| 139 | /*!
|
---|
| 140 | * \brief Check if a data correspond to its checksum
|
---|
| 141 | * \param data Datas to check
|
---|
| 142 | */
|
---|
| 143 | static bool checkSum(std::string data);
|
---|
| 144 | /*!
|
---|
| 145 | * \brief Decode datas using the 2 character encoding
|
---|
| 146 | * \param data Datas to decode
|
---|
| 147 | * \return Decoded datas
|
---|
| 148 | */
|
---|
| 149 | static float decode2car(const char* data);
|
---|
| 150 | /*!
|
---|
| 151 | * \brief Decode datas using the 3 character encoding
|
---|
| 152 | * \param data Datas to decode
|
---|
| 153 | * \return Decoded datas
|
---|
| 154 | */
|
---|
| 155 | static float decode3car(const char* data);
|
---|
| 156 | /*!
|
---|
| 157 | * \brief Decode datas using the 4 character encoding
|
---|
| 158 | * \param data Datas to decode
|
---|
| 159 | * \return Decoded datas
|
---|
| 160 | */
|
---|
| 161 | static float decode4car(const char* data);
|
---|
| 162 |
|
---|
| 163 | /*!
|
---|
| 164 | * \brief Update using provided datas
|
---|
| 165 | *
|
---|
| 166 | * Reimplemented from IODevice.
|
---|
| 167 | *
|
---|
| 168 | * \param data data from the parent to process
|
---|
| 169 | */
|
---|
| 170 | void UpdateFrom(const core::io_data *data){};
|
---|
| 171 |
|
---|
| 172 | };
|
---|
| 173 | } // end namespace sensor
|
---|
| 174 | } // end namespace framewor
|
---|
| 175 | #endif // HOKUYOUTM30LX_H
|
---|