denm_setters.h
Go to the documentation of this file.
1 /*
2 =============================================================================
3 MIT License
4 
5 Copyright (c) 2023-2025 Institute for Automotive Engineering (ika), RWTH Aachen University
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 =============================================================================
25 */
26 
32 #pragma once
33 
35 
37 
41 
49 inline void setItsPduHeader(DENM& denm, const uint32_t station_id, const uint8_t protocol_version = 0) {
50  setItsPduHeader(denm.header, ItsPduHeader::MESSAGE_ID_DENM, station_id, protocol_version);
51 }
52 
60 inline void setReferenceTime(
61  DENM& denm, const uint64_t unix_nanosecs,
62  const uint16_t n_leap_seconds = etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin()->second) {
63  TimestampIts t_its;
64  setTimestampITS(t_its, unix_nanosecs, n_leap_seconds);
65  throwIfOutOfRange(t_its.value, TimestampIts::MIN, TimestampIts::MAX, "TimestampIts");
66  denm.denm.management.reference_time = t_its;
67 }
68 
75 inline void setStationType(DENM& denm, const int value) { setStationType(denm.denm.management.station_type, value); }
76 
88 inline void setReferencePosition(DENM& denm, const double latitude, const double longitude,
89  const double altitude = AltitudeValue::UNAVAILABLE) {
90  setReferencePosition(denm.denm.management.event_position, latitude, longitude, altitude);
91 }
92 
99 inline void setIsHeadingPresent(DENM& denm, bool presence_of_heading) {
100  if (denm.denm.location_is_present) {
101  denm.denm.location.event_position_heading_is_present = presence_of_heading;
102  } else {
103  throw std::invalid_argument("LocationContainer is not present!");
104  }
105 }
106 
117 inline void setHeading(DENM& denm, const double heading_val, const double confidence = std::numeric_limits<double>::infinity()) {
118  if (denm.denm.location_is_present) {
119  setHeadingCDD(denm.denm.location.event_position_heading, heading_val, confidence);
120  setIsHeadingPresent(denm, true);
121  } else {
122  throw std::invalid_argument("LocationContainer is not present!");
123  }
124 }
125 
132 inline void setIsSpeedPresent(DENM& denm, bool presence_of_speed) {
133  if (denm.denm.location_is_present) {
134  denm.denm.location.event_speed_is_present = presence_of_speed;
135  } else {
136  throw std::invalid_argument("LocationContainer is not present!");
137  }
138 }
139 
147 inline void setSpeed(DENM& denm, const double speed_val, const double confidence = std::numeric_limits<double>::infinity()) {
148  if (denm.denm.location_is_present) {
149  setSpeed(denm.denm.location.event_speed, speed_val, confidence);
150  setIsSpeedPresent(denm, true);
151  } else {
152  throw std::invalid_argument("LocationContainer is not present!");
153  }
154 }
155 
168 inline void setFromUTMPosition(DENM& denm, const gm::PointStamped& utm_position, const int& zone, const bool& northp) {
169  setFromUTMPosition(denm.denm.management.event_position, utm_position, zone, northp);
170 }
171 
178 inline void setDrivingLaneStatus(DrivingLaneStatus& driving_lane_status, const std::vector<bool>& bits) {
179  setBitString(driving_lane_status, bits);
180 }
181 
188 inline void setLightBarSirenInUse(LightBarSirenInUse& light_bar_siren_in_use, const std::vector<bool>& bits) {
189  setBitString(light_bar_siren_in_use, bits);
190 }
191 
192 } // namespace etsi_its_denm_msgs::access
etsi_its_denm_msgs::access::setLightBarSirenInUse
void setLightBarSirenInUse(LightBarSirenInUse &light_bar_siren_in_use, const std::vector< bool > &bits)
Set the Lightbar Siren In Use by a vector of bools.
Definition: denm_setters.h:188
checks.h
Sanity-check functions etc.
etsi_its_denm_msgs::access::setIsHeadingPresent
void setIsHeadingPresent(DENM &denm, bool presence_of_heading)
Set the IsHeadingPresent object for DENM.
Definition: denm_setters.h:99
setHeadingCDD
void setHeadingCDD(Heading &heading, const double value, double confidence=std::numeric_limits< double >::infinity())
Set the Heading object.
Definition: cdd_setters_common.h:270
etsi_its_denm_msgs::access::setReferencePosition
void setReferencePosition(DENM &denm, const double latitude, const double longitude, const double altitude=AltitudeValue::UNAVAILABLE)
Set the ReferencePositionWithConfidence for a DENM.
Definition: denm_setters.h:88
etsi_its_denm_msgs::access::setFromUTMPosition
void setFromUTMPosition(DENM &denm, const gm::PointStamped &utm_position, const int &zone, const bool &northp)
Set the ReferencePosition of a DENM from a given UTM-Position.
Definition: denm_setters.h:168
etsi_its_denm_msgs::access::setStationType
void setStationType(DENM &denm, const int value)
Set the StationType for a DENM.
Definition: denm_setters.h:75
cdd_v1-3-1_setters.h
Setter functions for the ETSI ITS Common Data Dictionary (CDD) v1.3.1.
etsi_its_denm_msgs::access::setSpeed
void setSpeed(DENM &denm, const double speed_val, const double confidence=std::numeric_limits< double >::infinity())
Set the vehicle speed.
Definition: denm_setters.h:147
etsi_its_denm_msgs::access::setDrivingLaneStatus
void setDrivingLaneStatus(DrivingLaneStatus &driving_lane_status, const std::vector< bool > &bits)
Set the Driving Lane Status by a vector of bools.
Definition: denm_setters.h:178
etsi_its_denm_msgs::access::setHeading
void setHeading(DENM &denm, const double heading_val, const double confidence=std::numeric_limits< double >::infinity())
Set the Heading for a DENM.
Definition: denm_setters.h:117
constants.h
File containing constants that are used in the context of ETIS ITS Messages.
asn1_primitives_setters.h
etsi_its_denm_msgs::access::setReferenceTime
void setReferenceTime(DENM &denm, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin() ->second)
Set the ReferenceTime-value.
Definition: denm_setters.h:60
setBitString
void setBitString(T &bitstring, const std::vector< bool > &bits)
Set a Bit String by a vector of bools.
Definition: asn1_primitives_setters.h:43
setTimestampITS
void setTimestampITS(TimestampIts &timestamp_its, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin() ->second)
Set the TimestampITS object.
Definition: cdd_setters_common.h:52
etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004
const std::map< uint64_t, uint16_t > LEAP_SECOND_INSERTIONS_SINCE_2004
std::map that stores all leap second insertions since 2004 with the corresponding unix-date of the in...
Definition: constants.h:45
etsi_its_denm_msgs::access
Definition: impl/denm/denm_access.h:54
etsi_its_denm_msgs::access::setIsSpeedPresent
void setIsSpeedPresent(DENM &denm, bool presence_of_speed)
Set the IsSpeedPresent object for DENM.
Definition: denm_setters.h:132
throwIfOutOfRange
void throwIfOutOfRange(const T1 &val, const T2 &min, const T2 &max, const std::string val_desc)
Throws an exception if a given value is out of a defined range.
Definition: checks.h:46
etsi_its_denm_msgs::access::setItsPduHeader
void setItsPduHeader(DENM &denm, const uint32_t station_id, const uint8_t protocol_version=0)
Set the ItsPduHeader-object for a DENM.
Definition: denm_setters.h:49


etsi_its_msgs_utils
Author(s): Jean-Pierre Busch , Guido Küppers , Lennart Reiher
autogenerated on Sun May 18 2025 02:32:12