ROME 2 Lab5
Embed:
(wiki syntax)
Show/hide line numbers
LIDAR.h
00001 /* 00002 * LIDAR.h 00003 * Copyright (c) 2020, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #ifndef LIDAR_H_ 00008 #define LIDAR_H_ 00009 00010 #include <cstdlib> 00011 #include <deque> 00012 #include <mbed.h> 00013 #include "Point.h" 00014 00015 /** 00016 * This is a device driver class for the Slamtec RP LIDAR A1. 00017 */ 00018 class LIDAR { 00019 00020 public: 00021 00022 LIDAR(RawSerial& serial); 00023 virtual ~LIDAR(); 00024 deque<Point> getScan(); 00025 deque<Point> getBeacons(); 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; // quality threshold used for accepting measurements 00038 static const float DISTANCE_THRESHOLD; // threshold for measured distance, given in [m] 00039 static const float DEFAULT_DISTANCE; // default distance > range of sensor, given in [m] 00040 static const float M_PI; // the mathematical constant PI 00041 static const float DISTANCES[]; // simulated distance for every angle value, given in [m] 00042 00043 RawSerial& serial; // reference to serial interface for communication 00044 char headerCounter; 00045 char dataCounter; 00046 char data[DATA_SIZE]; 00047 float distances[360]; // measured distance for every angle value, given in [m] 00048 bool simulation; // flag to indicate if scans are only simulated 00049 00050 void receive(); 00051 }; 00052 00053 #endif /* LIDAR_H_ */ 00054
Generated on Thu Jul 14 2022 18:53:11 by
1.7.2