etsi_its_messages v3.1.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
36#include <etsi_its_msgs_utils/impl/asn1_primitives/asn1_primitives_getters.h>
38
43 * @return stationID value
44 */
45inline uint32_t getStationID(const DENM& denm) { return getStationID(denm.header); }
46
53inline TimestampIts getReferenceTime(const DENM& denm) { return denm.denm.management.reference_time; }
54
61inline uint64_t getReferenceTimeValue(const DENM& denm) { return getReferenceTime(denm).value; }
62
67
69inline uint8_t getStationType(const DENM& denm) { return denm.denm.management.station_type.value; }
70
77inline double getLatitude(const DENM& denm) { return getLatitude(denm.denm.management.event_position.latitude); }
78
85inline double getLongitude(const DENM& denm) { return getLongitude(denm.denm.management.event_position.longitude); }
86
87/**
88 * @brief Get the Altitude value of DENM
89 *
90 * @param denm DENM to get the Altitude value from
91 * @return Altitude value (above the reference ellipsoid surface) in meter as decimal number
92 */
93inline double getAltitude(const DENM& denm) { return getAltitude(denm.denm.management.event_position.altitude); }
94
101inline double getHeading(const DENM& denm) {
102 if (denm.denm.location_is_present) {
103 if (denm.denm.location.event_position_heading_is_present) {
104 return getHeadingCDD(denm.denm.location.event_position_heading);
105 } else {
106 throw std::invalid_argument("Heading is not present!");
107 }
108 } else {
109 throw std::invalid_argument("LocationContainer is not present!");
110 }
111}
112
119inline double getHeadingConfidence(const DENM& denm) {
120 if (denm.denm.location_is_present) {
121 if (denm.denm.location.event_position_heading_is_present) {
122 return getHeadingConfidenceCDD(denm.denm.location.event_position_heading);
123 } else {
124 throw std::invalid_argument("Heading is not present!");
125 }
126 } else {
127 throw std::invalid_argument("LocationContainer is not present!");
128 }
129}
130
137inline bool getIsHeadingPresent(const DENM& denm) {
138 if (denm.denm.location_is_present) {
139 return denm.denm.location.event_position_heading_is_present;
140 } else {
141 throw std::invalid_argument("LocationContainer is not present!");
142 }
144
151inline double getSpeed(const DENM& denm) {
152 if (denm.denm.location_is_present) {
153 if (denm.denm.location.event_speed_is_present) {
154 return getSpeed(denm.denm.location.event_speed);
155 } else {
156 throw std::invalid_argument("Speed is not present!");
157 }
158 } else {
159 throw std::invalid_argument("LocationContainer is not present!");
160 }
161}
162
163/**
164 * @brief Get the IsSpeedPresent object
165 *
166 * @param denm DENM to get the IsSpeedPresent-Value from
167 * @return IsSpeedPresent-Value (true or false)
168 */
169inline bool getIsSpeedPresent(const DENM& denm) {
170 if (denm.denm.location_is_present) {
171 return denm.denm.location.event_speed_is_present;
172 } else {
173 throw std::invalid_argument("LocationContainer is not present!");
174 }
175}
176
182 */
183inline double getSpeedConfidence(const DENM& denm) {
184 return getSpeedConfidence(
185 denm.denm.location.event_speed);
186}
187
196inline gm::PointStamped getUTMPosition(const DENM& denm, int& zone, bool& northp) {
197 return getUTMPosition(denm.denm.management.event_position, zone, northp);
198}
199
200
206inline gm::PointStamped getUTMPosition(const DENM& denm) {
207 int zone;
208 bool northp;
209 return getUTMPosition(denm.denm.management.event_position, zone, northp);
210}
215
218inline uint8_t getCauseCode(const DENM& denm) { return denm.denm.situation.event_type.cause_code.value; }
219
224 * @return subCauseCode value
225 */
226inline uint8_t getSubCauseCode(const DENM& denm) { return denm.denm.situation.event_type.sub_cause_code.value; }
227
228
236inline std::string getCauseCodeType(const DENM& denm) {
237 if (denm.denm.situation_is_present) {
238 int cause_code = getCauseCode(denm);
239 std::string cause_code_type = "undefined";
240
241 if (cause_code == CauseCodeType().TRAFFIC_CONDITION)
242 cause_code_type = "traffic condition";
243 else if (cause_code == CauseCodeType().ACCIDENT)
244 cause_code_type = "accident";
245 else if (cause_code == CauseCodeType().ROADWORKS)
246 cause_code_type = "roadworks";
247 else if (cause_code == CauseCodeType().IMPASSABILITY)
248 cause_code_type = "impassibility";
249 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_ADHESION)
250 cause_code_type = "adverse weather condition - adhesion";
251 else if (cause_code == CauseCodeType().AQUAPLANNNING)
252 cause_code_type = "aquaplanning";
253 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_SURFACE_CONDITION)
254 cause_code_type = "hazardous location - surface condition";
255 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_OBSTACLE_ON_THE_ROAD)
256 cause_code_type = "hazardous location - obstacle on the road";
257 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_ANIMAL_ON_THE_ROAD)
258 cause_code_type = "hazardous location - animal on the road";
259 else if (cause_code == CauseCodeType().HUMAN_PRESENCE_ON_THE_ROAD)
260 cause_code_type = "human presence on the road";
261 else if (cause_code == CauseCodeType().WRONG_WAY_DRIVING)
262 cause_code_type = "wrong way driving";
263 else if (cause_code == CauseCodeType().RESCUE_AND_RECOVERY_WORK_IN_PROGRESS)
264 cause_code_type = "rescue and recovery in progress";
265 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_EXTREME_WEATHER_CONDITION)
266 cause_code_type = "adverse weather condition - extreme weather condition";
267 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_VISIBILITY)
268 cause_code_type = "adverse weather condition - visibility";
269 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_PRECIPITATION)
270 cause_code_type = "adverse weather condition - precipitation";
271 else if (cause_code == CauseCodeType().SLOW_VEHICLE)
272 cause_code_type = "slow vehicle";
273 else if (cause_code == CauseCodeType().DANGEROUS_END_OF_QUEUE)
274 cause_code_type = "dangerous end of queue";
275 else if (cause_code == CauseCodeType().VEHICLE_BREAKDOWN)
276 cause_code_type = "vehicle breakdown";
277 else if (cause_code == CauseCodeType().POST_CRASH)
278 cause_code_type = "post crash";
279 else if (cause_code == CauseCodeType().HUMAN_PROBLEM)
280 cause_code_type = "human problem";
281 else if (cause_code == CauseCodeType().STATIONARY_VEHICLE)
282 cause_code_type = "stationary vehicle";
283 else if (cause_code == CauseCodeType().EMERGENCY_VEHICLE_APPROACHING)
284 cause_code_type = "emergency vehicle approaching";
285 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_DANGEROUS_CURVE)
286 cause_code_type = "hazardous location - dangerous curve";
287 else if (cause_code == CauseCodeType().COLLISION_RISK)
288 cause_code_type = "collision risk";
289 else if (cause_code == CauseCodeType().SIGNAL_VIOLATION)
290 cause_code_type = "signal violation";
291 else if (cause_code == CauseCodeType().DANGEROUS_SITUATION)
292 cause_code_type = "dangerous situation";
293
294 return cause_code_type;
295 } else {
296 throw std::invalid_argument("SituationContainer is not present!");
297 }
298}
299
308inline std::string getSubCauseCodeType(const DENM& denm) {
309 if (denm.denm.situation_is_present) {
310 int cause_code = getCauseCode(denm);
311 int sub_cause_code = getSubCauseCode(denm);
312 std::string sub_cause_code_type = "undefined";
313 if (cause_code == CauseCodeType().TRAFFIC_CONDITION) {
314 if (sub_cause_code == 0)
315 sub_cause_code_type = "unavailable";
316 else if (sub_cause_code == 1)
317 sub_cause_code_type = "not defined";
318 else if (sub_cause_code == 2)
319 sub_cause_code_type = "traffic jam slowly increasing";
320 else if (sub_cause_code == 3)
321 sub_cause_code_type = "traffic jam increasing";
322 else if (sub_cause_code == 4)
323 sub_cause_code_type = "traffic jam strongly increasing";
324 else if (sub_cause_code == 5)
325 sub_cause_code_type = "traffic stationary";
326 else if (sub_cause_code == 6)
327 sub_cause_code_type = "traffic jam slightly decreasing";
328 else if (sub_cause_code == 7)
329 sub_cause_code_type = "traffic jam decreasing";
330 else if (sub_cause_code == 8)
331 sub_cause_code_type = "traffic jam strongly decreasing";
332 } else if (cause_code == CauseCodeType().ACCIDENT) {
333 if (sub_cause_code == 0)
334 sub_cause_code_type = "unavailable";
335 else if (sub_cause_code >= 1 && sub_cause_code <= 7)
336 sub_cause_code_type = "not defined";
337 else if (sub_cause_code == 8)
338 sub_cause_code_type = "assistance requested (e-Call)";
339 } else if (cause_code == CauseCodeType().ROADWORKS) {
340 if (sub_cause_code == 0)
341 sub_cause_code_type = "unavailable";
342 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
343 sub_cause_code_type = "not defined";
344 else if (sub_cause_code == 4)
345 sub_cause_code_type = "short-term stationary roadworks";
346 else if (sub_cause_code == 5)
347 sub_cause_code_type = "street cleaning";
348 else if (sub_cause_code == 6)
349 sub_cause_code_type = "winter service";
350 } else if (cause_code == CauseCodeType().IMPASSABILITY)
351 sub_cause_code_type = "not defined";
352 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_ADHESION) {
353 if (sub_cause_code == 0)
354 sub_cause_code_type = "unavailable";
355 else if (sub_cause_code >= 1 && sub_cause_code <= 10)
356 sub_cause_code_type = "not defined";
357 } else if (cause_code == CauseCodeType().AQUAPLANNNING)
358 sub_cause_code_type = "not defined";
359 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_SURFACE_CONDITION) {
360 if (sub_cause_code == 0)
361 sub_cause_code_type = "unavailable";
362 else if (sub_cause_code >= 1 && sub_cause_code <= 9)
363 sub_cause_code_type = "not defined";
364 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_OBSTACLE_ON_THE_ROAD) {
365 if (sub_cause_code == 0)
366 sub_cause_code_type = "unavailable";
367 else if (sub_cause_code >= 1 && sub_cause_code <= 7)
368 sub_cause_code_type = "not defined";
369 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_ANIMAL_ON_THE_ROAD) {
370 if (sub_cause_code == 0)
371 sub_cause_code_type = "unavailable";
372 else if (sub_cause_code >= 1 && sub_cause_code <= 4)
373 sub_cause_code_type = "not defined";
374 } else if (cause_code == CauseCodeType().HUMAN_PRESENCE_ON_THE_ROAD) {
375 if (sub_cause_code == 0)
376 sub_cause_code_type = "unavailable";
377 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
378 sub_cause_code_type = "not defined";
379 } else if (cause_code == CauseCodeType().WRONG_WAY_DRIVING) {
380 if (sub_cause_code == 0)
381 sub_cause_code_type = "unavailable";
382 else if (sub_cause_code == 1)
383 sub_cause_code_type = "vehicle driving in wrong lane";
384 else if (sub_cause_code == 2)
385 sub_cause_code_type = "vehicle driving in wrong driving direction";
386 } else if (cause_code == CauseCodeType().RESCUE_AND_RECOVERY_WORK_IN_PROGRESS) {
387 if (sub_cause_code == 0)
388 sub_cause_code_type = "unavailable";
389 else if (sub_cause_code >= 1 && sub_cause_code <= 5)
390 sub_cause_code_type = "not defined";
391 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_EXTREME_WEATHER_CONDITION) {
392 if (sub_cause_code == 0)
393 sub_cause_code_type = "unavailable";
394 else if (sub_cause_code >= 1 && sub_cause_code <= 6)
395 sub_cause_code_type = "not defined";
396 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_VISIBILITY) {
397 if (sub_cause_code == 0)
398 sub_cause_code_type = "unavailable";
399 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
400 sub_cause_code_type = "not defined";
401 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_PRECIPITATION) {
402 if (sub_cause_code == 0)
403 sub_cause_code_type = "unavailable";
404 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
405 sub_cause_code_type = "not defined";
406 } else if (cause_code == CauseCodeType().SLOW_VEHICLE) {
407 if (sub_cause_code == 0)
408 sub_cause_code_type = "unavailable";
409 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
410 sub_cause_code_type = "not defined";
411 } else if (cause_code == CauseCodeType().DANGEROUS_END_OF_QUEUE) {
412 if (sub_cause_code == 0)
413 sub_cause_code_type = "unavailable";
414 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
415 sub_cause_code_type = "not defined";
416 } else if (cause_code == CauseCodeType().VEHICLE_BREAKDOWN) {
417 if (sub_cause_code == 0)
418 sub_cause_code_type = "unavailable";
419 else if (sub_cause_code == 1)
420 sub_cause_code_type = "lack of fuel";
421 else if (sub_cause_code == 2)
422 sub_cause_code_type = "lack of battery";
423 else if (sub_cause_code == 3)
424 sub_cause_code_type = "engine problem";
425 else if (sub_cause_code == 4)
426 sub_cause_code_type = "transmission problem";
427 else if (sub_cause_code == 5)
428 sub_cause_code_type = "engine cooling problem";
429 else if (sub_cause_code == 6)
430 sub_cause_code_type = "braking system problem";
431 else if (sub_cause_code == 7)
432 sub_cause_code_type = "steering problem";
433 else if (sub_cause_code == 8)
434 sub_cause_code_type = "tyre puncture";
435 } else if (cause_code == CauseCodeType().POST_CRASH) {
436 if (sub_cause_code == 0)
437 sub_cause_code_type = "unavailable";
438 else if (sub_cause_code == 1)
439 sub_cause_code_type = "accident without e-Call triggered";
440 else if (sub_cause_code == 2)
441 sub_cause_code_type = "accident with e-Call manually triggered";
442 else if (sub_cause_code == 3)
443 sub_cause_code_type = "accident with e-Call automatical triggered";
444 else if (sub_cause_code == 4)
445 sub_cause_code_type = "accident with e-Call triggered without a possible access to a cell network";
446 } else if (cause_code == CauseCodeType().HUMAN_PROBLEM) {
447 if (sub_cause_code == 0)
448 sub_cause_code_type = "unavailable";
449 else if (sub_cause_code == 1)
450 sub_cause_code_type = "glycaemia problem";
451 else if (sub_cause_code == 2)
452 sub_cause_code_type = "heart problem";
453 } else if (cause_code == CauseCodeType().STATIONARY_VEHICLE) {
454 if (sub_cause_code == 0)
455 sub_cause_code_type = "unavailable";
456 else if (sub_cause_code == 1)
457 sub_cause_code_type = "human problem";
458 else if (sub_cause_code == 2)
459 sub_cause_code_type = "vehicle breakdown";
460 else if (sub_cause_code == 3)
461 sub_cause_code_type = "post crash";
462 else if (sub_cause_code == 4)
463 sub_cause_code_type = "public transport stop";
464 else if (sub_cause_code == 5)
465 sub_cause_code_type = "carrying dangerous goods";
466 } else if (cause_code == CauseCodeType().EMERGENCY_VEHICLE_APPROACHING) {
467 if (sub_cause_code == 0)
468 sub_cause_code_type = "unavailable";
469 else if (sub_cause_code == 1)
470 sub_cause_code_type = "emergency vehicle approaching";
471 else if (sub_cause_code == 2)
472 sub_cause_code_type = "prioritized vehicle approaching";
473 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_DANGEROUS_CURVE) {
474 if (sub_cause_code == 0)
475 sub_cause_code_type = "unavailable";
476 else if (sub_cause_code == 1)
477 sub_cause_code_type = "dangerous left turn curve";
478 else if (sub_cause_code == 2)
479 sub_cause_code_type = "dangerous right turn curve";
480 else if (sub_cause_code == 3)
481 sub_cause_code_type = "multiple curves starting with unknown turning direction";
482 else if (sub_cause_code == 4)
483 sub_cause_code_type = "multiple curves starting with left turn";
484 else if (sub_cause_code == 5)
485 sub_cause_code_type = "multiple curves starting with right turn";
486 } else if (cause_code == CauseCodeType().COLLISION_RISK) {
487 if (sub_cause_code == 0)
488 sub_cause_code_type = "unavailable";
489 else if (sub_cause_code == 1)
490 sub_cause_code_type = "longitudinal collision risk";
491 else if (sub_cause_code == 2)
492 sub_cause_code_type = "crossing collision risk";
493 else if (sub_cause_code == 3)
494 sub_cause_code_type = "lateral collision risk";
495 else if (sub_cause_code == 4)
496 sub_cause_code_type = "collision risk involving vulnerable road user";
497 } else if (cause_code == CauseCodeType().SIGNAL_VIOLATION) {
498 if (sub_cause_code == 0)
499 sub_cause_code_type = "unavailable";
500 else if (sub_cause_code == 1)
501 sub_cause_code_type = "stop sign violation";
502 else if (sub_cause_code == 2)
503 sub_cause_code_type = "traffic light violation";
504 else if (sub_cause_code == 3)
505 sub_cause_code_type = "turning regulation violation";
506 } else if (cause_code == CauseCodeType().DANGEROUS_SITUATION) {
507 if (sub_cause_code == 0)
508 sub_cause_code_type = "unavailable";
509 else if (sub_cause_code == 1)
510 sub_cause_code_type = "emergency electronic break lights";
511 else if (sub_cause_code == 2)
512 sub_cause_code_type = "pre-crash system activated";
513 else if (sub_cause_code == 3)
514 sub_cause_code_type = "ESP (electronic stability program) activated";
515 else if (sub_cause_code == 4)
516 sub_cause_code_type = "ABS (anti-lock breaking system) activated";
517 else if (sub_cause_code == 5)
518 sub_cause_code_type = "AEB (automatic emergency breaking) activated";
519 else if (sub_cause_code == 6)
520 sub_cause_code_type = "break warning activated";
521 else if (sub_cause_code == 7)
522 sub_cause_code_type = "collision risk warning activated";
523 }
524 return sub_cause_code_type;
525 } else {
526 throw std::invalid_argument("SituationContainer is not present!");
527 }
528}
529
536inline std::vector<bool> getDrivingLaneStatus(const DrivingLaneStatus& driving_lane_status) {
537 return getBitString(driving_lane_status.value, driving_lane_status.bits_unused);
538}
539
546inline std::vector<bool> getLightBarSirenInUse(const LightBarSirenInUse& light_bar_siren_in_use) {
547 return getBitString(light_bar_siren_in_use.value, light_bar_siren_in_use.bits_unused);
548}
549
550} // namespace etsi_its_denm_msgs::access
gm::PointStamped getUTMPosition(const CAM &cam, int &zone, bool &northp)
Get the UTM Position defined within the BasicContainer of the CAM.
double getSpeed(const CAM &cam)
Get the vehicle speed.
double getHeading(const CAM &cam)
Get the Heading value of CAM.
Getter functions for the ETSI ITS Common Data Dictionary (CDD) v1.3.1.
std::vector< bool > getLightBarSirenInUse(const LightBarSirenInUse &light_bar_siren_in_use)
Get the Lightbar Siren In Use in form of bool vector.
std::vector< bool > getDrivingLaneStatus(const DrivingLaneStatus &driving_lane_status)
Get the Driving Lane Status in form of bool vector.
std::vector< bool > getBitString(const std::vector< uint8_t > &buffer, const int bits_unused)
Get a Bit String in form of bool vector.
double getHeadingConfidence(const DENM &denm)
Get the Heading confidence.
double getHeadingCDD(const Heading &heading)
Get the Heading value.
double getLongitude(const Longitude &longitude)
Get the Longitude value.
uint32_t getStationID(const ItsPduHeader &header)
Get the StationID of ItsPduHeader.
double getHeadingConfidenceCDD(const Heading &heading)
Get the Heading value.
uint8_t getStationType(const DENM &denm)
Get the stationType object.
TimestampIts getReferenceTime(const DENM &denm)
Get the Reference Time object.
uint8_t getSubCauseCode(const DENM &denm)
Get the Sub Cause Code object.
bool getIsSpeedPresent(const DENM &denm)
Get the IsSpeedPresent object.
std::string getSubCauseCodeType(const DENM &denm)
Get the Sub Cause Code Type object.
double getSpeedConfidence(const Speed &speed)
Get the Speed Confidence.
double getLatitude(const Latitude &latitude)
Get the Latitude value.
uint64_t getReferenceTimeValue(const DENM &denm)
Get the ReferenceTime-Value.
uint8_t getCauseCode(const DENM &denm)
Get the Cause Code object.
double getAltitude(const Altitude &altitude)
Get the Altitude value.
bool getIsHeadingPresent(const DENM &denm)
Get the IsHeadingPresent object.
double getSpeed(const Speed &speed)
Get the vehicle speed.