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 
27 #include <pugixml.hpp>
28 #include <valarray>
29 
31 {
32 inline namespace syntax
33 {
34 /*
35  RelativeDistanceCondition (OpenSCENARIO XML 1.3)
36 
37  The current relative distance of a triggering entity/entities to a reference
38  entity is compared to a given value. The logical operator used for comparison
39  is defined in the rule attribute.
40 
41  <xsd:complexType name="RelativeDistanceCondition">
42  <xsd:attribute name="entityRef" type="String" use="required"/>
43  <xsd:attribute name="freespace" type="Boolean" use="required"/>
44  <xsd:attribute name="relativeDistanceType" type="RelativeDistanceType" use="required"/>
45  <xsd:attribute name="rule" type="Rule" use="required"/>
46  <xsd:attribute name="value" type="Double" use="required"/>
47  <xsd:attribute name="coordinateSystem" type="CoordinateSystem"/>
48  <xsd:attribute name="routingAlgorithm" type="RoutingAlgorithm"/>
49  </xsd:complexType>
50 */
52 {
53  /*
54  Definition of the coordinate system to be used for calculations. If not
55  provided the value is interpreted as "entity".
56  */
58 
59  /*
60  Reference entity.
61  */
63 
64  /*
65  True: distance is measured between closest bounding box points.
66  False: reference point distance is used.
67  */
69 
70  /*
71  Definition of the coordinate system dimension(s) to be used for
72  calculating distances.
73  */
75 
76  /*
77  Algorithm for path selection/calculation between two positions across roads. Only relevant, if CoordinateSystem is "road"/"lane". Default value if omitted: "undefined".
78  */
80 
81  /*
82  The operator (less, greater, equal).
83  */
84  const Rule rule;
85 
86  /*
87  The distance value. Unit: m; Range: [0..inf[.
88  */
89  const Double value;
90 
92 
93  std::vector<std::valarray<double>> results; // for description
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  static auto distance(const EntityRef &, const EntityRef &) -> double
103  {
104  throw SyntaxError(__FILE__, ":", __LINE__);
105  }
106 
107  static auto evaluate(
108  const Entities *, const Entity &, const Entity &, CoordinateSystem, RelativeDistanceType,
109  RoutingAlgorithm, Boolean) -> double;
110 
111  auto evaluate() -> Object;
112 };
113 
114 // Ignore spell miss due to OpenSCENARIO standard.
115 // cspell: ignore euclidian
116 
117 // clang-format off
118 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::euclidianDistance, RoutingAlgorithm::undefined, false>(const EntityRef &, const EntityRef &) -> double;
119 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::euclidianDistance, RoutingAlgorithm::undefined, true >(const EntityRef &, const EntityRef &) -> double;
120 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::lateral, RoutingAlgorithm::undefined, false>(const EntityRef &, const EntityRef &) -> double;
121 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::lateral, RoutingAlgorithm::undefined, true >(const EntityRef &, const EntityRef &) -> double;
122 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::longitudinal, RoutingAlgorithm::undefined, false>(const EntityRef &, const EntityRef &) -> double;
123 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::longitudinal, RoutingAlgorithm::undefined, true >(const EntityRef &, const EntityRef &) -> double;
124 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::lateral, RoutingAlgorithm::undefined, false>(const EntityRef &, const EntityRef &) -> double;
125 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::lateral, RoutingAlgorithm::undefined, true >(const EntityRef &, const EntityRef &) -> double;
126 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::longitudinal, RoutingAlgorithm::undefined, false>(const EntityRef &, const EntityRef &) -> double;
127 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::longitudinal, RoutingAlgorithm::undefined, true >(const EntityRef &, const EntityRef &) -> double;
128 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::lateral, RoutingAlgorithm::shortest, false>(const EntityRef &, const EntityRef &) -> double;
129 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::lateral, RoutingAlgorithm::shortest, true >(const EntityRef &, const EntityRef &) -> double;
130 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::longitudinal, RoutingAlgorithm::shortest, false>(const EntityRef &, const EntityRef &) -> double;
131 template <> auto RelativeDistanceCondition::distance<CoordinateSystem::lane, RelativeDistanceType::longitudinal, RoutingAlgorithm::shortest, true >(const EntityRef &, const EntityRef &) -> double;
132 // clang-format on
133 } // namespace syntax
134 } // namespace openscenario_interpreter
135 
136 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__RELATIVE_DISTANCE_CONDITION_HPP_
Definition: scope.hpp:154
std::string String
Definition: string.hpp:24
Definition: hypot.hpp:22
Pointer< Expression > Object
Definition: object.hpp:26
Definition: coordinate_system.hpp:50
Definition: entity_ref.hpp:35
Definition: relative_distance_condition.hpp:52
const Rule rule
Definition: relative_distance_condition.hpp:84
auto evaluate() -> Object
Definition: relative_distance_condition.cpp:332
const RelativeDistanceType relative_distance_type
Definition: relative_distance_condition.hpp:74
const Entity entity_ref
Definition: relative_distance_condition.hpp:62
auto description() const -> String
Definition: relative_distance_condition.cpp:53
RelativeDistanceCondition(const pugi::xml_node &, Scope &, const TriggeringEntities &)
Definition: relative_distance_condition.cpp:30
std::vector< std::valarray< double > > results
Definition: relative_distance_condition.hpp:93
const CoordinateSystem coordinate_system
Definition: relative_distance_condition.hpp:57
const Double value
Definition: relative_distance_condition.hpp:89
const TriggeringEntities triggering_entities
Definition: relative_distance_condition.hpp:91
const RoutingAlgorithm routing_algorithm
Definition: relative_distance_condition.hpp:79
static auto distance(const EntityRef &, const EntityRef &) -> double
Definition: relative_distance_condition.hpp:102
const Boolean freespace
Definition: relative_distance_condition.hpp:68
Definition: relative_distance_type.hpp:55
Definition: routing_algorithm.hpp:48
Definition: triggering_entities.hpp:40