ROME 2 Lab5

Committer:
oehlemar
Date:
Tue Apr 28 13:59:27 2020 +0000
Revision:
0:893a1e710078
initial publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
oehlemar 0:893a1e710078 1 /*
oehlemar 0:893a1e710078 2 * LIDAR.h
oehlemar 0:893a1e710078 3 * Copyright (c) 2020, ZHAW
oehlemar 0:893a1e710078 4 * All rights reserved.
oehlemar 0:893a1e710078 5 */
oehlemar 0:893a1e710078 6
oehlemar 0:893a1e710078 7 #ifndef LIDAR_H_
oehlemar 0:893a1e710078 8 #define LIDAR_H_
oehlemar 0:893a1e710078 9
oehlemar 0:893a1e710078 10 #include <cstdlib>
oehlemar 0:893a1e710078 11 #include <deque>
oehlemar 0:893a1e710078 12 #include <mbed.h>
oehlemar 0:893a1e710078 13 #include "Point.h"
oehlemar 0:893a1e710078 14
oehlemar 0:893a1e710078 15 /**
oehlemar 0:893a1e710078 16 * This is a device driver class for the Slamtec RP LIDAR A1.
oehlemar 0:893a1e710078 17 */
oehlemar 0:893a1e710078 18 class LIDAR {
oehlemar 0:893a1e710078 19
oehlemar 0:893a1e710078 20 public:
oehlemar 0:893a1e710078 21
oehlemar 0:893a1e710078 22 LIDAR(RawSerial& serial);
oehlemar 0:893a1e710078 23 virtual ~LIDAR();
oehlemar 0:893a1e710078 24 deque<Point> getScan();
oehlemar 0:893a1e710078 25 deque<Point> getBeacons();
oehlemar 0:893a1e710078 26
oehlemar 0:893a1e710078 27 private:
oehlemar 0:893a1e710078 28
oehlemar 0:893a1e710078 29 static const unsigned short HEADER_SIZE = 7;
oehlemar 0:893a1e710078 30 static const unsigned short DATA_SIZE = 5;
oehlemar 0:893a1e710078 31
oehlemar 0:893a1e710078 32 static const char START_FLAG = 0xA5;
oehlemar 0:893a1e710078 33 static const char SCAN = 0x20;
oehlemar 0:893a1e710078 34 static const char STOP = 0x25;
oehlemar 0:893a1e710078 35 static const char RESET = 0x40;
oehlemar 0:893a1e710078 36
oehlemar 0:893a1e710078 37 static const char QUALITY_THRESHOLD = 10; // quality threshold used for accepting measurements
oehlemar 0:893a1e710078 38 static const float DISTANCE_THRESHOLD; // threshold for measured distance, given in [m]
oehlemar 0:893a1e710078 39 static const float DEFAULT_DISTANCE; // default distance > range of sensor, given in [m]
oehlemar 0:893a1e710078 40 static const float M_PI; // the mathematical constant PI
oehlemar 0:893a1e710078 41 static const float DISTANCES[]; // simulated distance for every angle value, given in [m]
oehlemar 0:893a1e710078 42
oehlemar 0:893a1e710078 43 RawSerial& serial; // reference to serial interface for communication
oehlemar 0:893a1e710078 44 char headerCounter;
oehlemar 0:893a1e710078 45 char dataCounter;
oehlemar 0:893a1e710078 46 char data[DATA_SIZE];
oehlemar 0:893a1e710078 47 float distances[360]; // measured distance for every angle value, given in [m]
oehlemar 0:893a1e710078 48 bool simulation; // flag to indicate if scans are only simulated
oehlemar 0:893a1e710078 49
oehlemar 0:893a1e710078 50 void receive();
oehlemar 0:893a1e710078 51 };
oehlemar 0:893a1e710078 52
oehlemar 0:893a1e710078 53 #endif /* LIDAR_H_ */
oehlemar 0:893a1e710078 54