Skip to content

Commit

Permalink
Add lslidar driver for Apollo platform,230714
Browse files Browse the repository at this point in the history
  • Loading branch information
Lslidar committed Jul 14, 2023
1 parent c70f99a commit cf81fa2
Show file tree
Hide file tree
Showing 27 changed files with 2,921 additions and 2,829 deletions.
6 changes: 3 additions & 3 deletions modules/drivers/lidar/lslidar/conf/lslidar16_conf.pb.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
model: LSLIDAR16P
device_ip: "192.168.1.200"
msop_port: 2368
difop_port: 2369
device_ip: "192.168.1.201"
msop_port: 2370
difop_port: 2371
return_mode: 1
degree_mode: 2 #2: 均匀2度校准两列 1://均匀1.33度校准两列
distance_unit: 0.25
Expand Down
2 changes: 1 addition & 1 deletion modules/drivers/lidar/lslidar/conf/lslidar32_conf.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ packet_size: 1206
time_synchronization: false
add_multicast: false
group_ip: "224.1.1.2"
rpm: 600 #雷达转速 10hz:600rpm, 20hz:1200rpm, 5hz:300rpm
rpm: 300 #雷达转速 10hz:600rpm, 20hz:1200rpm, 5hz:300rpm
convert_channel_name: "/apollo/sensor/lslidar32/PointCloud2"
frame_id: "lslidar32"
scan_channel: "/apollo/sensor/lslidar32/Scan"
Expand Down
895 changes: 467 additions & 428 deletions modules/drivers/lidar/lslidar/driver/driver.cc

Large diffs are not rendered by default.

147 changes: 74 additions & 73 deletions modules/drivers/lidar/lslidar/driver/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,81 +16,82 @@

#pragma once

#include <atomic>
#include <cmath>
#include <ctime>
#include <memory>
#include <string>
#include <mutex>
#include <atomic>
#include "modules/drivers/lidar/lslidar/driver/input.h"
#include <string>

#include "modules/drivers/lidar/lslidar/proto/config.pb.h"
#include "modules/drivers/lidar/lslidar/proto/lslidar.pb.h"

namespace apollo
{
namespace drivers
{
namespace lslidar
{

constexpr int BLOCKS_PER_PACKET = 12;
constexpr int BLOCK_SIZE = 100;

static const unsigned int POINTS_ONE_CHANNEL_PER_SECOND = 20000;
static const unsigned int BLOCKS_ONE_CHANNEL_PER_PKT = 12;
static const int POINTS_PER_PACKET = 171 * 7; // ch系列
static const int LS_POINTS_PER_PACKET_SINGLE_ECHO = 149 * 8; // LS 1550nm系列 单回波
static const int LS_POINTS_PER_PACKET_DOUBLE_ECHO = 99 * 12; // LS 1550nm系列 单回波

class LslidarDriver
{
public:
explicit LslidarDriver(const Config &config) : config_(config)
{
// scan_start = new LslidarPacket();
}
~LslidarDriver();

bool Poll(const std::shared_ptr<apollo::drivers::lslidar::LslidarScan> &scan);
void Init();
void difopPoll();
void SetPacketRate(const double packet_rate) { packet_rate_ = packet_rate; }
int npackets;
struct tm current_time;

protected:
Config config_;
std::unique_ptr<Input> input_ = nullptr;
std::unique_ptr<Input> positioning_input_ = nullptr;
std::string topic_;
double packet_rate_ = 0.0;
bool scan_fill = false;
uint64_t gps_time = 0;
uint64_t last_gps_time = 0;

uint64_t basetime_ = 0;
uint64_t packet_time_ns_ = 0;

uint32_t last_gps_time_ = 0;
uint64_t last_count_ = 0;
static uint64_t sync_counter;

std::thread difop_thread_;
int PollStandard(std::shared_ptr<apollo::drivers::lslidar::LslidarScan> scan);
LslidarPacket scan_start;
LslidarPacket last_scan_start;

LslidarPacket scan_start1;
LslidarPacket scan_start2;
std::mutex mutex_;
uint8_t bytes[FIRING_DATA_PACKET_SIZE] = {0x00};
std::string time_service_mode = {"gps"};
};

class LslidarDriverFactory
{
public:
static LslidarDriver *CreateDriver(const Config &config);
};

} // namespace lslidar
} // namespace drivers
} // namespace apollo
#include "cyber/cyber.h"
#include "modules/drivers/lidar/lslidar/driver/input.h"

namespace apollo {
namespace drivers {
namespace lslidar {

constexpr int BLOCKS_PER_PACKET = 12;
constexpr int BLOCK_SIZE = 100;

static const unsigned int POINTS_ONE_CHANNEL_PER_SECOND = 20000;
static const unsigned int BLOCKS_ONE_CHANNEL_PER_PKT = 12;
static const int POINTS_PER_PACKET = 171 * 7; // ch系列
static const int LS_POINTS_PER_PACKET_SINGLE_ECHO =
149 * 8; // LS 1550nm系列 单回波
static const int LS_POINTS_PER_PACKET_DOUBLE_ECHO =
99 * 12; // LS 1550nm系列 单回波

class LslidarDriver {
public:
explicit LslidarDriver(const Config &config) : config_(config) {
// scan_start = new LslidarPacket();
}
~LslidarDriver();

bool Poll(const std::shared_ptr<apollo::drivers::lslidar::LslidarScan> &scan);
void Init();
void difopPoll();
void SetPacketRate(const double packet_rate) { packet_rate_ = packet_rate; }
int npackets;
struct tm current_time;

protected:
Config config_;
std::unique_ptr<Input> input_ = nullptr;
std::unique_ptr<Input> positioning_input_ = nullptr;
std::string topic_;
double packet_rate_ = 0.0;
bool scan_fill = false;
uint64_t gps_time = 0;
uint64_t last_gps_time = 0;

uint64_t basetime_ = 0;
uint64_t packet_time_ns_ = 0;

uint32_t last_gps_time_ = 0;
uint64_t last_count_ = 0;
static uint64_t sync_counter;

std::thread difop_thread_;
int PollStandard(std::shared_ptr<apollo::drivers::lslidar::LslidarScan> scan);
LslidarPacket scan_start;
LslidarPacket last_scan_start;

LslidarPacket scan_start1;
LslidarPacket scan_start2;
std::mutex mutex_;
uint8_t bytes[FIRING_DATA_PACKET_SIZE] = {0x00};
std::string time_service_mode = {"gps"};
};

class LslidarDriverFactory {
public:
static LslidarDriver *CreateDriver(const Config &config);
};

} // namespace lslidar
} // namespace drivers
} // namespace apollo
Loading

0 comments on commit cf81fa2

Please sign in to comment.