scenario_simulator_v2 C++ API
relative_distance_condition.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef OPENSCENARIO_INTERPRETER__SYNTAX__RELATIVE_DISTANCE_CONDITION_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__RELATIVE_DISTANCE_CONDITION_HPP_
17 
26 #include <pugixml.hpp>
27 
29 {
30 inline namespace syntax
31 {
32 /*
33  RelativeDistanceCondition (OpenSCENARIO XML 1.3)
34 
35  The current relative distance of a triggering entity/entities to a reference
36  entity is compared to a given value. The logical operator used for comparison
37  is defined in the rule attribute.
38 
39  <xsd:complexType name="RelativeDistanceCondition">
40  <xsd:attribute name="entityRef" type="String" use="required"/>
41  <xsd:attribute name="freespace" type="Boolean" use="required"/>
42  <xsd:attribute name="relativeDistanceType" type="RelativeDistanceType" use="required"/>
43  <xsd:attribute name="rule" type="Rule" use="required"/>
44  <xsd:attribute name="value" type="Double" use="required"/>
45  <xsd:attribute name="coordinateSystem" type="CoordinateSystem"/>
46  <xsd:attribute name="routingAlgorithm" type="RoutingAlgorithm"/>
47  </xsd:complexType>
48 */
50 {
51  /*
52  Definition of the coordinate system to be used for calculations. If not
53  provided the value is interpreted as "entity".
54  */
56 
57  /*
58  Reference entity.
59  */
61 
62  /*
63  True: distance is measured between closest bounding box points.
64  False: reference point distance is used.
65  */
67 
68  /*
69  Definition of the coordinate system dimension(s) to be used for
70  calculating distances.
71  */
73 
74  /*
75  Algorithm for path selection/calculation between two positions across roads. Only relevant, if CoordinateSystem is "road"/"lane". Default value if omitted: "undefined".
76  */
78 
79  /*
80  The operator (less, greater, equal).
81  */
82  const Rule rule;
83 
84  /*
85  The distance value. Unit: m; Range: [0..inf[.
86  */
87  const Double value;
88 
90 
91  std::vector<Double> results; // for description
92 
93  const bool consider_z;
94 
95  explicit RelativeDistanceCondition(const pugi::xml_node &, Scope &, const TriggeringEntities &);
96 
97  auto description() const -> String;
98 
99  template <
100  CoordinateSystem::value_type, RelativeDistanceType::value_type, RoutingAlgorithm::value_type,
101  Boolean::value_type>
102  auto distance(const EntityRef &) -> double
103  {
104  throw SyntaxError(__FILE__, ":", __LINE__);
105  }
106 
107  auto distance(const EntityRef &) -> double;
108 
109  auto evaluate() -> Object;
110 };
111 
112 // Ignore spell miss due to OpenSCENARIO standard.
113 // cspell: ignore euclidian
114 
115 // clang-format off
116 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::euclidianDistance, RoutingAlgorithm::undefined, false>(const EntityRef &) -> double;
117 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::euclidianDistance, RoutingAlgorithm::undefined, true >(const EntityRef &) -> double;
118 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::lateral, RoutingAlgorithm::undefined, false>(const EntityRef &) -> double;
119 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::lateral, RoutingAlgorithm::undefined, true >(const EntityRef &) -> double;
120 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::longitudinal, RoutingAlgorithm::undefined, false>(const EntityRef &) -> double;
121 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::longitudinal, RoutingAlgorithm::undefined, true >(const EntityRef &) -> double;
122 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::lateral, RoutingAlgorithm::undefined, false>(const EntityRef &) -> double;
123 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::lateral, RoutingAlgorithm::undefined, true >(const EntityRef &) -> double;
124 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::longitudinal, RoutingAlgorithm::undefined, false>(const EntityRef &) -> double;
125 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::longitudinal, RoutingAlgorithm::undefined, true >(const EntityRef &) -> double;
126 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::lateral, RoutingAlgorithm::shortest, false>(const EntityRef &) -> double;
127 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::lateral, RoutingAlgorithm::shortest, true >(const EntityRef &) -> double;
128 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::longitudinal, RoutingAlgorithm::shortest, false>(const EntityRef &) -> double;
129 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::longitudinal, RoutingAlgorithm::shortest, true >(const EntityRef &) -> double;
130 // clang-format on
131 } // namespace syntax
132 } // namespace openscenario_interpreter
133 
134 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__RELATIVE_DISTANCE_CONDITION_HPP_
Definition: scope.hpp:154
std::string String
Definition: string.hpp:24
Definition: escape_sequence.hpp:22
Pointer< Expression > Object
Definition: object.hpp:26
Definition: coordinate_system.hpp:50
Definition: entity_ref.hpp:35
Definition: relative_distance_condition.hpp:50
const bool consider_z
Definition: relative_distance_condition.hpp:93
const Rule rule
Definition: relative_distance_condition.hpp:82
auto evaluate() -> Object
Definition: relative_distance_condition.cpp:416
const RelativeDistanceType relative_distance_type
Definition: relative_distance_condition.hpp:72
auto description() const -> String
Definition: relative_distance_condition.cpp:57
RelativeDistanceCondition(const pugi::xml_node &, Scope &, const TriggeringEntities &)
Definition: relative_distance_condition.cpp:29
const CoordinateSystem coordinate_system
Definition: relative_distance_condition.hpp:55
auto distance(const EntityRef &) -> double
Definition: relative_distance_condition.hpp:102
const String entity_ref
Definition: relative_distance_condition.hpp:60
std::vector< Double > results
Definition: relative_distance_condition.hpp:91
const Double value
Definition: relative_distance_condition.hpp:87
const TriggeringEntities triggering_entities
Definition: relative_distance_condition.hpp:89
const RoutingAlgorithm routing_algorithm
Definition: relative_distance_condition.hpp:77
const Boolean freespace
Definition: relative_distance_condition.hpp:66
Definition: relative_distance_type.hpp:55
Definition: routing_algorithm.hpp:48
Definition: triggering_entities.hpp:39