Apollo 10.0
自动驾驶开放平台
livox_dispatcher.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 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#pragma once
17
18#include <map>
19#include <regex>
20#include <string>
21
22#include <livox_lidar_def.h>
23
24#include "cyber/cyber.h"
25
26namespace apollo {
27namespace drivers {
28namespace lidar {
29
31 public:
32 LivoxDispatcher() : handle_callback_functions(), mtx() {}
33
34 using PointCloudCallbackType = std::function<void(
35 uint32_t handle,
36 const uint8_t dev_type,
37 LivoxLidarEthernetPacket* data,
38 void* client_data)>;
39
40 bool GetHandleFromIP(const std::string& ip, uint32_t& handle);
41
43 uint32_t handle,
45
47 uint32_t handle,
48 const uint8_t dev_type,
49 LivoxLidarEthernetPacket* data,
50 void* client_data);
51
53 return dispatcher_instance_;
54 }
55
56 private:
57 static LivoxDispatcher dispatcher_instance_;
58 std::map<uint32_t, PointCloudCallbackType> handle_callback_functions;
59 std::mutex mtx;
60};
61
62static void GlobalPointCloudCallback(
63 uint32_t handle,
64 const uint8_t dev_type,
65 LivoxLidarEthernetPacket* data,
66 void* client_data) {
67 auto* dispatcher_pointer = reinterpret_cast<LivoxDispatcher*>(client_data);
68 dispatcher_pointer->LivoxPointCloudCallback(
69 handle, dev_type, data, client_data);
70}
71
72} // namespace lidar
73} // namespace drivers
74} // namespace apollo
static LivoxDispatcher & GetLivoxDispatcherInstance()
std::function< void(uint32_t handle, const uint8_t dev_type, LivoxLidarEthernetPacket *data, void *client_data)> PointCloudCallbackType
void RegisterHandleDispatchCallback(uint32_t handle, PointCloudCallbackType cb)
void LivoxPointCloudCallback(uint32_t handle, const uint8_t dev_type, LivoxLidarEthernetPacket *data, void *client_data)
bool GetHandleFromIP(const std::string &ip, uint32_t &handle)
class register implement
Definition arena_queue.h:37