Nim leo niiiim

Committer:
Kiwicjam
Date:
Fri May 11 12:21:19 2018 +0000
Revision:
0:da791f233257
start of rome2 p5;

Who changed what in which revision?

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