From e1490cb727d3cf42bc4e14d2bd2acf614bf93290 Mon Sep 17 00:00:00 2001 From: "Simon D. Levy" Date: Sun, 7 Sep 2014 20:57:20 -0400 Subject: [PATCH] Create Laser.hpp --- cpp/Laser.hpp | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 cpp/Laser.hpp diff --git a/cpp/Laser.hpp b/cpp/Laser.hpp new file mode 100644 index 0000000..3f3dc51 --- /dev/null +++ b/cpp/Laser.hpp @@ -0,0 +1,102 @@ +/** +* +* Laser.hpp - C++ headers for Laser model classes +* +* Copyright (C) 2014 Simon D. Levy + +* This code is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation, either version 3 of the +* License, or (at your option) any later version. +* +* This code is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this code. If not, see . +*/ + +#include +#include + +#include +#include +using namespace std; + + +/** +* A class for scanning laser rangefinder (Lidar) parameters. +*/ +class Laser +{ + friend class CoreSLAM; + friend class SinglePositionSLAM; + friend class RMHC_SLAM; + friend class Scan; + +public: + + /** + * Builds a Laser object from parameters based on the specifications for your + * Lidar unit. + * @param scan_size number of rays per scan + * @param scan_rate_hz laser scan rate in Hertz + * @param detection_angle_degrees detection angle in degrees (e.g. 240, 360) + * @param detection_margin number of rays at edges of scan to ignore + * @param offset_mm forward/backward offset of laser motor from robot center + * @return a new Laser object + * + */ + Laser( + int scan_size, + float scan_rate_hz, + float detection_angle_degrees, + float distance_no_detection_mm, + int detection_margin = 0, + float offset_mm = 0. + ); + + /** + * Builds an empty Laser object (all parameters zero). + */ + Laser(void); + + /** + * Dealloates memory for this Laser object. + */ + ~Laser(void); + + + friend ostream& operator<< (ostream & out, Laser & laser); + +private: + + struct laser_t * laser; + +}; + +class URG04LX : public Laser +{ + +public: + + /** + * Builds a Laser object from parameters based on the specifications for your + * Lidar unit. + * @param detection_margin number of rays at edges of scan to ignore + * @param offset_mm forward/backward offset of laser motor from robot center + * @return a new URG04LX object + * + */ + URG04LX(int detection_margin = 0, float offset_mm = 0) : + Laser(682, 10, 240, 4000, detection_margin, offset_mm) { } + + /** + * Builds an empty Laser object (all parameters zero). + */ + URG04LX(void) : Laser() {} + +}; +