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