32#ifndef ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_SETTERS_COMMON_H
33#define ETSI_ITS_MSGS_UTILS_IMPL_CAM_CAM_SETTERS_COMMON_H
37#include <etsi_its_msgs_utils/impl/asn1_primitives/asn1_primitives_setters.h>
47 GenerationDeltaTime& generation_delta_time,
const uint64_t unix_nanosecs,
51 uint16_t gdt_value = t_its.value % 65536;
52 throwIfOutOfRange(gdt_value, GenerationDeltaTime::MIN, GenerationDeltaTime::MAX,
"GenerationDeltaTime");
53 generation_delta_time.value = gdt_value;
64 CAM& cam,
const uint64_t unix_nanosecs,
76 setStationType(cam.cam.cam_parameters.basic_container.station_type, value);
88 int64_t deg = (int64_t)std::round(value * 1e1);
102inline void setHeading(Heading& heading,
const double value) {
103 heading.heading_confidence.value = HeadingConfidence::UNAVAILABLE;
117 setHeading(cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.heading,
128 int64_t width = (int64_t)std::round(value * 1e1);
129 throwIfOutOfRange(width, VehicleWidth::MIN, VehicleWidth::MAX,
"VehicleWidthValue");
130 vehicle_width.value = width;
140 int64_t length = (int64_t)std::round(value * 1e1);
141 throwIfOutOfRange(length, VehicleLengthValue::MIN, VehicleLengthValue::MAX,
"VehicleLengthValue");
142 vehicle_length.value = length;
154 vehicle_length.vehicle_length_confidence_indication.value = VehicleLengthConfidenceIndication::UNAVAILABLE;
167 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.vehicle_length,
169 setVehicleWidth(cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.vehicle_width,
179inline void setSpeed(CAM& cam,
const double speed_val) {
180 setSpeed(cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.speed, speed_val);
191 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.longitudinal_acceleration,
203 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.lateral_acceleration,
205 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency
206 .lateral_acceleration_is_present =
true;
221 const double altitude = AltitudeValue::UNAVAILABLE) {
222 setReferencePosition(cam.cam.cam_parameters.basic_container.reference_position, latitude, longitude, altitude);
237inline void setFromUTMPosition(CAM& cam,
const gm::PointStamped& utm_position,
const int& zone,
const bool& northp) {
238 setFromUTMPosition(cam.cam.cam_parameters.basic_container.reference_position, utm_position, zone, northp);
248 setBitString(exterior_lights, bits);
258 if (ExteriorLights::SIZE_BITS != exterior_lights.size()) {
259 throw std::invalid_argument(
"Vector has wrong size. (" + std::to_string(exterior_lights.size()) +
260 " != " + std::to_string(ExteriorLights::SIZE_BITS) +
")");
262 if (cam.cam.cam_parameters.low_frequency_container_is_present) {
263 if (cam.cam.cam_parameters.low_frequency_container.choice ==
264 LowFrequencyContainer::CHOICE_BASIC_VEHICLE_CONTAINER_LOW_FREQUENCY) {
266 cam.cam.cam_parameters.low_frequency_container.basic_vehicle_container_low_frequency.exterior_lights,
269 throw std::invalid_argument(
"LowFrequencyContainer is not BASIC_VEHICLE_CONTAINER_LOW_FREQUENCY!");
272 throw std::invalid_argument(
"LowFrequencyContainer is not present!");
283 setBitString(acceleration_control, bits);
293 setBitString(driving_lane_status, bits);
303 setBitString(special_transport_type, bits);
313 setBitString(light_bar_siren_in_use, bits);
323 setBitString(emergency_priority, bits);
void setLongitudinalAcceleration(CAM &cam, const double lon_accel)
Set the longitudinal acceleration.
void setVehicleLength(VehicleLength &vehicle_length, const double value)
Set the VehicleLength object.
void setLateralAcceleration(CAM &cam, const double lat_accel)
Set the lateral acceleration.
void setSpecialTransportType(SpecialTransportType &special_transport_type, const std::vector< bool > &bits)
Set the Special Transport Type by a vector of bools.
void setSpeed(CAM &cam, const double speed_val)
Set the vehicle speed.
void setLightBarSirenInUse(LightBarSirenInUse &light_bar_siren_in_use, const std::vector< bool > &bits)
Set the Lightbar Siren In Use by a vector of bools.
void setVehicleDimensions(CAM &cam, const double vehicle_length, const double vehicle_width)
Set the vehicle dimensions.
void setVehicleLengthValue(VehicleLengthValue &vehicle_length, const double value)
Set the VehicleLengthValue object.
void setHeading(Heading &heading, const double value)
Set the Heading object.
void setExteriorLights(ExteriorLights &exterior_lights, const std::vector< bool > &bits)
Set the Exterior Lights by a vector of bools.
void setStationType(CAM &cam, const uint8_t value)
Set the StationType for a CAM.
void setAccelerationControl(AccelerationControl &acceleration_control, const std::vector< bool > &bits)
Set the Acceleration Control by a vector of bools.
void setFromUTMPosition(CAM &cam, const gm::PointStamped &utm_position, const int &zone, const bool &northp)
Set the ReferencePosition of a CAM from a given UTM-Position.
void setHeadingValue(HeadingValue &heading, const double value)
Set the HeadingValue object.
void setVehicleWidth(VehicleWidth &vehicle_width, const double value)
Set the VehicleWidth object.
void setEmergencyPriority(EmergencyPriority &emergency_priority, const std::vector< bool > &bits)
Set the Emergency Priority by a vector of bools.
void setGenerationDeltaTime(GenerationDeltaTime &generation_delta_time, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.end() ->second)
Set the GenerationDeltaTime-Value.
void setReferencePosition(CAM &cam, const double latitude, const double longitude, const double altitude=AltitudeValue::UNAVAILABLE)
Set the ReferencePosition for a CAM.
void setDrivingLaneStatus(DrivingLaneStatus &driving_lane_status, const std::vector< bool > &bits)
Set the Driving Lane Status by a vector of bools.
void setTimestampITS(TimestampIts ×tamp_its, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.end() ->second)
Set the TimestampITS object.
Sanity-check functions etc.
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.
File containing constants that are used in the context of ETIS ITS Messages.
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...