Point Cloud Library (PCL)  1.14.0-dev
vlp_grabber.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2015-, Open Perception, Inc.
6  * Copyright (c) 2015 The MITRE Corporation
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
38 
39 #pragma once
40 
41 #include "pcl/pcl_config.h"
42 
43 #include <pcl/io/hdl_grabber.h>
44 #include <pcl/io/grabber.h>
45 #include <pcl/point_types.h>
46 #include <boost/asio.hpp>
47 #include <string>
48 
49 namespace pcl
50 {
51 
52  /** \brief Grabber for the Velodyne LiDAR (VLP), based on the Velodyne High Definition Laser (HDL)
53  * \author Keven Ring <keven@mitre.org>
54  * \ingroup io
55  */
57  {
58  public:
59  /** \brief Constructor taking an optional path to an vlp corrections file. The Grabber will listen on the default IP/port for data packets [192.168.3.255/2368]
60  * \param[in] pcapFile Path to a file which contains previously captured data packets. This parameter is optional
61  */
62  VLPGrabber (const std::string& pcapFile = "");
63 
64  /** \brief Constructor taking a specified IP/port
65  * \param[in] ipAddress IP Address that should be used to listen for VLP packets
66  * \param[in] port UDP Port that should be used to listen for VLP packets
67  */
68  VLPGrabber (const boost::asio::ip::address& ipAddress,
69  const std::uint16_t port);
70 
71  /** \brief virtual Destructor inherited from the Grabber interface. It never throws. */
72 
73  ~VLPGrabber () noexcept override;
74 
75  /** \brief Obtains the name of this I/O Grabber
76  * \return The name of the grabber
77  */
78  std::string
79  getName () const override;
80 
81  /** \brief Allows one to customize the colors used by each laser.
82  * \param[in] color RGB color to set
83  * \param[in] laserNumber Number of laser to set color
84  */
85  void
86  setLaserColorRGB (const pcl::RGB& color,
87  const std::uint8_t laserNumber);
88 
89  /** \brief Allows one to customize the colors used for each of the lasers.
90  * \param[in] begin begin iterator of RGB color array
91  * \param[in] end end iterator of RGB color array
92  */
93  template<typename IterT> void
94  setLaserColorRGB (const IterT& begin, const IterT& end)
95  {
96  std::copy (begin, end, laser_rgb_mapping_);
97  }
98 
99  /** \brief Returns the maximum number of lasers
100  */
101  std::uint8_t
102  getMaximumNumberOfLasers () const override;
103 
104  protected:
105  static const std::uint8_t VLP_MAX_NUM_LASERS = 16;
106  static const std::uint8_t VLP_DUAL_MODE = 0x39;
107 
108  private:
109  pcl::RGB laser_rgb_mapping_[VLP_MAX_NUM_LASERS];
110 
111  void
112  toPointClouds (HDLDataPacket *dataPacket) override;
113 
114  boost::asio::ip::address
115  getDefaultNetworkAddress () override;
116 
117  void
118  initializeLaserMapping ();
119 
120  void
121  loadVLP16Corrections ();
122 
123  };
124 }
Grabber for the Velodyne High-Definition-Laser (HDL)
Definition: hdl_grabber.h:62
Grabber for the Velodyne LiDAR (VLP), based on the Velodyne High Definition Laser (HDL)
Definition: vlp_grabber.h:57
VLPGrabber(const boost::asio::ip::address &ipAddress, const std::uint16_t port)
Constructor taking a specified IP/port.
~VLPGrabber() noexcept override
virtual Destructor inherited from the Grabber interface.
std::uint8_t getMaximumNumberOfLasers() const override
Returns the maximum number of lasers.
VLPGrabber(const std::string &pcapFile="")
Constructor taking an optional path to an vlp corrections file.
Defines all the PCL implemented PointT point type structures.
#define PCL_EXPORTS
Definition: pcl_macros.h:323
A structure representing RGB color information.