source: flair-src/trunk/lib/FlairSensorActuator/src/HokuyoUTM30Lx.h@ 137

Last change on this file since 137 was 137, checked in by Sanahuja Guillaume, 6 years ago

singleton manager

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