60 #include <boost/format.hpp> 62 #include "modules/drivers/lidar/proto/velodyne.pb.h" 63 #include "modules/drivers/lidar/proto/velodyne_config.pb.h" 64 #include "modules/drivers/proto/pointcloud.pb.h" 75 using apollo::drivers::PointXYZIT;
76 using apollo::drivers::velodyne::DUAL;
77 using apollo::drivers::velodyne::HDL32E;
78 using apollo::drivers::velodyne::HDL64E_S2;
79 using apollo::drivers::velodyne::HDL64E_S3D;
80 using apollo::drivers::velodyne::HDL64E_S3S;
81 using apollo::drivers::velodyne::LAST;
82 using apollo::drivers::velodyne::STRONGEST;
83 using apollo::drivers::velodyne::VelodynePacket;
84 using apollo::drivers::velodyne::VelodyneScan;
85 using apollo::drivers::velodyne::VLP16;
86 using apollo::drivers::velodyne::VLP32C;
87 using apollo::drivers::velodyne::VLS128;
93 static const int RAW_SCAN_SIZE = 3;
94 static const int SCANS_PER_BLOCK = 32;
95 static const int BLOCK_DATA_SIZE = (SCANS_PER_BLOCK * RAW_SCAN_SIZE);
97 static const float ROTATION_RESOLUTION = 0.01f;
101 static const uint16_t ROTATION_MAX_UNITS = 36001;
105 static const float DISTANCE_MAX = 130.0f;
106 static const float DISTANCE_RESOLUTION = 0.002f;
107 static const float DISTANCE_MAX_UNITS =
108 (DISTANCE_MAX / DISTANCE_RESOLUTION + 1.0f);
111 static const uint16_t UPPER_BANK = 0xeeff;
112 static const uint16_t LOWER_BANK = 0xddff;
114 static const float ANGULAR_RESOLUTION = 0.00300919f;
117 static const int VLP16_FIRINGS_PER_BLOCK = 2;
118 static const int VLP16_SCANS_PER_FIRING = 16;
119 static const float VLP16_BLOCK_TDURATION = 110.592f;
120 static const float VLP16_DSR_TOFFSET = 2.304f;
121 static const float VLP16_FIRING_TOFFSET = 55.296f;
123 static const float VLS128_CHANNEL_TDURATION = 2.304f;
124 static const float VLS128_SEQ_TDURATION = 55.296f;
126 static const float VLP32_DISTANCE_RESOLUTION = 0.004f;
127 static const float VSL128_DISTANCE_RESOLUTION = 0.004f;
128 static const float CHANNEL_TDURATION = 2.304f;
129 static const float SEQ_TDURATION = 55.296f;
154 static const int PACKET_SIZE = 1206;
156 static const int PACKET_STATUS_SIZE = 4;
221 static const float nan = std::numeric_limits<float>::signaling_NaN();
241 virtual void GeneratePointcloud(
const std::shared_ptr<VelodyneScan>& scan_msg,
242 std::shared_ptr<PointCloud> out_msg) = 0;
243 virtual void setup();
245 virtual void Order(std::shared_ptr<PointCloud> cloud) = 0;
251 const float (*inner_time_)[12][32];
254 float sin_rot_table_[ROTATION_MAX_UNITS];
255 float cos_rot_table_[ROTATION_MAX_UNITS];
262 PointXYZIT get_nan_point(uint64_t timestamp);
263 void init_angle_params(
double view_direction,
double view_width);
270 void ComputeCoords(
const float& raw_distance,
272 const uint16_t
rotation, PointXYZIT* point);
274 bool is_scan_valid(
int rotation,
float distance);
280 virtual void Unpack(
const VelodynePacket& pkt,
281 std::shared_ptr<PointCloud> pc) = 0;
283 uint64_t GetGpsStamp(
double current_stamp,
double* previous_stamp,
284 uint64_t* gps_base_usec);
286 virtual uint64_t GetTimestamp(
double base_time,
float time_offset,
295 void GeneratePointcloud(
const std::shared_ptr<VelodyneScan>& scan_msg,
296 std::shared_ptr<PointCloud> out_msg);
297 void Order(std::shared_ptr<PointCloud> cloud);
298 void setup()
override;
301 void SetBaseTimeFromPackets(
const VelodynePacket& pkt);
302 void CheckGpsStatus(
const VelodynePacket& pkt);
303 uint64_t GetTimestamp(
double base_time,
float time_offset,
305 void Unpack(
const VelodynePacket& pkt, std::shared_ptr<PointCloud> pc);
308 const uint16_t raw_distance,
int intensity);
310 double previous_packet_stamp_[4];
311 uint64_t gps_base_usec_[4];
323 void GeneratePointcloud(
const std::shared_ptr<VelodyneScan>& scan_msg,
324 std::shared_ptr<PointCloud> out_msg);
325 void Order(std::shared_ptr<PointCloud> cloud);
328 uint64_t GetTimestamp(
double base_time,
float time_offset,
330 void Unpack(
const VelodynePacket& pkt, std::shared_ptr<PointCloud> pc);
331 void UnpackVLP32C(
const VelodynePacket& pkt, std::shared_ptr<PointCloud> pc);
333 double previous_firing_stamp_;
334 uint64_t gps_base_usec_;
342 void GeneratePointcloud(
const std::shared_ptr<VelodyneScan>& scan_msg,
343 std::shared_ptr<PointCloud> out_msg);
344 void Order(std::shared_ptr<PointCloud> cloud);
347 uint64_t GetTimestamp(
double base_time,
float time_offset,
349 void Unpack(
const VelodynePacket& pkt, std::shared_ptr<PointCloud> pc);
351 double previous_packet_stamp_;
352 uint64_t gps_base_usec_;
360 void GeneratePointcloud(
const std::shared_ptr<VelodyneScan>& scan_msg,
361 std::shared_ptr<PointCloud> out_msg);
362 void Order(std::shared_ptr<PointCloud> cloud);
365 uint64_t GetTimestamp(
double base_time,
float time_offset,
367 void Unpack(
const VelodynePacket& pkt, std::shared_ptr<PointCloud> pc);
369 const uint16_t raw_distance,
int intensity);
371 double previous_packet_stamp_;
372 uint64_t gps_base_usec_;
Mode mode_
Definition: velodyne_parser.h:260
Definition: velodyne_parser.h:166
bool need_two_pt_correction_
Definition: velodyne_parser.h:259
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
~Velodyne16Parser()
Definition: velodyne_parser.h:340
Definition: velodyne_parser.h:318
const double get_last_timestamp()
Definition: velodyne_parser.h:248
Definition: velodyne_parser.h:160
uint16_t rotation
0-35999, divide by 100 to get degrees
Definition: velodyne_parser.h:140
Definition: velodyne_parser.h:375
Config config_
Definition: velodyne_parser.h:257
Definition: online_calibration.h:37
pcl::PointCloud< Point > PointCloud
Definition: types.h:64
Definition: velodyne_parser.h:290
correction values for a single laser
Definition: calibration.h:43
Definition: velodyne_parser.h:165
Raw Velodyne packet.
Definition: velodyne_parser.h:178
uint8_t data[BLOCK_DATA_SIZE]
Definition: velodyne_parser.h:141
constexpr int BLOCKS_PER_PACKET
Definition: driver.h:33
Calibration calibration_
Definition: velodyne_parser.h:253
Definition: velodyne_parser.h:161
Definition: velodyne_parser.h:163
const Calibration & get_calibration()
Definition: velodyne_parser.h:247
unsigned char status_value
Definition: velodyne_parser.h:184
~Velodyne128Parser()
Definition: velodyne_parser.h:358
constexpr int BLOCK_SIZE
Definition: driver.h:34
Definition: velodyne_parser.h:355
Definition: velodyne_parser.h:149
VelodyneParser()
Definition: velodyne_parser.h:226
unsigned int gps_timestamp
Definition: velodyne_parser.h:182
Raw Velodyne data block.
Definition: velodyne_parser.h:138
Definition: velodyne_parser.h:162
Definition: velodyne_parser.h:337
virtual ~VelodyneParser()
Definition: velodyne_parser.h:228
~Velodyne32Parser()
Definition: velodyne_parser.h:321
Velodyne data conversion class.
Definition: velodyne_parser.h:224
uint16_t laser_block_id
UPPER_BANK or LOWER_BANK.
Definition: velodyne_parser.h:139
Calibration class storing entire configuration for the Velodyne.
Definition: calibration.h:68
unsigned char status_type
Definition: velodyne_parser.h:183
Definition: velodyne_parser.h:164
uint16_t raw_distance
Definition: velodyne_parser.h:150
~Velodyne64Parser()
Definition: velodyne_parser.h:293
double last_time_stamp_
Definition: velodyne_parser.h:256
StatusType
Definition: velodyne_parser.h:159