Apollo 10.0
自动驾驶开放平台
driver.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <atomic>
20#include <cmath>
21#include <ctime>
22#include <memory>
23#include <mutex>
24#include <string>
25
26#include "modules/drivers/lidar/lslidar/proto/config.pb.h"
27#include "modules/drivers/lidar/lslidar/proto/lslidar.pb.h"
28
29#include "cyber/cyber.h"
31
32namespace apollo {
33namespace drivers {
34namespace lslidar {
35namespace driver {
36
37constexpr int BLOCKS_PER_PACKET = 12;
38constexpr int BLOCK_SIZE = 100;
39
40static const unsigned int POINTS_ONE_CHANNEL_PER_SECOND = 20000;
41static const unsigned int BLOCKS_ONE_CHANNEL_PER_PKT = 12;
42static const int POINTS_PER_PACKET = 171 * 7; // ch系列
43static const int LS_POINTS_PER_PACKET_SINGLE_ECHO
44 = 149 * 8; // LS 1550nm系列 单回波
45static const int LS_POINTS_PER_PACKET_DOUBLE_ECHO
46 = 99 * 12; // LS 1550nm系列 单回波
47
49 public:
50 explicit LslidarDriver(const Config &config) : config_(config) {
51 // scan_start = new LslidarPacket();
52 }
54
55 bool Poll(
56 const std::shared_ptr<apollo::drivers::lslidar::LslidarScan> &scan);
57 void Init();
58 void difopPoll();
59 void SetPacketRate(const double packet_rate) {
60 packet_rate_ = packet_rate;
61 }
63 struct tm current_time;
64
65 protected:
67 std::unique_ptr<Input> input_ = nullptr;
68 std::unique_ptr<Input> positioning_input_ = nullptr;
69 std::string topic_;
70 double packet_rate_ = 0.0;
71 bool scan_fill = false;
72 uint64_t gps_time = 0;
73 uint64_t last_gps_time = 0;
74
75 uint64_t basetime_ = 0;
76 uint64_t packet_time_ns_ = 0;
77
78 uint32_t last_gps_time_ = 0;
79 uint64_t last_count_ = 0;
80 static uint64_t sync_counter;
81
82 std::thread difop_thread_;
83 int PollStandard(
84 std::shared_ptr<apollo::drivers::lslidar::LslidarScan> scan);
87
90 std::mutex mutex_;
91 uint8_t bytes[FIRING_DATA_PACKET_SIZE] = {0x00};
92 std::string time_service_mode = {"gps"};
93};
94
96 public:
97 static LslidarDriver *CreateDriver(const Config &config);
98};
99
100} // namespace driver
101} // namespace lslidar
102} // namespace drivers
103} // namespace apollo
static LslidarDriver * CreateDriver(const Config &config)
Definition driver.cc:601
void SetPacketRate(const double packet_rate)
Definition driver.h:59
uint8_t bytes[FIRING_DATA_PACKET_SIZE]
Definition driver.h:91
int PollStandard(std::shared_ptr< apollo::drivers::lslidar::LslidarScan > scan)
Definition driver.cc:173
bool Poll(const std::shared_ptr< apollo::drivers::lslidar::LslidarScan > &scan)
poll the device
Definition driver.cc:145
std::unique_ptr< Input > positioning_input_
Definition driver.h:68
constexpr int BLOCKS_PER_PACKET
Definition driver.h:37
class register implement
Definition arena_queue.h:37