Apollo 10.0
自动驾驶开放平台
lidar_driver_factory.cc
浏览该文件的文档.
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
18
19// #include "modules/drivers/lidar/hesai/driver/driver.h"
20// #include "modules/drivers/lidar/rslidar/driver/driver.h"
22
23namespace apollo {
24namespace drivers {
25namespace lidar {
26
31// Register(LidarParameter::HESAI,
32// [](const std::shared_ptr<::apollo::cyber::Node>& node,
33// const apollo::drivers::lidar::config& config) -> LidarDriver* {
34// return new hesai::HesaiDriver(node, config);
35// });
36 // Register(LidarParameter::ROBOSENSE,
37 // [](const std::shared_ptr<::apollo::cyber::Node>& node,
38 // const apollo::drivers::lidar::config& config) -> LidarDriver*
39 // {
40 // return new robosense::RobosenseDriver(node, config);
41 // });
42 //
44 [](const std::shared_ptr<::apollo::cyber::Node>& node,
47 node, config.velodyne());
48 });
49}
50std::unique_ptr<LidarDriver> LidarDriverFactory::CreateLidarDriver(
51 const std::shared_ptr<::apollo::cyber::Node>& node,
52 const apollo::drivers::lidar::config& parameter) {
53 auto factory = CreateObject(parameter.brand(), node, parameter);
54 if (!factory) {
55 AERROR << "Failed to create lidar with parameter: "
56 << parameter.DebugString();
57 }
58 return factory;
59}
60
61} // namespace lidar
62} // namespace drivers
63} // namespace apollo
std::unique_ptr< LidarDriver > CreateObject(const LidarParameter::LidarBrand &id, Args &&... args)
Creates and transfers membership of an object of type matching id.
Definition factory.h:115
bool Register(const LidarParameter::LidarBrand &id, LidarDriver * creator)
Registers the class given by the creator function, linking it to id.
Definition factory.h:70
LidarDriverFactory(const apollo::drivers::lidar::config &config)
void RegisterLidarClients()
Register the lidar driver of all brands.
std::unique_ptr< LidarDriver > CreateLidarDriver(const std::shared_ptr<::apollo::cyber::Node > &node, const apollo::drivers::lidar::config &parameter)
Create a pointer to a specified brand of lidar.
The class which defines the lidar driver .
Definition driver_base.h:45
static VelodyneDriver * CreateDriver(const std::shared_ptr<::apollo::cyber::Node > &node, const Config &config)
Definition driver.cc:232
Defines the LidarFactory class.
#define AERROR
Definition log.h:44
class register implement
Definition arena_queue.h:37
optional apollo::drivers::velodyne::Config velodyne
Definition config.proto:12
optional LidarParameter::LidarBrand brand
Definition config.proto:10