26double MoveSForward(
double s,
double upper_bound) {
27 if (s > upper_bound) {
28 AERROR <<
"Illegal s: " << s <<
", upper bound: " << upper_bound;
34 return ((s + upper_bound) / 2.0);
38double MoveSBackward(
double s,
double lower_bound) {
39 if (s < lower_bound) {
40 AERROR <<
"Illegal s: " << s <<
", lower bound: " << lower_bound;
46 return ((s + lower_bound) / 2.0);
50void GetOutParallelLane(
const TopoNode* node,
51 std::unordered_set<const TopoNode*>*
const node_set) {
53 const auto* to_node = edge->ToNode();
54 if (node_set->count(to_node) == 0) {
55 node_set->emplace(to_node);
56 GetOutParallelLane(to_node, node_set);
61void GetInParallelLane(
const TopoNode* node,
62 std::unordered_set<const TopoNode*>*
const node_set) {
64 const auto* from_node = edge->FromNode();
65 if (node_set->count(from_node) == 0) {
66 node_set->emplace(from_node);
67 GetInParallelLane(from_node, node_set);
77 std::unordered_set<const TopoNode*> road_nodes_set;
79 for (
const auto& node : road_nodes_set) {
80 range_manager->
Add(node, 0.0, node->
Length());
90 const auto* node = graph->
GetNode(lane.id());
92 range_manager->
Add(node, lane.start_s(), lane.end_s());
97void AddBlackMapFromOutParallel(
const TopoNode* node,
double cut_ratio,
99 std::unordered_set<const TopoNode*> par_node_set;
100 GetOutParallelLane(node, &par_node_set);
101 par_node_set.erase(node);
102 for (
const auto* par_node : par_node_set) {
103 double par_cut_s = cut_ratio * par_node->Length();
104 range_manager->
Add(par_node, par_cut_s, par_cut_s);
108void AddBlackMapFromInParallel(
const TopoNode* node,
double cut_ratio,
110 std::unordered_set<const TopoNode*> par_node_set;
111 GetInParallelLane(node, &par_node_set);
112 par_node_set.erase(node);
113 for (
const auto* par_node : par_node_set) {
114 double par_cut_s = cut_ratio * par_node->Length();
115 range_manager->
Add(par_node, par_cut_s, par_cut_s);
124 AddBlackMapFromLane(request, graph, range_manager);
125 AddBlackMapFromRoad(request, graph, range_manager);
132 double start_length = src_node->
Length();
133 double end_length = dest_node->
Length();
135 static constexpr double kEpsilon = 1e-2;
136 const double start_s_adjusted =
137 (start_s > start_length && start_s - start_length <= kEpsilon)
140 const double end_s_adjusted =
141 (end_s > end_length && end_s - end_length <= kEpsilon) ? end_length
144 if (start_s_adjusted < 0.0 || start_s_adjusted > start_length) {
145 AERROR <<
"Illegal start_s: " << start_s <<
", length: " << start_length;
148 if (end_s_adjusted < 0.0 || end_s_adjusted > end_length) {
149 AERROR <<
"Illegal end_s: " << end_s <<
", length: " << end_length;
153 double start_cut_s = MoveSBackward(start_s_adjusted, 0.0);
154 range_manager->
Add(src_node, start_cut_s, start_cut_s);
155 AddBlackMapFromOutParallel(src_node, start_cut_s / start_length,
158 double end_cut_s = MoveSForward(end_s_adjusted, end_length);
159 range_manager->
Add(dest_node, end_cut_s, end_cut_s);
160 AddBlackMapFromInParallel(dest_node, end_cut_s / end_length, range_manager);
void AddBlackMapFromTerminal(const TopoNode *src_node, const TopoNode *dest_node, double start_s, double end_s, TopoRangeManager *const range_manager) const
void GenerateBlackMapFromRequest(const routing::RoutingRequest &request, const TopoGraph *graph, TopoRangeManager *const range_manager) const
void GetNodesByRoadId(const std::string &road_id, std::unordered_set< const TopoNode * > *const node_in_road) const
const TopoNode * GetNode(const std::string &id) const
const std::unordered_set< const TopoEdge * > & OutToLeftOrRightEdge() const
const std::unordered_set< const TopoEdge * > & InFromLeftOrRightEdge() const
void Add(const TopoNode *node, double start_s, double end_s)
constexpr double S_GAP_FOR_BLACK
repeated string blacklisted_road
repeated apollo::routing::LaneSegment blacklisted_lane