Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
LIDAR.h@0:d87b2f1196e7, 2018-04-20 (annotated)
- Committer:
- kueenste
- Date:
- Fri Apr 20 13:49:49 2018 +0000
- Revision:
- 0:d87b2f1196e7
- Child:
- 1:f4b2dde3fa3a
P5 Fertig
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kueenste | 0:d87b2f1196e7 | 1 | /* |
| kueenste | 0:d87b2f1196e7 | 2 | * LIDAR.h |
| kueenste | 0:d87b2f1196e7 | 3 | * Copyright (c) 2018, ZHAW |
| kueenste | 0:d87b2f1196e7 | 4 | * All rights reserved. |
| kueenste | 0:d87b2f1196e7 | 5 | */ |
| kueenste | 0:d87b2f1196e7 | 6 | |
| kueenste | 0:d87b2f1196e7 | 7 | #ifndef LIDAR_H_ |
| kueenste | 0:d87b2f1196e7 | 8 | #define LIDAR_H_ |
| kueenste | 0:d87b2f1196e7 | 9 | |
| kueenste | 0:d87b2f1196e7 | 10 | #include <cstdlib> |
| kueenste | 0:d87b2f1196e7 | 11 | #include <mbed.h> |
| kueenste | 0:d87b2f1196e7 | 12 | |
| kueenste | 0:d87b2f1196e7 | 13 | /** |
| kueenste | 0:d87b2f1196e7 | 14 | * This is a device driver class for the Slamtec RP LIDAR A1. |
| kueenste | 0:d87b2f1196e7 | 15 | */ |
| kueenste | 0:d87b2f1196e7 | 16 | class LIDAR { |
| kueenste | 0:d87b2f1196e7 | 17 | |
| kueenste | 0:d87b2f1196e7 | 18 | public: |
| kueenste | 0:d87b2f1196e7 | 19 | |
| kueenste | 0:d87b2f1196e7 | 20 | LIDAR(RawSerial& serial); |
| kueenste | 0:d87b2f1196e7 | 21 | virtual ~LIDAR(); |
| kueenste | 0:d87b2f1196e7 | 22 | short getDistance(short angle); |
| kueenste | 0:d87b2f1196e7 | 23 | short getDistanceOfBeacon(); |
| kueenste | 0:d87b2f1196e7 | 24 | short getAngleOfBeacon(); |
| kueenste | 0:d87b2f1196e7 | 25 | void lookForBeacon(int direction); |
| kueenste | 0:d87b2f1196e7 | 26 | |
| kueenste | 0:d87b2f1196e7 | 27 | private: |
| kueenste | 0:d87b2f1196e7 | 28 | |
| kueenste | 0:d87b2f1196e7 | 29 | static const unsigned short HEADER_SIZE = 7; |
| kueenste | 0:d87b2f1196e7 | 30 | static const unsigned short DATA_SIZE = 5; |
| kueenste | 0:d87b2f1196e7 | 31 | |
| kueenste | 0:d87b2f1196e7 | 32 | static const char START_FLAG = 0xA5; |
| kueenste | 0:d87b2f1196e7 | 33 | static const char SCAN = 0x20; |
| kueenste | 0:d87b2f1196e7 | 34 | static const char STOP = 0x25; |
| kueenste | 0:d87b2f1196e7 | 35 | static const char RESET = 0x40; |
| kueenste | 0:d87b2f1196e7 | 36 | |
| kueenste | 0:d87b2f1196e7 | 37 | static const char QUALITY_THRESHOLD = 10; |
| kueenste | 0:d87b2f1196e7 | 38 | static const short DISTANCE_THRESHOLD = 10; |
| kueenste | 0:d87b2f1196e7 | 39 | static const short DEFAULT_DISTANCE = 10000; |
| kueenste | 0:d87b2f1196e7 | 40 | static const short MIN_DISTANCE = 500; |
| kueenste | 0:d87b2f1196e7 | 41 | static const short MAX_DISTANCE = 2000; |
| kueenste | 0:d87b2f1196e7 | 42 | static const short THRESHOLD = 500; |
| kueenste | 0:d87b2f1196e7 | 43 | static const short WINDOW = 75; |
| kueenste | 0:d87b2f1196e7 | 44 | static const short MIN_SIZE = 2; |
| kueenste | 0:d87b2f1196e7 | 45 | static const short MAX_SIZE = 9; |
| kueenste | 0:d87b2f1196e7 | 46 | |
| kueenste | 0:d87b2f1196e7 | 47 | RawSerial& serial; // reference to serial interface for communication |
| kueenste | 0:d87b2f1196e7 | 48 | char headerCounter; |
| kueenste | 0:d87b2f1196e7 | 49 | char dataCounter; |
| kueenste | 0:d87b2f1196e7 | 50 | char data[DATA_SIZE]; |
| kueenste | 0:d87b2f1196e7 | 51 | short distances[360]; // measured distance for every angle value, given in [mm] |
| kueenste | 0:d87b2f1196e7 | 52 | short distanceOfBeacon; // distance of detected beacon, given in [mm] |
| kueenste | 0:d87b2f1196e7 | 53 | short angleOfBeacon; // angle of detected beacon, given in [degrees] |
| kueenste | 0:d87b2f1196e7 | 54 | |
| kueenste | 0:d87b2f1196e7 | 55 | void receive(); |
| kueenste | 0:d87b2f1196e7 | 56 | }; |
| kueenste | 0:d87b2f1196e7 | 57 | |
| kueenste | 0:d87b2f1196e7 | 58 | #endif /* LIDAR_H_ */ |
| kueenste | 0:d87b2f1196e7 | 59 |