etsi_its_messages v3.0.0
 
Loading...
Searching...
No Matches
denm_getters.h
Go to the documentation of this file.
1/*
2=============================================================================
3MIT License
4
5Copyright (c) 2023-2024 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
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
103inline double getHeading(const Heading& heading) { return ((double)heading.heading_value.value) * 1e-1; }
104
109
111inline double getHeading(const DENM& denm) {
112 if (denm.denm.location_is_present) {
113 if (denm.denm.location.event_position_heading_is_present) {
114 return getHeading(denm.denm.location.event_position_heading);
115 } else {
116 throw std::invalid_argument("Heading is not present!");
117 }
118 } else {
119 throw std::invalid_argument("LocationContainer is not present!");
121}
122
129inline bool getIsHeadingPresent(const DENM& denm) {
130 if (denm.denm.location_is_present) {
131 return denm.denm.location.event_position_heading_is_present;
132 } else {
133 throw std::invalid_argument("LocationContainer is not present!");
134 }
135}
143inline double getSpeed(const DENM& denm) {
144 if (denm.denm.location_is_present) {
145 if (denm.denm.location.event_speed_is_present) {
146 return getSpeed(denm.denm.location.event_speed);
147 } else {
148 throw std::invalid_argument("Speed is not present!");
149 }
150 } else {
151 throw std::invalid_argument("LocationContainer is not present!");
153}
154
161inline bool getIsSpeedPresent(const DENM& denm) {
162 if (denm.denm.location_is_present) {
163 return denm.denm.location.event_speed_is_present;
164 } else {
165 throw std::invalid_argument("LocationContainer is not present!");
166 }
167}
177inline gm::PointStamped getUTMPosition(const DENM& denm, int& zone, bool& northp) {
178 return getUTMPosition(denm.denm.management.event_position, zone, northp);
179}
180
186 */
187inline gm::PointStamped getUTMPosition(const DENM& denm) {
188 int zone;
189 bool northp;
190 return getUTMPosition(denm.denm.management.event_position, zone, northp);
191}
192
197
199inline uint8_t getCauseCode(const DENM& denm) { return denm.denm.situation.event_type.cause_code.value; }
200
204 * @param denm DENM to get the subCauseCode value from
205 * @return subCauseCode value
206 */
207inline uint8_t getSubCauseCode(const DENM& denm) { return denm.denm.situation.event_type.sub_cause_code.value; }
208
211
217inline std::string getCauseCodeType(const DENM& denm) {
218 if (denm.denm.situation_is_present) {
219 int cause_code = getCauseCode(denm);
220 std::string cause_code_type = "undefined";
221
222 if (cause_code == CauseCodeType().TRAFFIC_CONDITION)
223 cause_code_type = "traffic condition";
224 else if (cause_code == CauseCodeType().ACCIDENT)
225 cause_code_type = "accident";
226 else if (cause_code == CauseCodeType().ROADWORKS)
227 cause_code_type = "roadworks";
228 else if (cause_code == CauseCodeType().IMPASSABILITY)
229 cause_code_type = "impassibility";
230 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_ADHESION)
231 cause_code_type = "adverse weather condition - adhesion";
232 else if (cause_code == CauseCodeType().AQUAPLANNNING)
233 cause_code_type = "aquaplanning";
234 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_SURFACE_CONDITION)
235 cause_code_type = "hazardous location - surface condition";
236 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_OBSTACLE_ON_THE_ROAD)
237 cause_code_type = "hazardous location - obstacle on the road";
238 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_ANIMAL_ON_THE_ROAD)
239 cause_code_type = "hazardous location - animal on the road";
240 else if (cause_code == CauseCodeType().HUMAN_PRESENCE_ON_THE_ROAD)
241 cause_code_type = "human presence on the road";
242 else if (cause_code == CauseCodeType().WRONG_WAY_DRIVING)
243 cause_code_type = "wrong way driving";
244 else if (cause_code == CauseCodeType().RESCUE_AND_RECOVERY_WORK_IN_PROGRESS)
245 cause_code_type = "rescue and recovery in progress";
246 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_EXTREME_WEATHER_CONDITION)
247 cause_code_type = "adverse weather condition - extreme weather condition";
248 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_VISIBILITY)
249 cause_code_type = "adverse weather condition - visibility";
250 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_PRECIPITATION)
251 cause_code_type = "adverse weather condition - precipitation";
252 else if (cause_code == CauseCodeType().SLOW_VEHICLE)
253 cause_code_type = "slow vehicle";
254 else if (cause_code == CauseCodeType().DANGEROUS_END_OF_QUEUE)
255 cause_code_type = "dangerous end of queue";
256 else if (cause_code == CauseCodeType().VEHICLE_BREAKDOWN)
257 cause_code_type = "vehicle breakdown";
258 else if (cause_code == CauseCodeType().POST_CRASH)
259 cause_code_type = "post crash";
260 else if (cause_code == CauseCodeType().HUMAN_PROBLEM)
261 cause_code_type = "human problem";
262 else if (cause_code == CauseCodeType().STATIONARY_VEHICLE)
263 cause_code_type = "stationary vehicle";
264 else if (cause_code == CauseCodeType().EMERGENCY_VEHICLE_APPROACHING)
265 cause_code_type = "emergency vehicle approaching";
266 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_DANGEROUS_CURVE)
267 cause_code_type = "hazardous location - dangerous curve";
268 else if (cause_code == CauseCodeType().COLLISION_RISK)
269 cause_code_type = "collision risk";
270 else if (cause_code == CauseCodeType().SIGNAL_VIOLATION)
271 cause_code_type = "signal violation";
272 else if (cause_code == CauseCodeType().DANGEROUS_SITUATION)
273 cause_code_type = "dangerous situation";
275 return cause_code_type;
276 } else {
277 throw std::invalid_argument("SituationContainer is not present!");
278 }
279}
280
289inline std::string getSubCauseCodeType(const DENM& denm) {
290 if (denm.denm.situation_is_present) {
291 int cause_code = getCauseCode(denm);
292 int sub_cause_code = getSubCauseCode(denm);
293 std::string sub_cause_code_type = "undefined";
294 if (cause_code == CauseCodeType().TRAFFIC_CONDITION) {
295 if (sub_cause_code == 0)
296 sub_cause_code_type = "unavailable";
297 else if (sub_cause_code == 1)
298 sub_cause_code_type = "not defined";
299 else if (sub_cause_code == 2)
300 sub_cause_code_type = "traffic jam slowly increasing";
301 else if (sub_cause_code == 3)
302 sub_cause_code_type = "traffic jam increasing";
303 else if (sub_cause_code == 4)
304 sub_cause_code_type = "traffic jam strongly increasing";
305 else if (sub_cause_code == 5)
306 sub_cause_code_type = "traffic stationary";
307 else if (sub_cause_code == 6)
308 sub_cause_code_type = "traffic jam slightly decreasing";
309 else if (sub_cause_code == 7)
310 sub_cause_code_type = "traffic jam decreasing";
311 else if (sub_cause_code == 8)
312 sub_cause_code_type = "traffic jam strongly decreasing";
313 } else if (cause_code == CauseCodeType().ACCIDENT) {
314 if (sub_cause_code == 0)
315 sub_cause_code_type = "unavailable";
316 else if (sub_cause_code >= 1 && sub_cause_code <= 7)
317 sub_cause_code_type = "not defined";
318 else if (sub_cause_code == 8)
319 sub_cause_code_type = "assistance requested (e-Call)";
320 } else if (cause_code == CauseCodeType().ROADWORKS) {
321 if (sub_cause_code == 0)
322 sub_cause_code_type = "unavailable";
323 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
324 sub_cause_code_type = "not defined";
325 else if (sub_cause_code == 4)
326 sub_cause_code_type = "short-term stationary roadworks";
327 else if (sub_cause_code == 5)
328 sub_cause_code_type = "street cleaning";
329 else if (sub_cause_code == 6)
330 sub_cause_code_type = "winter service";
331 } else if (cause_code == CauseCodeType().IMPASSABILITY)
332 sub_cause_code_type = "not defined";
333 else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_ADHESION) {
334 if (sub_cause_code == 0)
335 sub_cause_code_type = "unavailable";
336 else if (sub_cause_code >= 1 && sub_cause_code <= 10)
337 sub_cause_code_type = "not defined";
338 } else if (cause_code == CauseCodeType().AQUAPLANNNING)
339 sub_cause_code_type = "not defined";
340 else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_SURFACE_CONDITION) {
341 if (sub_cause_code == 0)
342 sub_cause_code_type = "unavailable";
343 else if (sub_cause_code >= 1 && sub_cause_code <= 9)
344 sub_cause_code_type = "not defined";
345 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_OBSTACLE_ON_THE_ROAD) {
346 if (sub_cause_code == 0)
347 sub_cause_code_type = "unavailable";
348 else if (sub_cause_code >= 1 && sub_cause_code <= 7)
349 sub_cause_code_type = "not defined";
350 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_ANIMAL_ON_THE_ROAD) {
351 if (sub_cause_code == 0)
352 sub_cause_code_type = "unavailable";
353 else if (sub_cause_code >= 1 && sub_cause_code <= 4)
354 sub_cause_code_type = "not defined";
355 } else if (cause_code == CauseCodeType().HUMAN_PRESENCE_ON_THE_ROAD) {
356 if (sub_cause_code == 0)
357 sub_cause_code_type = "unavailable";
358 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
359 sub_cause_code_type = "not defined";
360 } else if (cause_code == CauseCodeType().WRONG_WAY_DRIVING) {
361 if (sub_cause_code == 0)
362 sub_cause_code_type = "unavailable";
363 else if (sub_cause_code == 1)
364 sub_cause_code_type = "vehicle driving in wrong lane";
365 else if (sub_cause_code == 2)
366 sub_cause_code_type = "vehicle driving in wrong driving direction";
367 } else if (cause_code == CauseCodeType().RESCUE_AND_RECOVERY_WORK_IN_PROGRESS) {
368 if (sub_cause_code == 0)
369 sub_cause_code_type = "unavailable";
370 else if (sub_cause_code >= 1 && sub_cause_code <= 5)
371 sub_cause_code_type = "not defined";
372 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_EXTREME_WEATHER_CONDITION) {
373 if (sub_cause_code == 0)
374 sub_cause_code_type = "unavailable";
375 else if (sub_cause_code >= 1 && sub_cause_code <= 6)
376 sub_cause_code_type = "not defined";
377 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_VISIBILITY) {
378 if (sub_cause_code == 0)
379 sub_cause_code_type = "unavailable";
380 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
381 sub_cause_code_type = "not defined";
382 } else if (cause_code == CauseCodeType().ADVERSE_WEATHER_CONDITION_PRECIPITATION) {
383 if (sub_cause_code == 0)
384 sub_cause_code_type = "unavailable";
385 else if (sub_cause_code >= 1 && sub_cause_code <= 3)
386 sub_cause_code_type = "not defined";
387 } else if (cause_code == CauseCodeType().SLOW_VEHICLE) {
388 if (sub_cause_code == 0)
389 sub_cause_code_type = "unavailable";
390 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
391 sub_cause_code_type = "not defined";
392 } else if (cause_code == CauseCodeType().DANGEROUS_END_OF_QUEUE) {
393 if (sub_cause_code == 0)
394 sub_cause_code_type = "unavailable";
395 else if (sub_cause_code >= 1 && sub_cause_code <= 8)
396 sub_cause_code_type = "not defined";
397 } else if (cause_code == CauseCodeType().VEHICLE_BREAKDOWN) {
398 if (sub_cause_code == 0)
399 sub_cause_code_type = "unavailable";
400 else if (sub_cause_code == 1)
401 sub_cause_code_type = "lack of fuel";
402 else if (sub_cause_code == 2)
403 sub_cause_code_type = "lack of battery";
404 else if (sub_cause_code == 3)
405 sub_cause_code_type = "engine problem";
406 else if (sub_cause_code == 4)
407 sub_cause_code_type = "transmission problem";
408 else if (sub_cause_code == 5)
409 sub_cause_code_type = "engine cooling problem";
410 else if (sub_cause_code == 6)
411 sub_cause_code_type = "braking system problem";
412 else if (sub_cause_code == 7)
413 sub_cause_code_type = "steering problem";
414 else if (sub_cause_code == 8)
415 sub_cause_code_type = "tyre puncture";
416 } else if (cause_code == CauseCodeType().POST_CRASH) {
417 if (sub_cause_code == 0)
418 sub_cause_code_type = "unavailable";
419 else if (sub_cause_code == 1)
420 sub_cause_code_type = "accident without e-Call triggered";
421 else if (sub_cause_code == 2)
422 sub_cause_code_type = "accident with e-Call manually triggered";
423 else if (sub_cause_code == 3)
424 sub_cause_code_type = "accident with e-Call automatical triggered";
425 else if (sub_cause_code == 4)
426 sub_cause_code_type = "accident with e-Call triggered without a possible access to a cell network";
427 } else if (cause_code == CauseCodeType().HUMAN_PROBLEM) {
428 if (sub_cause_code == 0)
429 sub_cause_code_type = "unavailable";
430 else if (sub_cause_code == 1)
431 sub_cause_code_type = "glycaemia problem";
432 else if (sub_cause_code == 2)
433 sub_cause_code_type = "heart problem";
434 } else if (cause_code == CauseCodeType().STATIONARY_VEHICLE) {
435 if (sub_cause_code == 0)
436 sub_cause_code_type = "unavailable";
437 else if (sub_cause_code == 1)
438 sub_cause_code_type = "human problem";
439 else if (sub_cause_code == 2)
440 sub_cause_code_type = "vehicle breakdown";
441 else if (sub_cause_code == 3)
442 sub_cause_code_type = "post crash";
443 else if (sub_cause_code == 4)
444 sub_cause_code_type = "public transport stop";
445 else if (sub_cause_code == 5)
446 sub_cause_code_type = "carrying dangerous goods";
447 } else if (cause_code == CauseCodeType().EMERGENCY_VEHICLE_APPROACHING) {
448 if (sub_cause_code == 0)
449 sub_cause_code_type = "unavailable";
450 else if (sub_cause_code == 1)
451 sub_cause_code_type = "emergency vehicle approaching";
452 else if (sub_cause_code == 2)
453 sub_cause_code_type = "prioritized vehicle approaching";
454 } else if (cause_code == CauseCodeType().HAZARDOUS_LOCATION_DANGEROUS_CURVE) {
455 if (sub_cause_code == 0)
456 sub_cause_code_type = "unavailable";
457 else if (sub_cause_code == 1)
458 sub_cause_code_type = "dangerous left turn curve";
459 else if (sub_cause_code == 2)
460 sub_cause_code_type = "dangerous right turn curve";
461 else if (sub_cause_code == 3)
462 sub_cause_code_type = "multiple curves starting with unknown turning direction";
463 else if (sub_cause_code == 4)
464 sub_cause_code_type = "multiple curves starting with left turn";
465 else if (sub_cause_code == 5)
466 sub_cause_code_type = "multiple curves starting with right turn";
467 } else if (cause_code == CauseCodeType().COLLISION_RISK) {
468 if (sub_cause_code == 0)
469 sub_cause_code_type = "unavailable";
470 else if (sub_cause_code == 1)
471 sub_cause_code_type = "longitudinal collision risk";
472 else if (sub_cause_code == 2)
473 sub_cause_code_type = "crossing collision risk";
474 else if (sub_cause_code == 3)
475 sub_cause_code_type = "lateral collision risk";
476 else if (sub_cause_code == 4)
477 sub_cause_code_type = "collision risk involving vulnerable road user";
478 } else if (cause_code == CauseCodeType().SIGNAL_VIOLATION) {
479 if (sub_cause_code == 0)
480 sub_cause_code_type = "unavailable";
481 else if (sub_cause_code == 1)
482 sub_cause_code_type = "stop sign violation";
483 else if (sub_cause_code == 2)
484 sub_cause_code_type = "traffic light violation";
485 else if (sub_cause_code == 3)
486 sub_cause_code_type = "turning regulation violation";
487 } else if (cause_code == CauseCodeType().DANGEROUS_SITUATION) {
488 if (sub_cause_code == 0)
489 sub_cause_code_type = "unavailable";
490 else if (sub_cause_code == 1)
491 sub_cause_code_type = "emergency electronic break lights";
492 else if (sub_cause_code == 2)
493 sub_cause_code_type = "pre-crash system activated";
494 else if (sub_cause_code == 3)
495 sub_cause_code_type = "ESP (electronic stability program) activated";
496 else if (sub_cause_code == 4)
497 sub_cause_code_type = "ABS (anti-lock breaking system) activated";
498 else if (sub_cause_code == 5)
499 sub_cause_code_type = "AEB (automatic emergency breaking) activated";
500 else if (sub_cause_code == 6)
501 sub_cause_code_type = "break warning activated";
502 else if (sub_cause_code == 7)
503 sub_cause_code_type = "collision risk warning activated";
504 }
505 return sub_cause_code_type;
506 } else {
507 throw std::invalid_argument("SituationContainer is not present!");
508 }
509}
510
517inline std::vector<bool> getDrivingLaneStatus(const DrivingLaneStatus& driving_lane_status) {
518 return getBitString(driving_lane_status.value, driving_lane_status.bits_unused);
519}
520
527inline std::vector<bool> getLightBarSirenInUse(const LightBarSirenInUse& light_bar_siren_in_use) {
528 return getBitString(light_bar_siren_in_use.value, light_bar_siren_in_use.bits_unused);
529}
530
531} // namespace etsi_its_denm_msgs::access
double getLongitude(const CAM &cam)
Get the Longitude value of CAM.
double getHeading(const Heading &heading)
Get the Heading value.
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.
gm::PointStamped getUTMPosition(const T &reference_position, int &zone, bool &northp)
Get the UTM Position defined by the given ReferencePosition.
uint32_t getStationID(const ItsPduHeader &header)
Get the StationID of ItsPduHeader.
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 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.