etsi_its_messages 2.4.0
Loading...
Searching...
No Matches
cam_getters_common.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
32#ifndef ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_GETTERS_COMMON_H
33#define ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_GETTERS_COMMON_H
34
41inline uint32_t getStationID(const CAM& cam) { return getStationID(cam.header); }
42
49inline GenerationDeltaTime getGenerationDeltaTime(const CAM& cam) { return cam.cam.generation_delta_time; }
50
57inline uint16_t getGenerationDeltaTimeValue(const CAM& cam) { return getGenerationDeltaTime(cam).value; }
58
65inline uint8_t getStationType(const CAM& cam) { return cam.cam.cam_parameters.basic_container.station_type.value; }
66
73inline double getLatitude(const CAM& cam) {
74 return getLatitude(cam.cam.cam_parameters.basic_container.reference_position.latitude);
75}
76
83inline double getLongitude(const CAM& cam) {
84 return getLongitude(cam.cam.cam_parameters.basic_container.reference_position.longitude);
85}
86
93inline double getAltitude(const CAM& cam) {
94 return getAltitude(cam.cam.cam_parameters.basic_container.reference_position.altitude);
95}
96
105inline double getHeading(const Heading& heading) { return ((double)heading.heading_value.value) * 1e-1; }
106
115inline double getHeading(const CAM& cam) {
116 return getHeading(cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.heading);
117}
118
125inline double getVehicleLength(const VehicleLength& vehicle_length) {
126 return ((double)vehicle_length.vehicle_length_value.value) * 1e-1;
127}
128
135inline double getVehicleLength(const CAM& cam) {
136 return getVehicleLength(
137 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.vehicle_length);
138}
139
146inline double getVehicleWidth(const VehicleWidth& vehicle_width) { return ((double)vehicle_width.value) * 1e-1; }
147
154inline double getVehicleWidth(const CAM& cam) {
155 return getVehicleWidth(
156 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.vehicle_width);
157}
158
165inline double getSpeed(const CAM& cam) {
166 return getSpeed(cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.speed);
167}
168
175inline double getLongitudinalAcceleration(const CAM& cam) {
177 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.longitudinal_acceleration);
178}
179
186inline double getLateralAcceleration(const CAM& cam) {
187 if (cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency
188 .lateral_acceleration_is_present) {
190 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.lateral_acceleration);
191 } else {
192 throw std::invalid_argument("LateralAcceleration is not present!");
193 }
194}
195
207inline gm::PointStamped getUTMPosition(const CAM& cam, int& zone, bool& northp) {
208 return getUTMPosition(cam.cam.cam_parameters.basic_container.reference_position, zone, northp);
209}
210
220inline gm::PointStamped getUTMPosition(const CAM& cam) {
221 int zone;
222 bool northp;
223 return getUTMPosition(cam.cam.cam_parameters.basic_container.reference_position, zone, northp);
224}
225
232inline std::vector<bool> getExteriorLights(const ExteriorLights& exterior_lights) {
233 return getBitString(exterior_lights.value, exterior_lights.bits_unused);
234}
235
242inline std::vector<bool> getExteriorLights(const CAM& cam) {
243 if (cam.cam.cam_parameters.low_frequency_container_is_present) {
244 if (cam.cam.cam_parameters.low_frequency_container.choice ==
245 LowFrequencyContainer::CHOICE_BASIC_VEHICLE_CONTAINER_LOW_FREQUENCY) {
246 return getExteriorLights(
247 cam.cam.cam_parameters.low_frequency_container.basic_vehicle_container_low_frequency.exterior_lights);
248 } else {
249 throw std::invalid_argument("LowFrequencyContainer is not BASIC_VEHICLE_CONTAINER_LOW_FREQUENCY!");
250 }
251 } else {
252 throw std::invalid_argument("LowFrequencyContainer is not present!");
253 }
254}
255
262inline std::vector<bool> getAccelerationControl(const AccelerationControl& acceleration_control) {
263 return getBitString(acceleration_control.value, acceleration_control.bits_unused);
264}
265
272inline std::vector<bool> getDrivingLaneStatus(const DrivingLaneStatus& driving_lane_status) {
273 return getBitString(driving_lane_status.value, driving_lane_status.bits_unused);
274}
275
282inline std::vector<bool> getSpecialTransportType(const SpecialTransportType& special_transport_type) {
283 return getBitString(special_transport_type.value, special_transport_type.bits_unused);
284}
285
292inline std::vector<bool> getLightBarSirenInUse(const LightBarSirenInUse& light_bar_siren_in_use) {
293 return getBitString(light_bar_siren_in_use.value, light_bar_siren_in_use.bits_unused);
294}
295
302inline std::vector<bool> getEmergencyPriority(const EmergencyPriority& emergency_priority) {
303 return getBitString(emergency_priority.value, emergency_priority.bits_unused);
304}
305
306#endif // ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_GETTERS_COMMON_H
double getLongitude(const CAM &cam)
Get the Longitude value of CAM.
std::vector< bool > getAccelerationControl(const AccelerationControl &acceleration_control)
Get Acceleration Control in form of bool vector.
std::vector< bool > getSpecialTransportType(const SpecialTransportType &special_transport_type)
Get the Special Transport Type in form of bool vector.
double getVehicleWidth(const VehicleWidth &vehicle_width)
Get the Vehicle Width.
std::vector< bool > getLightBarSirenInUse(const LightBarSirenInUse &light_bar_siren_in_use)
Get the Lightbar Siren In Use in form of bool vector.
gm::PointStamped getUTMPosition(const CAM &cam, int &zone, bool &northp)
Get the UTM Position defined within the BasicContainer of the CAM.
uint8_t getStationType(const CAM &cam)
Get the stationType object.
double getHeading(const Heading &heading)
Get the Heading value.
double getLongitudinalAcceleration(const CAM &cam)
Get the longitudinal acceleration.
uint32_t getStationID(const CAM &cam)
Get the Station ID object.
std::vector< bool > getEmergencyPriority(const EmergencyPriority &emergency_priority)
Get the Vehicle Role in form of bool vector.
double getLateralAcceleration(const CAM &cam)
Get the lateral acceleration.
double getLatitude(const CAM &cam)
Get the Latitude value of CAM.
uint16_t getGenerationDeltaTimeValue(const CAM &cam)
Get the GenerationDeltaTime-Value.
double getSpeed(const CAM &cam)
Get the vehicle speed.
double getAltitude(const CAM &cam)
Get the Altitude value of CAM.
std::vector< bool > getExteriorLights(const ExteriorLights &exterior_lights)
Get the Exterior Lights in form of bool vector.
std::vector< bool > getDrivingLaneStatus(const DrivingLaneStatus &driving_lane_status)
Get the Driving Lane Status in form of bool vector.
double getVehicleLength(const VehicleLength &vehicle_length)
Get the Vehicle Length.
GenerationDeltaTime getGenerationDeltaTime(const CAM &cam)
Get the GenerationDeltaTime.
std::vector< bool > getBitString(const std::vector< uint8_t > &buffer, const int bits_unused)
Get a Bit String in form of bool vector.