Apollo
10.0
自动驾驶开放平台
topo_range.cc
浏览该文件的文档.
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
17
#include "
modules/routing/graph/topo_range.h
"
18
19
#include <algorithm>
20
21
#include "
modules/routing/common/routing_gflags.h
"
22
23
namespace
apollo
{
24
namespace
routing {
25
26
bool
NodeSRange::IsEnoughForChangeLane
(
double
start_s,
double
end_s) {
27
return
IsEnoughForChangeLane
(end_s - start_s);
28
}
29
30
bool
NodeSRange::IsEnoughForChangeLane
(
double
length) {
31
return
(length > FLAGS_min_length_for_lane_change);
32
}
33
34
NodeSRange::NodeSRange
(
double
s1,
double
s2) : start_s_(s1), end_s_(s2) {}
35
36
bool
NodeSRange::operator<
(
const
NodeSRange
& other)
const
{
37
return
StartS
() < other.
StartS
();
38
}
39
40
bool
NodeSRange::IsValid
()
const
{
return
start_s_ <= end_s_; }
41
42
double
NodeSRange::StartS
()
const
{
return
start_s_; }
43
44
double
NodeSRange::EndS
()
const
{
return
end_s_; }
45
46
double
NodeSRange::Length
()
const
{
return
end_s_ - start_s_; }
47
48
bool
NodeSRange::IsEnoughForChangeLane
()
const
{
49
return
NodeSRange::IsEnoughForChangeLane
(
StartS
(),
EndS
());
50
}
51
52
void
NodeSRange::SetStartS
(
double
start_s) { start_s_ = start_s; }
53
54
void
NodeSRange::SetEndS
(
double
end_s) { end_s_ = end_s; }
55
56
bool
NodeSRange::MergeRangeOverlap
(
const
NodeSRange
& other) {
57
if
(!
IsValid
() || !other.
IsValid
()) {
58
return
false
;
59
}
60
if
(other.
StartS
() >
EndS
() || other.
EndS
() <
StartS
()) {
61
return
false
;
62
}
63
SetEndS
(std::max(
EndS
(), other.
EndS
()));
64
SetStartS
(std::min(
StartS
(), other.
StartS
()));
65
return
true
;
66
}
67
68
}
// namespace routing
69
}
// namespace apollo
apollo::routing::NodeSRange
Definition
topo_range.h:22
apollo::routing::NodeSRange::IsValid
bool IsValid() const
Definition
topo_range.cc:40
apollo::routing::NodeSRange::IsEnoughForChangeLane
bool IsEnoughForChangeLane() const
Definition
topo_range.cc:48
apollo::routing::NodeSRange::EndS
double EndS() const
Definition
topo_range.cc:44
apollo::routing::NodeSRange::SetEndS
void SetEndS(double end_s)
Definition
topo_range.cc:54
apollo::routing::NodeSRange::Length
double Length() const
Definition
topo_range.cc:46
apollo::routing::NodeSRange::MergeRangeOverlap
bool MergeRangeOverlap(const NodeSRange &other)
Definition
topo_range.cc:56
apollo::routing::NodeSRange::SetStartS
void SetStartS(double start_s)
Definition
topo_range.cc:52
apollo::routing::NodeSRange::StartS
double StartS() const
Definition
topo_range.cc:42
apollo::routing::NodeSRange::NodeSRange
NodeSRange()=default
apollo::routing::NodeSRange::operator<
bool operator<(const NodeSRange &other) const
Definition
topo_range.cc:36
apollo
class register implement
Definition
arena_queue.h:37
routing_gflags.h
topo_range.h
modules
routing
graph
topo_range.cc