ROME_P5
Dependencies: mbed
LIDAR.h@0:29be10cb0afc, 2018-04-27 (annotated)
- Committer:
- Inaueadr
- Date:
- Fri Apr 27 08:47:34 2018 +0000
- Revision:
- 0:29be10cb0afc
Hallo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Inaueadr | 0:29be10cb0afc | 1 | /* |
Inaueadr | 0:29be10cb0afc | 2 | * LIDAR.h |
Inaueadr | 0:29be10cb0afc | 3 | * Copyright (c) 2018, ZHAW |
Inaueadr | 0:29be10cb0afc | 4 | * All rights reserved. |
Inaueadr | 0:29be10cb0afc | 5 | */ |
Inaueadr | 0:29be10cb0afc | 6 | |
Inaueadr | 0:29be10cb0afc | 7 | #ifndef LIDAR_H_ |
Inaueadr | 0:29be10cb0afc | 8 | #define LIDAR_H_ |
Inaueadr | 0:29be10cb0afc | 9 | |
Inaueadr | 0:29be10cb0afc | 10 | #include <cstdlib> |
Inaueadr | 0:29be10cb0afc | 11 | #include <mbed.h> |
Inaueadr | 0:29be10cb0afc | 12 | |
Inaueadr | 0:29be10cb0afc | 13 | /** |
Inaueadr | 0:29be10cb0afc | 14 | * This is a device driver class for the Slamtec RP LIDAR A1. |
Inaueadr | 0:29be10cb0afc | 15 | */ |
Inaueadr | 0:29be10cb0afc | 16 | class LIDAR { |
Inaueadr | 0:29be10cb0afc | 17 | |
Inaueadr | 0:29be10cb0afc | 18 | public: |
Inaueadr | 0:29be10cb0afc | 19 | |
Inaueadr | 0:29be10cb0afc | 20 | LIDAR(RawSerial& serial); |
Inaueadr | 0:29be10cb0afc | 21 | virtual ~LIDAR(); |
Inaueadr | 0:29be10cb0afc | 22 | short getDistance(short angle); |
Inaueadr | 0:29be10cb0afc | 23 | short getDistanceOfBeacon(); |
Inaueadr | 0:29be10cb0afc | 24 | short getAngleOfBeacon(); |
Inaueadr | 0:29be10cb0afc | 25 | void lookForBeacon(); |
Inaueadr | 0:29be10cb0afc | 26 | |
Inaueadr | 0:29be10cb0afc | 27 | private: |
Inaueadr | 0:29be10cb0afc | 28 | |
Inaueadr | 0:29be10cb0afc | 29 | static const unsigned short HEADER_SIZE = 7; |
Inaueadr | 0:29be10cb0afc | 30 | static const unsigned short DATA_SIZE = 5; |
Inaueadr | 0:29be10cb0afc | 31 | |
Inaueadr | 0:29be10cb0afc | 32 | static const char START_FLAG = 0xA5; |
Inaueadr | 0:29be10cb0afc | 33 | static const char SCAN = 0x20; |
Inaueadr | 0:29be10cb0afc | 34 | static const char STOP = 0x25; |
Inaueadr | 0:29be10cb0afc | 35 | static const char RESET = 0x40; |
Inaueadr | 0:29be10cb0afc | 36 | |
Inaueadr | 0:29be10cb0afc | 37 | static const char QUALITY_THRESHOLD = 10; |
Inaueadr | 0:29be10cb0afc | 38 | static const short DISTANCE_THRESHOLD = 10; |
Inaueadr | 0:29be10cb0afc | 39 | static const short DEFAULT_DISTANCE = 10000; |
Inaueadr | 0:29be10cb0afc | 40 | static const short MIN_DISTANCE = 500; |
Inaueadr | 0:29be10cb0afc | 41 | static const short MAX_DISTANCE = 2000; |
Inaueadr | 0:29be10cb0afc | 42 | static const short THRESHOLD = 500; |
Inaueadr | 0:29be10cb0afc | 43 | static const short WINDOW = 75; |
Inaueadr | 0:29be10cb0afc | 44 | static const short MIN_SIZE = 2; |
Inaueadr | 0:29be10cb0afc | 45 | static const short MAX_SIZE = 9; |
Inaueadr | 0:29be10cb0afc | 46 | |
Inaueadr | 0:29be10cb0afc | 47 | RawSerial& serial; // reference to serial interface for communication |
Inaueadr | 0:29be10cb0afc | 48 | char headerCounter; |
Inaueadr | 0:29be10cb0afc | 49 | char dataCounter; |
Inaueadr | 0:29be10cb0afc | 50 | char data[DATA_SIZE]; |
Inaueadr | 0:29be10cb0afc | 51 | short distances[360]; // measured distance for every angle value, given in [mm] |
Inaueadr | 0:29be10cb0afc | 52 | short distanceOfBeacon; // distance of detected beacon, given in [mm] |
Inaueadr | 0:29be10cb0afc | 53 | short angleOfBeacon; // angle of detected beacon, given in [degrees] |
Inaueadr | 0:29be10cb0afc | 54 | short dist_copy[360]; |
Inaueadr | 0:29be10cb0afc | 55 | int dist_diff_start[10]; |
Inaueadr | 0:29be10cb0afc | 56 | int dist_diff_stop[10]; |
Inaueadr | 0:29be10cb0afc | 57 | int i; |
Inaueadr | 0:29be10cb0afc | 58 | int n; |
Inaueadr | 0:29be10cb0afc | 59 | int m; |
Inaueadr | 0:29be10cb0afc | 60 | int x; |
Inaueadr | 0:29be10cb0afc | 61 | int range; |
Inaueadr | 0:29be10cb0afc | 62 | bool changed; |
Inaueadr | 0:29be10cb0afc | 63 | short min; |
Inaueadr | 0:29be10cb0afc | 64 | short max; |
Inaueadr | 0:29be10cb0afc | 65 | |
Inaueadr | 0:29be10cb0afc | 66 | |
Inaueadr | 0:29be10cb0afc | 67 | void receive(); |
Inaueadr | 0:29be10cb0afc | 68 | }; |
Inaueadr | 0:29be10cb0afc | 69 | |
Inaueadr | 0:29be10cb0afc | 70 | #endif /* LIDAR_H_ */ |
Inaueadr | 0:29be10cb0afc | 71 |