|
16 | 16 |
|
17 | 17 | #pragma once |
18 | 18 |
|
| 19 | +#include <atomic> |
| 20 | +#include <cmath> |
| 21 | +#include <ctime> |
19 | 22 | #include <memory> |
20 | | -#include <string> |
21 | 23 | #include <mutex> |
22 | | -#include <atomic> |
23 | | -#include "modules/drivers/lidar/lslidar/driver/input.h" |
| 24 | +#include <string> |
| 25 | + |
24 | 26 | #include "modules/drivers/lidar/lslidar/proto/config.pb.h" |
25 | 27 | #include "modules/drivers/lidar/lslidar/proto/lslidar.pb.h" |
26 | 28 |
|
27 | | -namespace apollo |
28 | | -{ |
29 | | - namespace drivers |
30 | | - { |
31 | | - namespace lslidar |
32 | | - { |
33 | | - |
34 | | - constexpr int BLOCKS_PER_PACKET = 12; |
35 | | - constexpr int BLOCK_SIZE = 100; |
36 | | - |
37 | | - static const unsigned int POINTS_ONE_CHANNEL_PER_SECOND = 20000; |
38 | | - static const unsigned int BLOCKS_ONE_CHANNEL_PER_PKT = 12; |
39 | | - static const int POINTS_PER_PACKET = 171 * 7; // ch系列 |
40 | | - static const int LS_POINTS_PER_PACKET_SINGLE_ECHO = 149 * 8; // LS 1550nm系列 单回波 |
41 | | - static const int LS_POINTS_PER_PACKET_DOUBLE_ECHO = 99 * 12; // LS 1550nm系列 单回波 |
42 | | - |
43 | | - class LslidarDriver |
44 | | - { |
45 | | - public: |
46 | | - explicit LslidarDriver(const Config &config) : config_(config) |
47 | | - { |
48 | | - // scan_start = new LslidarPacket(); |
49 | | - } |
50 | | - ~LslidarDriver(); |
51 | | - |
52 | | - bool Poll(const std::shared_ptr<apollo::drivers::lslidar::LslidarScan> &scan); |
53 | | - void Init(); |
54 | | - void difopPoll(); |
55 | | - void SetPacketRate(const double packet_rate) { packet_rate_ = packet_rate; } |
56 | | - int npackets; |
57 | | - struct tm current_time; |
58 | | - |
59 | | - protected: |
60 | | - Config config_; |
61 | | - std::unique_ptr<Input> input_ = nullptr; |
62 | | - std::unique_ptr<Input> positioning_input_ = nullptr; |
63 | | - std::string topic_; |
64 | | - double packet_rate_ = 0.0; |
65 | | - bool scan_fill = false; |
66 | | - uint64_t gps_time = 0; |
67 | | - uint64_t last_gps_time = 0; |
68 | | - |
69 | | - uint64_t basetime_ = 0; |
70 | | - uint64_t packet_time_ns_ = 0; |
71 | | - |
72 | | - uint32_t last_gps_time_ = 0; |
73 | | - uint64_t last_count_ = 0; |
74 | | - static uint64_t sync_counter; |
75 | | - |
76 | | - std::thread difop_thread_; |
77 | | - int PollStandard(std::shared_ptr<apollo::drivers::lslidar::LslidarScan> scan); |
78 | | - LslidarPacket scan_start; |
79 | | - LslidarPacket last_scan_start; |
80 | | - |
81 | | - LslidarPacket scan_start1; |
82 | | - LslidarPacket scan_start2; |
83 | | - std::mutex mutex_; |
84 | | - uint8_t bytes[FIRING_DATA_PACKET_SIZE] = {0x00}; |
85 | | - std::string time_service_mode = {"gps"}; |
86 | | - }; |
87 | | - |
88 | | - class LslidarDriverFactory |
89 | | - { |
90 | | - public: |
91 | | - static LslidarDriver *CreateDriver(const Config &config); |
92 | | - }; |
93 | | - |
94 | | - } // namespace lslidar |
95 | | - } // namespace drivers |
96 | | -} // namespace apollo |
| 29 | +#include "cyber/cyber.h" |
| 30 | +#include "modules/drivers/lidar/lslidar/driver/input.h" |
| 31 | + |
| 32 | +namespace apollo { |
| 33 | +namespace drivers { |
| 34 | +namespace lslidar { |
| 35 | + |
| 36 | +constexpr int BLOCKS_PER_PACKET = 12; |
| 37 | +constexpr int BLOCK_SIZE = 100; |
| 38 | + |
| 39 | +static const unsigned int POINTS_ONE_CHANNEL_PER_SECOND = 20000; |
| 40 | +static const unsigned int BLOCKS_ONE_CHANNEL_PER_PKT = 12; |
| 41 | +static const int POINTS_PER_PACKET = 171 * 7; // ch系列 |
| 42 | +static const int LS_POINTS_PER_PACKET_SINGLE_ECHO = |
| 43 | + 149 * 8; // LS 1550nm系列 单回波 |
| 44 | +static const int LS_POINTS_PER_PACKET_DOUBLE_ECHO = |
| 45 | + 99 * 12; // LS 1550nm系列 单回波 |
| 46 | + |
| 47 | +class LslidarDriver { |
| 48 | + public: |
| 49 | + explicit LslidarDriver(const Config &config) : config_(config) { |
| 50 | + // scan_start = new LslidarPacket(); |
| 51 | + } |
| 52 | + ~LslidarDriver(); |
| 53 | + |
| 54 | + bool Poll(const std::shared_ptr<apollo::drivers::lslidar::LslidarScan> &scan); |
| 55 | + void Init(); |
| 56 | + void difopPoll(); |
| 57 | + void SetPacketRate(const double packet_rate) { packet_rate_ = packet_rate; } |
| 58 | + int npackets; |
| 59 | + struct tm current_time; |
| 60 | + |
| 61 | + protected: |
| 62 | + Config config_; |
| 63 | + std::unique_ptr<Input> input_ = nullptr; |
| 64 | + std::unique_ptr<Input> positioning_input_ = nullptr; |
| 65 | + std::string topic_; |
| 66 | + double packet_rate_ = 0.0; |
| 67 | + bool scan_fill = false; |
| 68 | + uint64_t gps_time = 0; |
| 69 | + uint64_t last_gps_time = 0; |
| 70 | + |
| 71 | + uint64_t basetime_ = 0; |
| 72 | + uint64_t packet_time_ns_ = 0; |
| 73 | + |
| 74 | + uint32_t last_gps_time_ = 0; |
| 75 | + uint64_t last_count_ = 0; |
| 76 | + static uint64_t sync_counter; |
| 77 | + |
| 78 | + std::thread difop_thread_; |
| 79 | + int PollStandard(std::shared_ptr<apollo::drivers::lslidar::LslidarScan> scan); |
| 80 | + LslidarPacket scan_start; |
| 81 | + LslidarPacket last_scan_start; |
| 82 | + |
| 83 | + LslidarPacket scan_start1; |
| 84 | + LslidarPacket scan_start2; |
| 85 | + std::mutex mutex_; |
| 86 | + uint8_t bytes[FIRING_DATA_PACKET_SIZE] = {0x00}; |
| 87 | + std::string time_service_mode = {"gps"}; |
| 88 | +}; |
| 89 | + |
| 90 | +class LslidarDriverFactory { |
| 91 | + public: |
| 92 | + static LslidarDriver *CreateDriver(const Config &config); |
| 93 | +}; |
| 94 | + |
| 95 | +} // namespace lslidar |
| 96 | +} // namespace drivers |
| 97 | +} // namespace apollo |
0 commit comments