Apollo 11.0
自动驾驶开放平台
map_manager.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 "cyber/common/file.h"
20#include "cyber/common/log.h"
22
23namespace apollo {
24namespace perception {
25namespace lidar {
26
28 std::string config_file =
29 GetConfigFile(options.config_path, options.config_file);
30 MapManagerConfig config;
31 ACHECK(cyber::common::GetProtoFromFile(config_file, &config));
32 update_pose_ = config.update_pose();
33 roi_search_distance_ = config.roi_search_distance();
34 hdmap_input_ = map::HDMapInput::Instance();
35 if (!hdmap_input_->Init()) {
36 AINFO << "Failed to init hdmap input.";
37 return false;
38 }
39 return true;
40}
41
42bool MapManager::Update(const MapManagerOptions& options, LidarFrame* frame) {
43 if (!frame) {
44 AINFO << "Frame is nullptr.";
45 return false;
46 }
47 if (!(frame->hdmap_struct)) {
48 frame->hdmap_struct.reset(new base::HdmapStruct);
49 }
50 if (!hdmap_input_) {
51 AINFO << "Hdmap input is nullptr";
52 return false;
53 }
54 if (update_pose_) {
55 if (!QueryPose(&(frame->lidar2world_pose))) {
56 AINFO << "Failed to query updated pose.";
57 }
58 }
59 base::PointD point;
60 point.x = frame->lidar2world_pose.translation()(0);
61 point.y = frame->lidar2world_pose.translation()(1);
62 point.z = frame->lidar2world_pose.translation()(2);
63 if (!hdmap_input_->GetRoiHDMapStruct(point, roi_search_distance_,
64 frame->hdmap_struct)) {
65 frame->hdmap_struct->road_polygons.clear();
66 frame->hdmap_struct->road_boundary.clear();
67 frame->hdmap_struct->hole_polygons.clear();
68 frame->hdmap_struct->junction_polygons.clear();
69 AINFO << "Failed to get roi from hdmap.";
70 }
71 return true;
72}
73
74bool MapManager::QueryPose(Eigen::Affine3d* sensor2world_pose) const {
75 // TODO(...): map-based alignment to refine pose
76 return false;
77}
78
79} // namespace lidar
80} // namespace perception
81} // namespace apollo
bool QueryPose(Eigen::Affine3d *sensor2world_pose) const
Query the pose
bool Init(const MapManagerInitOptions &options=MapManagerInitOptions())
Init of Map Manager
bool Update(const MapManagerOptions &options, LidarFrame *frame)
update map structure and lidar2world pose
bool GetRoiHDMapStruct(const base::PointD &pointd, const double distance, std::shared_ptr< base::HdmapStruct > hdmap_struct_prt)
#define ACHECK(cond)
Definition log.h:80
#define AINFO
Definition log.h:42
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
Definition util.cc:80
class register implement
Definition arena_queue.h:37
std::shared_ptr< base::HdmapStruct > hdmap_struct
Definition lidar_frame.h:51