Skip to content

Commit cf81fa2

Browse files
committed
Add lslidar driver for Apollo platform,230714
1 parent c70f99a commit cf81fa2

27 files changed

+2921
-2829
lines changed

modules/drivers/lidar/lslidar/conf/lslidar16_conf.pb.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
model: LSLIDAR16P
2-
device_ip: "192.168.1.200"
3-
msop_port: 2368
4-
difop_port: 2369
2+
device_ip: "192.168.1.201"
3+
msop_port: 2370
4+
difop_port: 2371
55
return_mode: 1
66
degree_mode: 2 #2: 均匀2度校准两列 1://均匀1.33度校准两列
77
distance_unit: 0.25

modules/drivers/lidar/lslidar/conf/lslidar32_conf.pb.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ packet_size: 1206
99
time_synchronization: false
1010
add_multicast: false
1111
group_ip: "224.1.1.2"
12-
rpm: 600 #雷达转速 10hz:600rpm, 20hz:1200rpm, 5hz:300rpm
12+
rpm: 300 #雷达转速 10hz:600rpm, 20hz:1200rpm, 5hz:300rpm
1313
convert_channel_name: "/apollo/sensor/lslidar32/PointCloud2"
1414
frame_id: "lslidar32"
1515
scan_channel: "/apollo/sensor/lslidar32/Scan"

modules/drivers/lidar/lslidar/driver/driver.cc

Lines changed: 467 additions & 428 deletions
Large diffs are not rendered by default.

modules/drivers/lidar/lslidar/driver/driver.h

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -16,81 +16,82 @@
1616

1717
#pragma once
1818

19+
#include <atomic>
20+
#include <cmath>
21+
#include <ctime>
1922
#include <memory>
20-
#include <string>
2123
#include <mutex>
22-
#include <atomic>
23-
#include "modules/drivers/lidar/lslidar/driver/input.h"
24+
#include <string>
25+
2426
#include "modules/drivers/lidar/lslidar/proto/config.pb.h"
2527
#include "modules/drivers/lidar/lslidar/proto/lslidar.pb.h"
2628

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

Comments
 (0)