rome2_p6 imported

Dependencies:   mbed

Committer:
Appalco
Date:
Fri May 18 13:54:25 2018 +0000
Revision:
5:957580f33e52
Parent:
0:351a2fb21235
fixed tolerance and wayponts

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Appalco 0:351a2fb21235 1 /*
Appalco 0:351a2fb21235 2 * LIDAR.h
Appalco 0:351a2fb21235 3 * Copyright (c) 2018, ZHAW
Appalco 0:351a2fb21235 4 * All rights reserved.
Appalco 0:351a2fb21235 5 */
Appalco 0:351a2fb21235 6
Appalco 0:351a2fb21235 7 #ifndef LIDAR_H_
Appalco 0:351a2fb21235 8 #define LIDAR_H_
Appalco 0:351a2fb21235 9
Appalco 0:351a2fb21235 10 #include <cstdlib>
Appalco 0:351a2fb21235 11 #include <mbed.h>
Appalco 0:351a2fb21235 12
Appalco 0:351a2fb21235 13 /**
Appalco 0:351a2fb21235 14 * This is a device driver class for the Slamtec RP LIDAR A1.
Appalco 0:351a2fb21235 15 */
Appalco 0:351a2fb21235 16 class LIDAR {
Appalco 0:351a2fb21235 17
Appalco 0:351a2fb21235 18 public:
Appalco 0:351a2fb21235 19
Appalco 0:351a2fb21235 20 LIDAR(RawSerial& serial);
Appalco 0:351a2fb21235 21 virtual ~LIDAR();
Appalco 0:351a2fb21235 22 short getDistance(short angle);
Appalco 0:351a2fb21235 23 short getDistanceOfBeacon();
Appalco 0:351a2fb21235 24 short getAngleOfBeacon();
Appalco 0:351a2fb21235 25 void lookForBeacon();
Appalco 0:351a2fb21235 26
Appalco 0:351a2fb21235 27 private:
Appalco 0:351a2fb21235 28
Appalco 0:351a2fb21235 29 static const unsigned short HEADER_SIZE = 7;
Appalco 0:351a2fb21235 30 static const unsigned short DATA_SIZE = 5;
Appalco 0:351a2fb21235 31
Appalco 0:351a2fb21235 32 static const char START_FLAG = 0xA5;
Appalco 0:351a2fb21235 33 static const char SCAN = 0x20;
Appalco 0:351a2fb21235 34 static const char STOP = 0x25;
Appalco 0:351a2fb21235 35 static const char RESET = 0x40;
Appalco 0:351a2fb21235 36
Appalco 0:351a2fb21235 37 static const char QUALITY_THRESHOLD = 10;
Appalco 0:351a2fb21235 38 static const short DISTANCE_THRESHOLD = 10;
Appalco 0:351a2fb21235 39 static const short DEFAULT_DISTANCE = 10000;
Appalco 0:351a2fb21235 40 static const short MIN_DISTANCE = 500;
Appalco 0:351a2fb21235 41 static const short MAX_DISTANCE = 2000;
Appalco 0:351a2fb21235 42 static const short THRESHOLD = 500;
Appalco 0:351a2fb21235 43 static const short WINDOW = 75;
Appalco 0:351a2fb21235 44 static const short MIN_SIZE = 2;
Appalco 0:351a2fb21235 45 static const short MAX_SIZE = 9;
Appalco 0:351a2fb21235 46
Appalco 0:351a2fb21235 47 RawSerial& serial; // reference to serial interface for communication
Appalco 0:351a2fb21235 48 char headerCounter;
Appalco 0:351a2fb21235 49 char dataCounter;
Appalco 0:351a2fb21235 50 char data[DATA_SIZE];
Appalco 0:351a2fb21235 51 short distances[360]; // measured distance for every angle value, given in [mm]
Appalco 0:351a2fb21235 52 short distanceOfBeacon; // distance of detected beacon, given in [mm]
Appalco 0:351a2fb21235 53 short angleOfBeacon; // angle of detected beacon, given in [degrees]
Appalco 0:351a2fb21235 54 bool lookClockwise; // flag to indicate direction of search algorithm
Appalco 0:351a2fb21235 55
Appalco 0:351a2fb21235 56 void receive();
Appalco 0:351a2fb21235 57 };
Appalco 0:351a2fb21235 58
Appalco 0:351a2fb21235 59 #endif /* LIDAR_H_ */
Appalco 0:351a2fb21235 60