scenario_simulator_v2 C++ API
dynamics_shape.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__DYNAMICS_SHAPE_HPP_
16 #define OPENSCENARIO_INTERPRETER__SYNTAX__DYNAMICS_SHAPE_HPP_
17 
18 #include <iostream>
21 
23 {
24 inline namespace syntax
25 {
26 /* ---- DynamicsShape ----------------------------------------------------------
27  *
28  * <xsd:simpleType name="DynamicsShape">
29  * <xsd:union>
30  * <xsd:simpleType>
31  * <xsd:restriction base="xsd:string">
32  * <xsd:enumeration value="linear"/>
33  * <xsd:enumeration value="cubic"/>
34  * <xsd:enumeration value="sinusoidal"/>
35  * <xsd:enumeration value="step"/>
36  * </xsd:restriction>
37  * </xsd:simpleType>
38  * <xsd:simpleType>
39  * <xsd:restriction base="parameter"/>
40  * </xsd:simpleType>
41  * </xsd:union>
42  * </xsd:simpleType>
43  *
44  * -------------------------------------------------------------------------- */
46 {
47  enum value_type {
48  /* ---- NOTE ---------------------------------------------------------------
49  *
50  * Value changes in a linear function:
51  *
52  * f(x) = f_0 + rate * x.
53  *
54  * ---------------------------------------------------------------------- */
56 
57  /* ---- NOTE ---------------------------------------------------------------
58  *
59  * Cubical transition
60  *
61  * f(x) = A * x^3 + B * x^2 + C * x + D
62  *
63  * with the constraint that the gradient must be zero at start and end.
64  *
65  * ---------------------------------------------------------------------- */
67 
68  /* ---- NOTE ---------------------------------------------------------------
69  *
70  * Sinusoidal transition
71  *
72  * f(x) = A * sin(x) + B
73  *
74  * with the constraint that the gradient must be zero at start and end.
75  *
76  * ---------------------------------------------------------------------- */
78 
79  /* ---- NOTE ---------------------------------------------------------------
80  *
81  * Step transition.
82  *
83  * ---------------------------------------------------------------------- */
85  } value;
86 
87  DynamicsShape() = default;
88 
89  constexpr operator value_type() const noexcept { return value; }
90 
91  explicit constexpr operator traffic_simulator::speed_change::Transition() const
92  {
93  switch (value) {
94  case linear:
96  case step:
98  default:
99  return {};
100  }
101  }
102 
103  explicit constexpr operator traffic_simulator::lane_change::TrajectoryShape() const
104  {
105  switch (value) {
106  case linear:
108  case cubic:
110  default:
111  return {};
112  }
113  }
114 };
115 
116 static_assert(std::is_standard_layout<DynamicsShape>::value, "");
117 
118 static_assert(std::is_trivial<DynamicsShape>::value, "");
119 
120 auto operator>>(std::istream &, DynamicsShape &) -> std::istream &;
121 
122 auto operator<<(std::ostream &, const DynamicsShape &) -> std::ostream &;
123 } // namespace syntax
124 } // namespace openscenario_interpreter
125 
126 #endif // OPENSCENARIO_INTERPRETER__SYNTAX__DYNAMICS_SHAPE_HPP_
auto operator>>(std::istream &, Boolean &) -> std::istream &
Definition: boolean.cpp:52
auto operator<<(std::ostream &, const Boolean &) -> std::ostream &
Definition: boolean.cpp:46
Definition: escape_sequence.hpp:22
TrajectoryShape
Definition: lane_change.hpp:31
Transition
Definition: speed_change.hpp:26
Definition: dynamics_shape.hpp:46
enum openscenario_interpreter::syntax::DynamicsShape::value_type value
value_type
Definition: dynamics_shape.hpp:47
@ step
Definition: dynamics_shape.hpp:84
@ cubic
Definition: dynamics_shape.hpp:66
@ linear
Definition: dynamics_shape.hpp:55
@ sinusoidal
Definition: dynamics_shape.hpp:77