Apollo 10.0
自动驾驶开放平台
route_segments.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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
21#pragma once
22
23#include <limits>
24#include <string>
25#include <vector>
26
27#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
28#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
29#include "modules/common_msgs/routing_msgs/routing.pb.h"
30
33
34namespace apollo {
35namespace hdmap {
36
48class RouteSegments : public std::vector<LaneSegment> {
49 public:
53 RouteSegments() = default;
54
67
80
85 bool CanExit() const;
86 void SetCanExit(bool can_exit);
87
97 bool GetProjection(const common::PointENU &point_enu,
98 common::SLPoint *sl_point, LaneWaypoint *waypoint) const;
99 bool GetProjection(const common::math::Vec2d &point,
100 common::SLPoint *sl_point, LaneWaypoint *waypoint) const;
101 bool GetProjection(const common::math::Vec2d &point, const double heading,
102 common::SLPoint *sl_point, LaneWaypoint *waypoint) const;
103
104 bool GetWaypoint(const double s, LaneWaypoint *waypoint) const;
105
113 bool CanDriveFrom(const LaneWaypoint &waypoint) const;
114
115 /*
116 * This is the point that is the end of the original passage in routing.
117 * It is used to check if the vehicle is out of current routing.
118 * The LaneWaypoint.lane is nullptr if the end of the passage is not on the
119 * RouteSegment.
120 */
121 const LaneWaypoint &RouteEndWaypoint() const;
122 void SetRouteEndWaypoint(const LaneWaypoint &waypoint);
123
141 bool Stitch(const RouteSegments &other);
142
143 bool Shrink(const common::math::Vec2d &point, const double look_backward,
144 const double look_forward);
145
146 bool Shrink(const double s, const double look_backward,
147 const double look_forward);
148
149 bool Shrink(const double s, const LaneWaypoint &waypoint,
150 const double look_backward, const double look_forward);
151
152 bool IsOnSegment() const;
153 void SetIsOnSegment(bool on_segment);
154
155 bool IsNeighborSegment() const;
156 void SetIsNeighborSegment(bool is_neighbor);
157
158 void SetId(const std::string &id);
159 const std::string &Id() const;
160
165
170
174 bool IsWaypointOnSegment(const LaneWaypoint &waypoint) const;
175
181 bool IsConnectedSegment(const RouteSegments &other) const;
182
183 bool StopForDestination() const;
184 void SetStopForDestination(bool stop_for_destination);
185
189 void SetProperties(const RouteSegments &other);
190
191 static bool WithinLaneSegment(const LaneSegment &lane_segment,
192 const LaneWaypoint &waypoint);
193
194 static bool WithinLaneSegment(const LaneSegment &lane_segment,
195 const routing::LaneWaypoint &waypoint);
196
197 static bool WithinLaneSegment(const routing::LaneSegment &lane_segment,
198 const LaneWaypoint &waypoint);
199
200 static bool WithinLaneSegment(const routing::LaneSegment &lane_segment,
201 const routing::LaneWaypoint &waypoint);
202
203 static double Length(const RouteSegments &segments);
204 std::string DebugString() {
205 std::stringstream ss;
206 for (auto iter = begin(); iter != end(); ++iter) {
207 ss << iter->DebugString() << ";";
208 }
209 return ss.str();
210 }
211
212 private:
213 LaneWaypoint route_end_waypoint_;
214
218 bool can_exit_ = false;
219
223 bool is_on_segment_ = false;
224
229 bool is_neighbor_ = false;
230
232
233 routing::ChangeLaneType previous_action_ = routing::FORWARD;
234
235 std::string id_;
236
242 bool stop_for_destination_ = false;
243};
244
245} // namespace hdmap
246} // namespace apollo
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
void SetId(const std::string &id)
bool GetWaypoint(const double s, LaneWaypoint *waypoint) const
bool Stitch(const RouteSegments &other)
Stitch current route segments with the other route segment.
void SetStopForDestination(bool stop_for_destination)
bool Shrink(const common::math::Vec2d &point, const double look_backward, const double look_forward)
bool IsWaypointOnSegment(const LaneWaypoint &waypoint) const
Check if a waypoint is on segment
RouteSegments()=default
The default constructor.
const std::string & Id() const
LaneWaypoint LastWaypoint() const
Get the last waypoint from the lane segments.
bool IsConnectedSegment(const RouteSegments &other) const
Check if we can reach the other segment from current segment just by following lane.
void SetIsNeighborSegment(bool is_neighbor)
void SetProperties(const RouteSegments &other)
Copy the properties of other segments to current one
LaneWaypoint FirstWaypoint() const
Get the first waypoint from the lane segments.
bool CanExit() const
Whether the passage region that generate this route segment can lead to another passage region in rou...
void SetRouteEndWaypoint(const LaneWaypoint &waypoint)
void SetIsOnSegment(bool on_segment)
static bool WithinLaneSegment(const LaneSegment &lane_segment, const LaneWaypoint &waypoint)
bool CanDriveFrom(const LaneWaypoint &waypoint) const
Check whether the map allows a vehicle can reach current RouteSegment from a point on a lane (LaneWay...
void SetPreviousAction(routing::ChangeLaneType action)
routing::ChangeLaneType PreviousAction() const
Get the previous change lane action need to take by the vehicle to reach current segment,...
static double Length(const RouteSegments &segments)
const LaneWaypoint & RouteEndWaypoint() const
routing::ChangeLaneType NextAction() const
Get the next change lane action need to take by the vehicle, if the vehicle is on this RouteSegments.
bool GetProjection(const common::PointENU &point_enu, common::SLPoint *sl_point, LaneWaypoint *waypoint) const
Project a point to this route segment.
void SetCanExit(bool can_exit)
void SetNextAction(routing::ChangeLaneType action)
class register implement
Definition arena_queue.h:37