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.
LIDAR.h
00001 /* 00002 * LIDAR.h 00003 * Copyright (c) 2018, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #ifndef LIDAR_H_ 00008 #define LIDAR_H_ 00009 00010 #include <cstdlib> 00011 #include <mbed.h> 00012 00013 /** 00014 * This is a device driver class for the Slamtec RP LIDAR A1. 00015 */ 00016 class LIDAR { 00017 00018 public: 00019 00020 LIDAR(RawSerial& serial); 00021 virtual ~LIDAR(); 00022 short getDistance(short angle); 00023 short getDistanceOfBeacon(); 00024 short getAngleOfBeacon(); 00025 void lookForBeacon(); 00026 00027 private: 00028 00029 static const unsigned short HEADER_SIZE = 7; 00030 static const unsigned short DATA_SIZE = 5; 00031 00032 static const char START_FLAG = 0xA5; 00033 static const char SCAN = 0x20; 00034 static const char STOP = 0x25; 00035 static const char RESET = 0x40; 00036 00037 static const char QUALITY_THRESHOLD = 10; 00038 static const short DISTANCE_THRESHOLD = 10; 00039 static const short DEFAULT_DISTANCE = 10000; 00040 static const short MIN_DISTANCE = 500; 00041 static const short MAX_DISTANCE = 2000; 00042 static const short THRESHOLD = 500; 00043 static const short WINDOW = 75; 00044 static const short MIN_SIZE = 2; 00045 static const short MAX_SIZE = 9; 00046 00047 RawSerial& serial; // reference to serial interface for communication 00048 char headerCounter; 00049 char dataCounter; 00050 char data[DATA_SIZE]; 00051 short distances[360]; // measured distance for every angle value, given in [mm] 00052 short distanceOfBeacon; // distance of detected beacon, given in [mm] 00053 short angleOfBeacon; // angle of detected beacon, given in [degrees] 00054 bool lookClockwise; // flag to indicate direction of search algorithm 00055 00056 void receive(); 00057 }; 00058 00059 #endif /* LIDAR_H_ */
Generated on Tue Jul 26 2022 07:27:35 by
