Apollo 10.0
自动驾驶开放平台
input.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 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 <unistd.h>
20#include <cstdio>
21#include <string>
22
23#include <pcap.h>
24#include "cyber/cyber.h"
25#include "modules/drivers/lidar/lslidar/proto/lslidar.pb.h"
26
27namespace apollo {
28namespace drivers {
29namespace lslidar {
30namespace driver {
31
32static const size_t FIRING_DATA_PACKET_SIZE = 1212;
33static uint16_t MSOP_DATA_PORT_NUMBER
34 = 2368; // lslidar default data port on PC
35
36class Input {
37 public:
38 Input(uint16_t portport = MSOP_DATA_PORT_NUMBER,
39 std::string lidar_ip = "192.168.1.200",
40 int packet_size = 1212);
41 virtual ~Input();
42 virtual int GetPacket(LslidarPacket *pkt);
43
44 protected:
45 int port_;
48 in_addr devip_;
50};
51
53class InputSocket : public Input {
54 public:
56 uint16_t port = MSOP_DATA_PORT_NUMBER,
57 std::string lidar_ip = "192.168.1.200",
58 int packet_size = 1212);
59
60 virtual ~InputSocket();
61
62 virtual int GetPacket(LslidarPacket *pkt);
63};
64
69class InputPCAP : public Input {
70 public:
72 uint16_t port = MSOP_DATA_PORT_NUMBER,
73 std::string lidar_ip = "192.168.1.200",
74 int packet_size = 1212,
75 double packet_rate = 0.0,
76 std::string filename = "",
77 bool read_once = false,
78 bool read_fast = false,
79 double repeat_delay = 0.0);
80
81 virtual ~InputPCAP();
82
83 virtual int GetPacket(LslidarPacket *pkt);
84
85 private:
86 double packet_rate_;
87 std::string filename_;
88 pcap_t *pcap_;
89 bpf_program pcap_packet_filter_;
90 char errbuf_[PCAP_ERRBUF_SIZE];
91 bool empty_;
92 bool read_once_;
93 bool read_fast_;
94 double repeat_delay_;
95 std::string lidar_ip_;
96};
97
98} // namespace driver
99} // namespace lslidar
100} // namespace drivers
101} // namespace apollo
lslidar input from PCAP dump file.
Definition input.h:69
virtual int GetPacket(LslidarPacket *pkt)
Get one lslidar packet.
Definition input.cc:203
Live lslidar input from socket.
Definition input.h:53
virtual int GetPacket(LslidarPacket *pkt)
Definition input.cc:83
virtual int GetPacket(LslidarPacket *pkt)
Definition input.cc:40
class register implement
Definition arena_queue.h:37