calibration.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Copyright (C) 2012, 2019 Austin Robot Technology, Piyush Khandelwal, Joshua Whitley
  2. // All rights reserved.
  3. //
  4. // Software License Agreement (BSD License 2.0)
  5. //
  6. // Redistribution and use in source and binary forms, with or without
  7. // modification, are permitted provided that the following conditions
  8. // are met:
  9. //
  10. // * Redistributions of source code must retain the above copyright
  11. // notice, this list of conditions and the following disclaimer.
  12. // * Redistributions in binary form must reproduce the above
  13. // copyright notice, this list of conditions and the following
  14. // disclaimer in the documentation and/or other materials provided
  15. // with the distribution.
  16. // * Neither the name of {copyright_holder} nor the names of its
  17. // contributors may be used to endorse or promote products derived
  18. // from this software without specific prior written permission.
  19. //
  20. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  30. // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. // POSSIBILITY OF SUCH DAMAGE.
  32. #ifndef VELODYNE_POINTCLOUD_CALIBRATION_H
  33. #define VELODYNE_POINTCLOUD_CALIBRATION_H
  34. #include <map>
  35. #include <vector>
  36. #include <string>
  37. namespace velodyne_pointcloud
  38. {
  39. /** \brief correction values for a single laser
  40. *
  41. * Correction values for a single laser (as provided by db.xml from
  42. * Velodyne). Includes parameters for Velodyne HDL-64E S2.1.
  43. *
  44. * http://velodynelidar.com/lidar/products/manual/63-HDL64E%20S2%20Manual_Rev%20D_2011_web.pdf
  45. */
  46. /** \brief Correction information for a single laser. */
  47. struct LaserCorrection
  48. {
  49. /** parameters in db.xml */
  50. float rot_correction;
  51. float vert_correction;
  52. float dist_correction;
  53. bool two_pt_correction_available;
  54. float dist_correction_x;
  55. float dist_correction_y;
  56. float vert_offset_correction;
  57. float horiz_offset_correction;
  58. int max_intensity;
  59. int min_intensity;
  60. float focal_distance;
  61. float focal_slope;
  62. /** cached values calculated when the calibration file is read */
  63. float cos_rot_correction; ///< cosine of rot_correction
  64. float sin_rot_correction; ///< sine of rot_correction
  65. float cos_vert_correction; ///< cosine of vert_correction
  66. float sin_vert_correction; ///< sine of vert_correction
  67. int laser_ring; ///< ring number for this laser
  68. };
  69. /** \brief Calibration information for the entire device. */
  70. class Calibration
  71. {
  72. public:
  73. float distance_resolution_m;
  74. std::map<int, LaserCorrection> laser_corrections_map;
  75. std::vector<LaserCorrection> laser_corrections;
  76. int num_lasers;
  77. bool initialized;
  78. // bool ros_info;
  79. public:
  80. explicit Calibration(bool info = true)
  81. : distance_resolution_m(0.002f),
  82. num_lasers(0),
  83. initialized(false) {}
  84. explicit Calibration(
  85. const std::string& calibration_file,
  86. bool info = true)
  87. : distance_resolution_m(0.002f)
  88. {
  89. read(calibration_file);
  90. }
  91. void read(const std::string& calibration_file);
  92. void write(const std::string& calibration_file);
  93. };
  94. } // namespace velodyne_pointcloud
  95. #endif // VELODYNE_POINTCLOUD_CALIBRATION_H