Apollo 10.0
自动驾驶开放平台
navigation_lane.h
浏览该文件的文档.
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
22#pragma once
23
24#include <list>
25#include <memory>
26#include <tuple>
27#include <unordered_map>
28#include <utility>
29
30#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
32#include "modules/common_msgs/localization_msgs/localization.pb.h"
33#include "modules/common_msgs/planning_msgs/navigation.pb.h"
34#include "modules/map/relative_map/proto/relative_map_config.pb.h"
35#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
36
41namespace apollo {
42namespace relative_map {
43
44// A navigation path tuple.
45//
46// first element: original navigation line index of the current navigation path.
47// A negative value indicates illegal.
48//
49// second element: half of the lateral distance to the left adjacent navigation
50// path, that is, the left width of the lane generated by this navigation path.
51// If the navigation path is generated based on lane markers, the value is the
52// perceived left lane width. If there is no left adjacent navigation path, the
53// value is "default_left_width_". A negative value indicates illegal.
54//
55// third element: half of the lateral distance to the right adjacent navigation
56// path, that is, the right width of the lane generated by this navigation path.
57// If the navigation path is generated based on lane markers, the value is the
58// perceived right lane width. If there is no right adjacent navigation path,
59// the value is "default_right_width_". A negative value indicates illegal.
60//
61// fourth element : a shared pointer of the current navigation path.
62typedef std::tuple<int, double, double, std::shared_ptr<NavigationPath>>
64
65// A stitching index pair.
66// pair.first: the start stitching index of the current navigation line.
67// pair.second: the end stitching index of the current navigation line.
68typedef std::pair<int, int> StitchIndexPair;
69
70// A projection index pair.
71// pair.first: projection index of the vehicle in the current navigation line.
72// pair.second: the distance between the vehicle's initial position and the
73// projection position in the current navigation line.
74typedef std::pair<int, double> ProjIndexPair;
75
98 public:
99 NavigationLane() = default;
100 explicit NavigationLane(const NavigationLaneConfig& config);
101 ~NavigationLane() = default;
102
108 void SetConfig(const NavigationLaneConfig& config);
109
111 common::VehicleStateProvider* vehicle_state_provider);
112
118 void UpdateNavigationInfo(const NavigationInfo& navigation_info);
119
126 void SetDefaultWidth(const double left_width, const double right_width) {
127 default_left_width_ = left_width;
128 default_right_width_ = right_width;
129 }
130
136 bool GeneratePath();
137
144 const perception::PerceptionObstacles& perception_obstacles) {
145 perception_obstacles_ = perception_obstacles;
146 }
147
155 const auto& current_navi_path = std::get<3>(current_navi_path_tuple_);
156 if (current_navi_path) {
157 return *current_navi_path;
158 }
159 return NavigationPath();
160 }
161
170 bool CreateMap(const MapGenerationParam& map_config,
171 MapMsg* const map_msg) const;
172
173 private:
184 double EvaluateCubicPolynomial(const double c0, const double c1,
185 const double c2, const double c3,
186 const double x) const;
187
197 double GetKappa(const double c1, const double c2, const double c3,
198 const double x);
199
210 common::PathPoint GetPathPointByS(const common::Path& path,
211 const int start_index, const double s,
212 int* const matched_index);
213
221 void ConvertLaneMarkerToPath(const perception::LaneMarkers& lane_marker,
222 common::Path* const path);
223
233 bool ConvertNavigationLineToPath(const int line_index,
234 common::Path* const path);
235
243 void MergeNavigationLineAndLaneMarker(const int line_index,
244 common::Path* const path);
245
255 ProjIndexPair UpdateProjectionIndex(const common::Path& path,
256 const int line_index);
257
265 void UpdateStitchIndexInfo();
266
267 private:
268 // the configuration information required by the `NavigationLane`
269 NavigationLaneConfig config_;
270
271 // received from topic: /apollo/perception_obstacles
272 perception::PerceptionObstacles perception_obstacles_;
273
274 // received from topic: /apollo/navigation
275 NavigationInfo navigation_info_;
276
277 // navigation_path_list_ is a list of navigation paths. The internal paths
278 // are arranged from left to right based on the vehicle's driving direction.
279 // A navigation path is the combined results from perception and navigation.
280 std::list<NaviPathTuple> navigation_path_list_;
281
282 // the navigation path which the vehicle is currently on.
283 NaviPathTuple current_navi_path_tuple_;
284
285 // when invalid, left_width_ < 0
286 double perceived_left_width_ = -1.0;
287
288 // when invalid, right_width_ < 0
289 double perceived_right_width_ = -1.0;
290
291 // The standard lane width of China's expressway is 3.75 meters.
292 double default_left_width_ = 1.875;
293 double default_right_width_ = 1.875;
294
295 // key: line index,
296 // value: last projection index pair in the "key" line.
297 std::unordered_map<int, ProjIndexPair> last_project_index_map_;
298
299 // key: line index,
300 // value: stitching index pair in the "key" line.
301 std::unordered_map<int, StitchIndexPair> stitch_index_map_;
302
303 // in world coordination: ENU
304 localization::Pose original_pose_;
305 common::VehicleStateProvider* vehicle_state_provider_ = nullptr;
306};
307
308} // namespace relative_map
309} // namespace apollo
NavigationLane generates a real-time relative map based on navagation lines.
void SetConfig(const NavigationLaneConfig &config)
Set the configuration information required by the NavigationLane.
bool GeneratePath()
Generate a suitable path (i.e.
void SetDefaultWidth(const double left_width, const double right_width)
Set the default width of a lane.
void UpdatePerception(const perception::PerceptionObstacles &perception_obstacles)
Update perceived lane line information.
void SetVehicleStateProvider(common::VehicleStateProvider *vehicle_state_provider)
NavigationPath Path() const
Get the generated lane segment where the vehicle is currently located.
bool CreateMap(const MapGenerationParam &map_config, MapMsg *const map_msg) const
Generate a real-time relative map of approximately 250 m in length based on several navigation line s...
void UpdateNavigationInfo(const NavigationInfo &navigation_info)
Update navigation line information.
std::tuple< int, double, double, std::shared_ptr< NavigationPath > > NaviPathTuple
std::pair< int, double > ProjIndexPair
std::pair< int, int > StitchIndexPair
class register implement
Definition arena_queue.h:37