direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
laserSickS300.h
Go to the documentation of this file.
1 /*************************************************************************
2 * Copyright (C) Markus Knapp *
3 * www.direcs.de *
4 * *
5 * This file is part of direcs. *
6 * *
7 * direcs is free software: you can redistribute it and/or modify it *
8 * under the terms of the GNU General Public License as published *
9 * by the Free Software Foundation, version 3 of the License. *
10 * *
11 * direcs is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18 * *
19 *************************************************************************/
20 
21 #ifndef LASERSICKS300_H
22 #define LASERSICKS300_H
23 
24 #include <QtGlobal> // for Q_OS_* Makro!
25 #include <QObject>
26 #include <QDebug>
27 #include <QFile>
28 #include <QTime>
29 
30 
31 #include "direcsSerial.h"
32 
33 
38 class SickS300 : public QObject
39 {
40  Q_OBJECT
41 
42  public:
46  SickS300();
47 
51  ~SickS300();
52 
57  int setup();
58 
63  int readRequestTelegram();
64 
69  int readUnknownTelegram();
70 
74  void setDevicePort(QString serialPort);
75 
80  bool openComPort();
81 
86  int closeComPort();
87 
93  bool sendChar(unsigned char character);
94 
100  bool receiveChar(unsigned char *character);
101 
107  float getDistance(int angleIndex);
108 
109 
110  signals:
116  void message(QString text);
117 
118 
119  private:
121  int baudRate;
122  QString laserSerialPort;
123 
124  static const unsigned int LASERSAMPLES = 1082;
125  unsigned char scanData[LASERSAMPLES];
126 
127  static const float LASERMAXLENGTH = 2000;
128 
129  float distances[540]; // 540 is the maximum of this laserscanner, because we have 270 degrees at a resolution of 0.5
130 
131  static const bool ON = true;
132  static const bool OFF = false;
133 };
134 
135 #endif