Point Cloud Library (PCL)  1.9.1
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 #include "pcl/pcl_config.h"
40 
41 #ifndef PCL_IO_VLP_GRABBER_H_
42 #define PCL_IO_VLP_GRABBER_H_
43 
44 #include <pcl/io/hdl_grabber.h>
45 #include <pcl/io/grabber.h>
46 #include <pcl/point_types.h>
47 #include <pcl/point_cloud.h>
48 #include <boost/asio.hpp>
49 #include <string>
50 
51 namespace pcl
52 {
53 
54  /** \brief Grabber for the Velodyne LiDAR (VLP), based on the Velodyne High Definition Laser (HDL)
55  * \author Keven Ring <keven@mitre.org>
56  * \ingroup io
57  */
58  class PCL_EXPORTS VLPGrabber : public HDLGrabber
59  {
60  public:
61  /** \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]
62  * \param[in] pcapFile Path to a file which contains previously captured data packets. This parameter is optional
63  */
64  VLPGrabber (const std::string& pcapFile = "");
65 
66  /** \brief Constructor taking a specified IP/port
67  * \param[in] ipAddress IP Address that should be used to listen for VLP packets
68  * \param[in] port UDP Port that should be used to listen for VLP packets
69  */
70  VLPGrabber (const boost::asio::ip::address& ipAddress,
71  const uint16_t port);
72 
73  /** \brief virtual Destructor inherited from the Grabber interface. It never throws. */
74  virtual
75  ~VLPGrabber () throw ();
76 
77  /** \brief Obtains the name of this I/O Grabber
78  * \return The name of the grabber
79  */
80  virtual std::string
81  getName () const;
82 
83  /** \brief Allows one to customize the colors used by each laser.
84  * \param[in] color RGB color to set
85  * \param[in] laserNumber Number of laser to set color
86  */
87  void
88  setLaserColorRGB (const pcl::RGB& color,
89  const uint8_t laserNumber);
90 
91  /** \brief Allows one to customize the colors used for each of the lasers.
92  * \param[in] begin begin iterator of RGB color array
93  * \param[in] end end iterator of RGB color array
94  */
95  template<typename IterT> void
96  setLaserColorRGB (const IterT& begin, const IterT& end)
97  {
98  std::copy (begin, end, laser_rgb_mapping_);
99  }
100 
101  /** \brief Returns the maximum number of lasers
102  */
103  virtual uint8_t
104  getMaximumNumberOfLasers () const;
105 
106  protected:
107  static const uint8_t VLP_MAX_NUM_LASERS = 16;
108  static const uint8_t VLP_DUAL_MODE = 0x39;
109 
110  private:
111  pcl::RGB laser_rgb_mapping_[VLP_MAX_NUM_LASERS];
112 
113  virtual void
114  toPointClouds (HDLDataPacket *dataPacket);
115 
116  boost::asio::ip::address
117  getDefaultNetworkAddress ();
118 
119  void
120  initializeLaserMapping ();
121 
122  void
123  loadVLP16Corrections ();
124 
125  };
126 }
127 
128 #endif /* PCL_IO_VLP_GRABBER_H_ */
Grabber for the Velodyne LiDAR (VLP), based on the Velodyne High Definition Laser (HDL)
Definition: vlp_grabber.h:58
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
Grabber for the Velodyne High-Definition-Laser (HDL)
Definition: hdl_grabber.h:60
A structure representing RGB color information.
void setLaserColorRGB(const IterT &begin, const IterT &end)
Allows one to customize the colors used for each of the lasers.
Definition: vlp_grabber.h:96
Defines all the PCL implemented PointT point type structures.