etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
denm_getters.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
3
8
9#pragma once
10
11namespace etsi_its_denm_msgs::access {
12
14
16
20 * @param denm DENM to get the Heading-Value from
21 * @return heading value in degree as decimal number
22 */
23inline double getHeading(const DENM& denm) {
24 if (denm.denm.location_is_present) {
25 if (denm.denm.location.event_position_heading_is_present) {
26 return getHeadingCDD(denm.denm.location.event_position_heading);
27 } else {
28 throw std::invalid_argument("Heading is not present!");
29 }
30 } else {
31 throw std::invalid_argument("LocationContainer is not present!");
32 }
33}
34
41inline double getHeadingConfidence(const DENM& denm) {
42 if (denm.denm.location_is_present) {
43 if (denm.denm.location.event_position_heading_is_present) {
44 return getHeadingConfidenceCDD(denm.denm.location.event_position_heading);
45 } else {
46 throw std::invalid_argument("Heading is not present!");
47 }
48 } else {
49 throw std::invalid_argument("LocationContainer is not present!");
50 }
51}
54
59inline uint8_t getCauseCode(const DENM& denm) { return denm.denm.situation.event_type.cause_code.value; }
67inline uint8_t getSubCauseCode(const DENM& denm) { return denm.denm.situation.event_type.sub_cause_code.value; }
69/**
70 * @brief Get the Cause Code Type object
71 *
72 * https://www.etsi.org/deliver/etsi_en/302600_302699/30263703/01.02.01_30/en_30263703v010201v.pdf
73 *
74 * @param denm DENM to get the causeCodeType value from
75 * @return causeCodeType value
76 */
77inline std::string getCauseCodeType(const DENM& denm) {
78 if (denm.denm.situation_is_present) {
79 int cause_code = getCauseCode(denm);
80 std::string cause_code_type = "undefined";
81
82 if (cause_code == CauseCodeType().TRAFFIC_CONDITION)
83 cause_code_type = "traffic condition";
84 else if (cause_code == CauseCodeType().ACCIDENT)
85 cause_code_type = "accident";
86 else if (cause_code == CauseCodeType().ROADWORKS)
87 cause_code_type = "roadworks";
88 else if (cause_code == CauseCodeType().IMPASSABILITY)
89 cause_code_type = "impassibility";
90 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_ADHESION)
91 cause_code_type = "adverse weather condition - adhesion";
92 else if (cause_code == CauseCodeType().AQUAPLANNNING)
93 cause_code_type = "aquaplanning";
94 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_SURFACE_CONDITION)
95 cause_code_type = "hazardous location - surface condition";
96 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_OBSTACLE_ON_THE_ROAD)
97 cause_code_type = "hazardous location - obstacle on the road";
98 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_ANIMAL_ON_THE_ROAD)
99 cause_code_type = "hazardous location - animal on the road";
100 else if (cause_code == CauseCodeType().HUMAN_PRESENCE_ON_THE_ROAD)
101 cause_code_type = "human presence on the road";
102 else if (cause_code == CauseCodeType().WRONG_WAY_DRIVING)
103 cause_code_type = "wrong way driving";
104 else if (cause_code == CauseCodeType().RESCUE_AND_RECOVERY_WORK_IN_PROGRESS)
105 cause_code_type = "rescue and recovery in progress";
106 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_EXTREME_WEATHER_CONDITION)
107 cause_code_type = "adverse weather condition - extreme weather condition";
108 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_VISIBILITY)
109 cause_code_type = "adverse weather condition - visibility";
110 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_PRECIPITATION)
111 cause_code_type = "adverse weather condition - precipitation";
112 else if (cause_code == CauseCodeType().SLOW_VEHICLE)
113 cause_code_type = "slow vehicle";
114 else if (cause_code == CauseCodeType().DANGEROUS_END_OF_QUEUE)
115 cause_code_type = "dangerous end of queue";
116 else if (cause_code == CauseCodeType().VEHICLE_BREAKDOWN)
117 cause_code_type = "vehicle breakdown";
118 else if (cause_code == CauseCodeType().POST_CRASH)
119 cause_code_type = "post crash";
120 else if (cause_code == CauseCodeType().HUMAN_PROBLEM)
121 cause_code_type = "human problem";
122 else if (cause_code == CauseCodeType().STATIONARY_VEHICLE)
123 cause_code_type = "stationary vehicle";
124 else if (cause_code == CauseCodeType().EMERGENCY_VEHICLE_APPROACHING)
125 cause_code_type = "emergency vehicle approaching";
126 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_DANGEROUS_CURVE)
127 cause_code_type = "hazardous location - dangerous curve";
128 else if (cause_code == CauseCodeType().COLLISION_RISK)
129 cause_code_type = "collision risk";
130 else if (cause_code == CauseCodeType().SIGNAL_VIOLATION)
131 cause_code_type = "signal violation";
132 else if (cause_code == CauseCodeType().DANGEROUS_SITUATION)
133 cause_code_type = "dangerous situation";
134
135 return cause_code_type;
136 } else {
137 throw std::invalid_argument("SituationContainer is not present!");
138 }
139}
140
146 * @param denm DENM to get the subCauseCodeType value from
147 * @return causeCodeType value
148 */
149inline std::string getSubCauseCodeType(const DENM& denm) {
150 if (denm.denm.situation_is_present) {
151 int cause_code = getCauseCode(denm);
152 int sub_cause_code = getSubCauseCode(denm);
153 std::string sub_cause_code_type = "undefined";
154 if (cause_code == CauseCodeType().TRAFFIC_CONDITION) {
155 if (sub_cause_code == 0)
156 sub_cause_code_type = "unavailable";
157 else if (sub_cause_code == 1)
158 sub_cause_code_type = "not defined";
159 else if (sub_cause_code == 2)
160 sub_cause_code_type = "traffic jam slowly increasing";
161 else if (sub_cause_code == 3)
162 sub_cause_code_type = "traffic jam increasing";
163 else if (sub_cause_code == 4)
164 sub_cause_code_type = "traffic jam strongly increasing";
165 else if (sub_cause_code == 5)
166 sub_cause_code_type = "traffic stationary";
167 else if (sub_cause_code == 6)
168 sub_cause_code_type = "traffic jam slightly decreasing";
169 else if (sub_cause_code == 7)
170 sub_cause_code_type = "traffic jam decreasing";
171 else if (sub_cause_code == 8)
172 sub_cause_code_type = "traffic jam strongly decreasing";
173 } else if (cause_code == CauseCodeType().ACCIDENT) {
174 if (sub_cause_code == 0)
175 sub_cause_code_type = "unavailable";
176 else if (sub_cause_code >= 1 && sub_cause_code <= 7)
177 sub_cause_code_type = "not defined";
178 else if (sub_cause_code == 8)
179 sub_cause_code_type = "assistance requested (e-Call)";
180 } else if (cause_code == CauseCodeType().ROADWORKS) {
181 if (sub_cause_code == 0)
182 sub_cause_code_type = "unavailable";
183 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
184 sub_cause_code_type = "not defined";
185 else if (sub_cause_code == 4)
186 sub_cause_code_type = "short-term stationary roadworks";
187 else if (sub_cause_code == 5)
188 sub_cause_code_type = "street cleaning";
189 else if (sub_cause_code == 6)
190 sub_cause_code_type = "winter service";
191 } else if (cause_code == CauseCodeType().IMPASSABILITY)
192 sub_cause_code_type = "not defined";
193 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_ADHESION) {
194 if (sub_cause_code == 0)
195 sub_cause_code_type = "unavailable";
196 else if (sub_cause_code >= 1 && sub_cause_code <= 10)
197 sub_cause_code_type = "not defined";
198 } else if (cause_code == CauseCodeType().AQUAPLANNNING)
199 sub_cause_code_type = "not defined";
200 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_SURFACE_CONDITION) {
201 if (sub_cause_code == 0)
202 sub_cause_code_type = "unavailable";
203 else if (sub_cause_code >= 1 && sub_cause_code <= 9)
204 sub_cause_code_type = "not defined";
205 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_OBSTACLE_ON_THE_ROAD) {
206 if (sub_cause_code == 0)
207 sub_cause_code_type = "unavailable";
208 else if (sub_cause_code >= 1 && sub_cause_code <= 7)
209 sub_cause_code_type = "not defined";
210 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_ANIMAL_ON_THE_ROAD) {
211 if (sub_cause_code == 0)
212 sub_cause_code_type = "unavailable";
213 else if (sub_cause_code >= 1 && sub_cause_code <= 4)
214 sub_cause_code_type = "not defined";
215 } else if (cause_code == CauseCodeType().HUMAN_PRESENCE_ON_THE_ROAD) {
216 if (sub_cause_code == 0)
217 sub_cause_code_type = "unavailable";
218 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
219 sub_cause_code_type = "not defined";
220 } else if (cause_code == CauseCodeType().WRONG_WAY_DRIVING) {
221 if (sub_cause_code == 0)
222 sub_cause_code_type = "unavailable";
223 else if (sub_cause_code == 1)
224 sub_cause_code_type = "vehicle driving in wrong lane";
225 else if (sub_cause_code == 2)
226 sub_cause_code_type = "vehicle driving in wrong driving direction";
227 } else if (cause_code == CauseCodeType().RESCUE_AND_RECOVERY_WORK_IN_PROGRESS) {
228 if (sub_cause_code == 0)
229 sub_cause_code_type = "unavailable";
230 else if (sub_cause_code >= 1 && sub_cause_code <= 5)
231 sub_cause_code_type = "not defined";
232 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_EXTREME_WEATHER_CONDITION) {
233 if (sub_cause_code == 0)
234 sub_cause_code_type = "unavailable";
235 else if (sub_cause_code >= 1 && sub_cause_code <= 6)
236 sub_cause_code_type = "not defined";
237 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_VISIBILITY) {
238 if (sub_cause_code == 0)
239 sub_cause_code_type = "unavailable";
240 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
241 sub_cause_code_type = "not defined";
242 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_PRECIPITATION) {
243 if (sub_cause_code == 0)
244 sub_cause_code_type = "unavailable";
245 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
246 sub_cause_code_type = "not defined";
247 } else if (cause_code == CauseCodeType().SLOW_VEHICLE) {
248 if (sub_cause_code == 0)
249 sub_cause_code_type = "unavailable";
250 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
251 sub_cause_code_type = "not defined";
252 } else if (cause_code == CauseCodeType().DANGEROUS_END_OF_QUEUE) {
253 if (sub_cause_code == 0)
254 sub_cause_code_type = "unavailable";
255 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
256 sub_cause_code_type = "not defined";
257 } else if (cause_code == CauseCodeType().VEHICLE_BREAKDOWN) {
258 if (sub_cause_code == 0)
259 sub_cause_code_type = "unavailable";
260 else if (sub_cause_code == 1)
261 sub_cause_code_type = "lack of fuel";
262 else if (sub_cause_code == 2)
263 sub_cause_code_type = "lack of battery";
264 else if (sub_cause_code == 3)
265 sub_cause_code_type = "engine problem";
266 else if (sub_cause_code == 4)
267 sub_cause_code_type = "transmission problem";
268 else if (sub_cause_code == 5)
269 sub_cause_code_type = "engine cooling problem";
270 else if (sub_cause_code == 6)
271 sub_cause_code_type = "braking system problem";
272 else if (sub_cause_code == 7)
273 sub_cause_code_type = "steering problem";
274 else if (sub_cause_code == 8)
275 sub_cause_code_type = "tyre puncture";
276 } else if (cause_code == CauseCodeType().POST_CRASH) {
277 if (sub_cause_code == 0)
278 sub_cause_code_type = "unavailable";
279 else if (sub_cause_code == 1)
280 sub_cause_code_type = "accident without e-Call triggered";
281 else if (sub_cause_code == 2)
282 sub_cause_code_type = "accident with e-Call manually triggered";
283 else if (sub_cause_code == 3)
284 sub_cause_code_type = "accident with e-Call automatical triggered";
285 else if (sub_cause_code == 4)
286 sub_cause_code_type = "accident with e-Call triggered without a possible access to a cell network";
287 } else if (cause_code == CauseCodeType().HUMAN_PROBLEM) {
288 if (sub_cause_code == 0)
289 sub_cause_code_type = "unavailable";
290 else if (sub_cause_code == 1)
291 sub_cause_code_type = "glycaemia problem";
292 else if (sub_cause_code == 2)
293 sub_cause_code_type = "heart problem";
294 } else if (cause_code == CauseCodeType().STATIONARY_VEHICLE) {
295 if (sub_cause_code == 0)
296 sub_cause_code_type = "unavailable";
297 else if (sub_cause_code == 1)
298 sub_cause_code_type = "human problem";
299 else if (sub_cause_code == 2)
300 sub_cause_code_type = "vehicle breakdown";
301 else if (sub_cause_code == 3)
302 sub_cause_code_type = "post crash";
303 else if (sub_cause_code == 4)
304 sub_cause_code_type = "public transport stop";
305 else if (sub_cause_code == 5)
306 sub_cause_code_type = "carrying dangerous goods";
307 } else if (cause_code == CauseCodeType().EMERGENCY_VEHICLE_APPROACHING) {
308 if (sub_cause_code == 0)
309 sub_cause_code_type = "unavailable";
310 else if (sub_cause_code == 1)
311 sub_cause_code_type = "emergency vehicle approaching";
312 else if (sub_cause_code == 2)
313 sub_cause_code_type = "prioritized vehicle approaching";
314 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_DANGEROUS_CURVE) {
315 if (sub_cause_code == 0)
316 sub_cause_code_type = "unavailable";
317 else if (sub_cause_code == 1)
318 sub_cause_code_type = "dangerous left turn curve";
319 else if (sub_cause_code == 2)
320 sub_cause_code_type = "dangerous right turn curve";
321 else if (sub_cause_code == 3)
322 sub_cause_code_type = "multiple curves starting with unknown turning direction";
323 else if (sub_cause_code == 4)
324 sub_cause_code_type = "multiple curves starting with left turn";
325 else if (sub_cause_code == 5)
326 sub_cause_code_type = "multiple curves starting with right turn";
327 } else if (cause_code == CauseCodeType().COLLISION_RISK) {
328 if (sub_cause_code == 0)
329 sub_cause_code_type = "unavailable";
330 else if (sub_cause_code == 1)
331 sub_cause_code_type = "longitudinal collision risk";
332 else if (sub_cause_code == 2)
333 sub_cause_code_type = "crossing collision risk";
334 else if (sub_cause_code == 3)
335 sub_cause_code_type = "lateral collision risk";
336 else if (sub_cause_code == 4)
337 sub_cause_code_type = "collision risk involving vulnerable road user";
338 } else if (cause_code == CauseCodeType().SIGNAL_VIOLATION) {
339 if (sub_cause_code == 0)
340 sub_cause_code_type = "unavailable";
341 else if (sub_cause_code == 1)
342 sub_cause_code_type = "stop sign violation";
343 else if (sub_cause_code == 2)
344 sub_cause_code_type = "traffic light violation";
345 else if (sub_cause_code == 3)
346 sub_cause_code_type = "turning regulation violation";
347 } else if (cause_code == CauseCodeType().DANGEROUS_SITUATION) {
348 if (sub_cause_code == 0)
349 sub_cause_code_type = "unavailable";
350 else if (sub_cause_code == 1)
351 sub_cause_code_type = "emergency electronic break lights";
352 else if (sub_cause_code == 2)
353 sub_cause_code_type = "pre-crash system activated";
354 else if (sub_cause_code == 3)
355 sub_cause_code_type = "ESP (electronic stability program) activated";
356 else if (sub_cause_code == 4)
357 sub_cause_code_type = "ABS (anti-lock breaking system) activated";
358 else if (sub_cause_code == 5)
359 sub_cause_code_type = "AEB (automatic emergency breaking) activated";
360 else if (sub_cause_code == 6)
361 sub_cause_code_type = "break warning activated";
362 else if (sub_cause_code == 7)
363 sub_cause_code_type = "collision risk warning activated";
364 }
365 return sub_cause_code_type;
366 } else {
367 throw std::invalid_argument("SituationContainer is not present!");
368 }
369}
370
371} // namespace etsi_its_denm_msgs::access
Getter functions for the ETSI ITS Common Data Dictionary (CDD) v1.3.1.
double getHeading(const DENM &denm)
Get the Heading object.
std::string getCauseCodeType(const DENM &denm)
Get the Cause Code Type object.
double getHeadingConfidence(const DENM &denm)
Get the Heading confidence.
double getHeadingCDD(const Heading &heading)
Get the Heading value.
double getHeadingConfidenceCDD(const Heading &heading)
Get the Heading value.
uint8_t getSubCauseCode(const DENM &denm)
Get the Sub Cause Code object.
std::string getSubCauseCodeType(const DENM &denm)
Get the Sub Cause Code Type object.
uint8_t getCauseCode(const DENM &denm)
Get the Cause Code object.
Common getter functions for the ETSI ITS DENM (EN and TS).