etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
denm_getters.h
Go to the documentation of this file.
1/*
2=============================================================================
3MIT License
4
5Copyright (c) 2023-2025 Institute for Automotive Engineering (ika), RWTH Aachen University
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24=============================================================================
25*/
26
31
32#pragma once
33
34namespace etsi_its_denm_msgs::access {
35
37
39
43 * @param denm DENM to get the Heading-Value from
44 * @return heading value in degree as decimal number
45 */
46inline double getHeading(const DENM& denm) {
47 if (denm.denm.location_is_present) {
48 if (denm.denm.location.event_position_heading_is_present) {
49 return getHeadingCDD(denm.denm.location.event_position_heading);
50 } else {
51 throw std::invalid_argument("Heading is not present!");
52 }
53 } else {
54 throw std::invalid_argument("LocationContainer is not present!");
55 }
56}
57
64inline double getHeadingConfidence(const DENM& denm) {
65 if (denm.denm.location_is_present) {
66 if (denm.denm.location.event_position_heading_is_present) {
67 return getHeadingConfidenceCDD(denm.denm.location.event_position_heading);
68 } else {
69 throw std::invalid_argument("Heading is not present!");
70 }
71 } else {
72 throw std::invalid_argument("LocationContainer is not present!");
73 }
74}
77
82inline uint8_t getCauseCode(const DENM& denm) { return denm.denm.situation.event_type.cause_code.value; }
90inline uint8_t getSubCauseCode(const DENM& denm) { return denm.denm.situation.event_type.sub_cause_code.value; }
92/**
93 * @brief Get the Cause Code Type object
94 *
95 * https://www.etsi.org/deliver/etsi_en/302600_302699/30263703/01.02.01_30/en_30263703v010201v.pdf
96 *
97 * @param denm DENM to get the causeCodeType value from
98 * @return causeCodeType value
99 */
100inline std::string getCauseCodeType(const DENM& denm) {
101 if (denm.denm.situation_is_present) {
102 int cause_code = getCauseCode(denm);
103 std::string cause_code_type = "undefined";
104
105 if (cause_code == CauseCodeType().TRAFFIC_CONDITION)
106 cause_code_type = "traffic condition";
107 else if (cause_code == CauseCodeType().ACCIDENT)
108 cause_code_type = "accident";
109 else if (cause_code == CauseCodeType().ROADWORKS)
110 cause_code_type = "roadworks";
111 else if (cause_code == CauseCodeType().IMPASSABILITY)
112 cause_code_type = "impassibility";
113 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_ADHESION)
114 cause_code_type = "adverse weather condition - adhesion";
115 else if (cause_code == CauseCodeType().AQUAPLANNNING)
116 cause_code_type = "aquaplanning";
117 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_SURFACE_CONDITION)
118 cause_code_type = "hazardous location - surface condition";
119 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_OBSTACLE_ON_THE_ROAD)
120 cause_code_type = "hazardous location - obstacle on the road";
121 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_ANIMAL_ON_THE_ROAD)
122 cause_code_type = "hazardous location - animal on the road";
123 else if (cause_code == CauseCodeType().HUMAN_PRESENCE_ON_THE_ROAD)
124 cause_code_type = "human presence on the road";
125 else if (cause_code == CauseCodeType().WRONG_WAY_DRIVING)
126 cause_code_type = "wrong way driving";
127 else if (cause_code == CauseCodeType().RESCUE_AND_RECOVERY_WORK_IN_PROGRESS)
128 cause_code_type = "rescue and recovery in progress";
129 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_EXTREME_WEATHER_CONDITION)
130 cause_code_type = "adverse weather condition - extreme weather condition";
131 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_VISIBILITY)
132 cause_code_type = "adverse weather condition - visibility";
133 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_PRECIPITATION)
134 cause_code_type = "adverse weather condition - precipitation";
135 else if (cause_code == CauseCodeType().SLOW_VEHICLE)
136 cause_code_type = "slow vehicle";
137 else if (cause_code == CauseCodeType().DANGEROUS_END_OF_QUEUE)
138 cause_code_type = "dangerous end of queue";
139 else if (cause_code == CauseCodeType().VEHICLE_BREAKDOWN)
140 cause_code_type = "vehicle breakdown";
141 else if (cause_code == CauseCodeType().POST_CRASH)
142 cause_code_type = "post crash";
143 else if (cause_code == CauseCodeType().HUMAN_PROBLEM)
144 cause_code_type = "human problem";
145 else if (cause_code == CauseCodeType().STATIONARY_VEHICLE)
146 cause_code_type = "stationary vehicle";
147 else if (cause_code == CauseCodeType().EMERGENCY_VEHICLE_APPROACHING)
148 cause_code_type = "emergency vehicle approaching";
149 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_DANGEROUS_CURVE)
150 cause_code_type = "hazardous location - dangerous curve";
151 else if (cause_code == CauseCodeType().COLLISION_RISK)
152 cause_code_type = "collision risk";
153 else if (cause_code == CauseCodeType().SIGNAL_VIOLATION)
154 cause_code_type = "signal violation";
155 else if (cause_code == CauseCodeType().DANGEROUS_SITUATION)
156 cause_code_type = "dangerous situation";
157
158 return cause_code_type;
159 } else {
160 throw std::invalid_argument("SituationContainer is not present!");
161 }
162}
163
168 *
169 * @param denm DENM to get the subCauseCodeType value from
170 * @return causeCodeType value
171 */
172inline std::string getSubCauseCodeType(const DENM& denm) {
173 if (denm.denm.situation_is_present) {
174 int cause_code = getCauseCode(denm);
175 int sub_cause_code = getSubCauseCode(denm);
176 std::string sub_cause_code_type = "undefined";
177 if (cause_code == CauseCodeType().TRAFFIC_CONDITION) {
178 if (sub_cause_code == 0)
179 sub_cause_code_type = "unavailable";
180 else if (sub_cause_code == 1)
181 sub_cause_code_type = "not defined";
182 else if (sub_cause_code == 2)
183 sub_cause_code_type = "traffic jam slowly increasing";
184 else if (sub_cause_code == 3)
185 sub_cause_code_type = "traffic jam increasing";
186 else if (sub_cause_code == 4)
187 sub_cause_code_type = "traffic jam strongly increasing";
188 else if (sub_cause_code == 5)
189 sub_cause_code_type = "traffic stationary";
190 else if (sub_cause_code == 6)
191 sub_cause_code_type = "traffic jam slightly decreasing";
192 else if (sub_cause_code == 7)
193 sub_cause_code_type = "traffic jam decreasing";
194 else if (sub_cause_code == 8)
195 sub_cause_code_type = "traffic jam strongly decreasing";
196 } else if (cause_code == CauseCodeType().ACCIDENT) {
197 if (sub_cause_code == 0)
198 sub_cause_code_type = "unavailable";
199 else if (sub_cause_code >= 1 && sub_cause_code <= 7)
200 sub_cause_code_type = "not defined";
201 else if (sub_cause_code == 8)
202 sub_cause_code_type = "assistance requested (e-Call)";
203 } else if (cause_code == CauseCodeType().ROADWORKS) {
204 if (sub_cause_code == 0)
205 sub_cause_code_type = "unavailable";
206 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
207 sub_cause_code_type = "not defined";
208 else if (sub_cause_code == 4)
209 sub_cause_code_type = "short-term stationary roadworks";
210 else if (sub_cause_code == 5)
211 sub_cause_code_type = "street cleaning";
212 else if (sub_cause_code == 6)
213 sub_cause_code_type = "winter service";
214 } else if (cause_code == CauseCodeType().IMPASSABILITY)
215 sub_cause_code_type = "not defined";
216 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_ADHESION) {
217 if (sub_cause_code == 0)
218 sub_cause_code_type = "unavailable";
219 else if (sub_cause_code >= 1 && sub_cause_code <= 10)
220 sub_cause_code_type = "not defined";
221 } else if (cause_code == CauseCodeType().AQUAPLANNNING)
222 sub_cause_code_type = "not defined";
223 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_SURFACE_CONDITION) {
224 if (sub_cause_code == 0)
225 sub_cause_code_type = "unavailable";
226 else if (sub_cause_code >= 1 && sub_cause_code <= 9)
227 sub_cause_code_type = "not defined";
228 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_OBSTACLE_ON_THE_ROAD) {
229 if (sub_cause_code == 0)
230 sub_cause_code_type = "unavailable";
231 else if (sub_cause_code >= 1 && sub_cause_code <= 7)
232 sub_cause_code_type = "not defined";
233 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_ANIMAL_ON_THE_ROAD) {
234 if (sub_cause_code == 0)
235 sub_cause_code_type = "unavailable";
236 else if (sub_cause_code >= 1 && sub_cause_code <= 4)
237 sub_cause_code_type = "not defined";
238 } else if (cause_code == CauseCodeType().HUMAN_PRESENCE_ON_THE_ROAD) {
239 if (sub_cause_code == 0)
240 sub_cause_code_type = "unavailable";
241 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
242 sub_cause_code_type = "not defined";
243 } else if (cause_code == CauseCodeType().WRONG_WAY_DRIVING) {
244 if (sub_cause_code == 0)
245 sub_cause_code_type = "unavailable";
246 else if (sub_cause_code == 1)
247 sub_cause_code_type = "vehicle driving in wrong lane";
248 else if (sub_cause_code == 2)
249 sub_cause_code_type = "vehicle driving in wrong driving direction";
250 } else if (cause_code == CauseCodeType().RESCUE_AND_RECOVERY_WORK_IN_PROGRESS) {
251 if (sub_cause_code == 0)
252 sub_cause_code_type = "unavailable";
253 else if (sub_cause_code >= 1 && sub_cause_code <= 5)
254 sub_cause_code_type = "not defined";
255 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_EXTREME_WEATHER_CONDITION) {
256 if (sub_cause_code == 0)
257 sub_cause_code_type = "unavailable";
258 else if (sub_cause_code >= 1 && sub_cause_code <= 6)
259 sub_cause_code_type = "not defined";
260 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_VISIBILITY) {
261 if (sub_cause_code == 0)
262 sub_cause_code_type = "unavailable";
263 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
264 sub_cause_code_type = "not defined";
265 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_PRECIPITATION) {
266 if (sub_cause_code == 0)
267 sub_cause_code_type = "unavailable";
268 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
269 sub_cause_code_type = "not defined";
270 } else if (cause_code == CauseCodeType().SLOW_VEHICLE) {
271 if (sub_cause_code == 0)
272 sub_cause_code_type = "unavailable";
273 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
274 sub_cause_code_type = "not defined";
275 } else if (cause_code == CauseCodeType().DANGEROUS_END_OF_QUEUE) {
276 if (sub_cause_code == 0)
277 sub_cause_code_type = "unavailable";
278 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
279 sub_cause_code_type = "not defined";
280 } else if (cause_code == CauseCodeType().VEHICLE_BREAKDOWN) {
281 if (sub_cause_code == 0)
282 sub_cause_code_type = "unavailable";
283 else if (sub_cause_code == 1)
284 sub_cause_code_type = "lack of fuel";
285 else if (sub_cause_code == 2)
286 sub_cause_code_type = "lack of battery";
287 else if (sub_cause_code == 3)
288 sub_cause_code_type = "engine problem";
289 else if (sub_cause_code == 4)
290 sub_cause_code_type = "transmission problem";
291 else if (sub_cause_code == 5)
292 sub_cause_code_type = "engine cooling problem";
293 else if (sub_cause_code == 6)
294 sub_cause_code_type = "braking system problem";
295 else if (sub_cause_code == 7)
296 sub_cause_code_type = "steering problem";
297 else if (sub_cause_code == 8)
298 sub_cause_code_type = "tyre puncture";
299 } else if (cause_code == CauseCodeType().POST_CRASH) {
300 if (sub_cause_code == 0)
301 sub_cause_code_type = "unavailable";
302 else if (sub_cause_code == 1)
303 sub_cause_code_type = "accident without e-Call triggered";
304 else if (sub_cause_code == 2)
305 sub_cause_code_type = "accident with e-Call manually triggered";
306 else if (sub_cause_code == 3)
307 sub_cause_code_type = "accident with e-Call automatical triggered";
308 else if (sub_cause_code == 4)
309 sub_cause_code_type = "accident with e-Call triggered without a possible access to a cell network";
310 } else if (cause_code == CauseCodeType().HUMAN_PROBLEM) {
311 if (sub_cause_code == 0)
312 sub_cause_code_type = "unavailable";
313 else if (sub_cause_code == 1)
314 sub_cause_code_type = "glycaemia problem";
315 else if (sub_cause_code == 2)
316 sub_cause_code_type = "heart problem";
317 } else if (cause_code == CauseCodeType().STATIONARY_VEHICLE) {
318 if (sub_cause_code == 0)
319 sub_cause_code_type = "unavailable";
320 else if (sub_cause_code == 1)
321 sub_cause_code_type = "human problem";
322 else if (sub_cause_code == 2)
323 sub_cause_code_type = "vehicle breakdown";
324 else if (sub_cause_code == 3)
325 sub_cause_code_type = "post crash";
326 else if (sub_cause_code == 4)
327 sub_cause_code_type = "public transport stop";
328 else if (sub_cause_code == 5)
329 sub_cause_code_type = "carrying dangerous goods";
330 } else if (cause_code == CauseCodeType().EMERGENCY_VEHICLE_APPROACHING) {
331 if (sub_cause_code == 0)
332 sub_cause_code_type = "unavailable";
333 else if (sub_cause_code == 1)
334 sub_cause_code_type = "emergency vehicle approaching";
335 else if (sub_cause_code == 2)
336 sub_cause_code_type = "prioritized vehicle approaching";
337 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_DANGEROUS_CURVE) {
338 if (sub_cause_code == 0)
339 sub_cause_code_type = "unavailable";
340 else if (sub_cause_code == 1)
341 sub_cause_code_type = "dangerous left turn curve";
342 else if (sub_cause_code == 2)
343 sub_cause_code_type = "dangerous right turn curve";
344 else if (sub_cause_code == 3)
345 sub_cause_code_type = "multiple curves starting with unknown turning direction";
346 else if (sub_cause_code == 4)
347 sub_cause_code_type = "multiple curves starting with left turn";
348 else if (sub_cause_code == 5)
349 sub_cause_code_type = "multiple curves starting with right turn";
350 } else if (cause_code == CauseCodeType().COLLISION_RISK) {
351 if (sub_cause_code == 0)
352 sub_cause_code_type = "unavailable";
353 else if (sub_cause_code == 1)
354 sub_cause_code_type = "longitudinal collision risk";
355 else if (sub_cause_code == 2)
356 sub_cause_code_type = "crossing collision risk";
357 else if (sub_cause_code == 3)
358 sub_cause_code_type = "lateral collision risk";
359 else if (sub_cause_code == 4)
360 sub_cause_code_type = "collision risk involving vulnerable road user";
361 } else if (cause_code == CauseCodeType().SIGNAL_VIOLATION) {
362 if (sub_cause_code == 0)
363 sub_cause_code_type = "unavailable";
364 else if (sub_cause_code == 1)
365 sub_cause_code_type = "stop sign violation";
366 else if (sub_cause_code == 2)
367 sub_cause_code_type = "traffic light violation";
368 else if (sub_cause_code == 3)
369 sub_cause_code_type = "turning regulation violation";
370 } else if (cause_code == CauseCodeType().DANGEROUS_SITUATION) {
371 if (sub_cause_code == 0)
372 sub_cause_code_type = "unavailable";
373 else if (sub_cause_code == 1)
374 sub_cause_code_type = "emergency electronic break lights";
375 else if (sub_cause_code == 2)
376 sub_cause_code_type = "pre-crash system activated";
377 else if (sub_cause_code == 3)
378 sub_cause_code_type = "ESP (electronic stability program) activated";
379 else if (sub_cause_code == 4)
380 sub_cause_code_type = "ABS (anti-lock breaking system) activated";
381 else if (sub_cause_code == 5)
382 sub_cause_code_type = "AEB (automatic emergency breaking) activated";
383 else if (sub_cause_code == 6)
384 sub_cause_code_type = "break warning activated";
385 else if (sub_cause_code == 7)
386 sub_cause_code_type = "collision risk warning activated";
387 }
388 return sub_cause_code_type;
389 } else {
390 throw std::invalid_argument("SituationContainer is not present!");
391 }
392}
393
394} // 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).