etsi_its_messages v3.0.0
 
Loading...
Searching...
No Matches
cam_setters_common.h File Reference

Common setter functions for the ETSI ITS CAM (EN and TS) More...

#include <etsi_its_msgs_utils/impl/checks.h>
#include <etsi_its_msgs_utils/impl/constants.h>
#include <etsi_its_msgs_utils/impl/asn1_primitives/asn1_primitives_setters.h>

Go to the source code of this file.

Functions

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 setGenerationDeltaTime (CAM &cam, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.end() ->second)
 Set the Generation Delta Time object.
 
void setStationType (CAM &cam, const uint8_t value)
 Set the StationType for a CAM.
 
void setHeadingValue (HeadingValue &heading, const double value)
 Set the HeadingValue object.
 
void setHeading (Heading &heading, const double value)
 Set the Heading object.
 
void setHeading (CAM &cam, const double heading_val)
 Set the Heading for a CAM.
 
void setVehicleWidth (VehicleWidth &vehicle_width, const double value)
 Set the VehicleWidth object.
 
void setVehicleLengthValue (VehicleLengthValue &vehicle_length, const double value)
 Set the VehicleLengthValue object.
 
void setVehicleLength (VehicleLength &vehicle_length, const double value)
 Set the VehicleLength object.
 
void setVehicleDimensions (CAM &cam, const double vehicle_length, const double vehicle_width)
 Set the vehicle dimensions.
 
void setSpeed (CAM &cam, const double speed_val)
 Set the vehicle speed.
 
void setLongitudinalAcceleration (CAM &cam, const double lon_accel)
 Set the longitudinal acceleration.
 
void setLateralAcceleration (CAM &cam, const double lat_accel)
 Set the lateral acceleration.
 
void setReferencePosition (CAM &cam, const double latitude, const double longitude, const double altitude=AltitudeValue::UNAVAILABLE)
 Set the ReferencePosition for a CAM.
 
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 setExteriorLights (ExteriorLights &exterior_lights, const std::vector< bool > &bits)
 Set the Exterior Lights by a vector of bools.
 
void setExteriorLights (CAM &cam, const std::vector< bool > &exterior_lights)
 Set the Exterior Lights by using a vector of bools.
 
void setAccelerationControl (AccelerationControl &acceleration_control, const std::vector< bool > &bits)
 Set the Acceleration Control by a vector of bools.
 
void setDrivingLaneStatus (DrivingLaneStatus &driving_lane_status, const std::vector< bool > &bits)
 Set the Driving Lane Status by a vector of bools.
 
void setSpecialTransportType (SpecialTransportType &special_transport_type, const std::vector< bool > &bits)
 Set the Special Transport Type by a vector of bools.
 
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 setEmergencyPriority (EmergencyPriority &emergency_priority, const std::vector< bool > &bits)
 Set the Emergency Priority by a vector of bools.
 

Detailed Description

Common setter functions for the ETSI ITS CAM (EN and TS)

Definition in file cam_setters_common.h.

Function Documentation

◆ setAccelerationControl()

void setAccelerationControl ( AccelerationControl & acceleration_control,
const std::vector< bool > & bits )
inline

Set the Acceleration Control by a vector of bools.

Parameters
acceleration_control
bits

Definition at line 282 of file cam_setters_common.h.

282 {
283 setBitString(acceleration_control, bits);
284}

◆ setDrivingLaneStatus()

void setDrivingLaneStatus ( DrivingLaneStatus & driving_lane_status,
const std::vector< bool > & bits )
inline

Set the Driving Lane Status by a vector of bools.

Parameters
driving_lane_status
bits

Definition at line 292 of file cam_setters_common.h.

292 {
293 setBitString(driving_lane_status, bits);
294}

◆ setEmergencyPriority()

void setEmergencyPriority ( EmergencyPriority & emergency_priority,
const std::vector< bool > & bits )
inline

Set the Emergency Priority by a vector of bools.

Parameters
emergency_priority
bits

Definition at line 322 of file cam_setters_common.h.

322 {
323 setBitString(emergency_priority, bits);
324}

◆ setExteriorLights() [1/2]

void setExteriorLights ( CAM & cam,
const std::vector< bool > & exterior_lights )
inline

Set the Exterior Lights by using a vector of bools.

Parameters
camCAM to set the exterior lights
exterior_lightsvector of bools to set the exterior lights

Definition at line 257 of file cam_setters_common.h.

257 {
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) + ")");
261 }
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,
267 exterior_lights);
268 } else {
269 throw std::invalid_argument("LowFrequencyContainer is not BASIC_VEHICLE_CONTAINER_LOW_FREQUENCY!");
270 }
271 } else {
272 throw std::invalid_argument("LowFrequencyContainer is not present!");
273 }
274}
void setExteriorLights(ExteriorLights &exterior_lights, const std::vector< bool > &bits)
Set the Exterior Lights by a vector of bools.

◆ setExteriorLights() [2/2]

void setExteriorLights ( ExteriorLights & exterior_lights,
const std::vector< bool > & bits )
inline

Set the Exterior Lights by a vector of bools.

Parameters
exterior_lights
bits

Definition at line 247 of file cam_setters_common.h.

247 {
248 setBitString(exterior_lights, bits);
249}

◆ setFromUTMPosition()

void setFromUTMPosition ( CAM & cam,
const gm::PointStamped & utm_position,
const int & zone,
const bool & northp )
inline

Set the ReferencePosition of a CAM from a given UTM-Position.

The position is transformed to latitude and longitude by using GeographicLib::UTMUPS The z-Coordinate is directly used as altitude value The frame_id of the given utm_position must be set to 'utm_<zone><N/S>'

Parameters
[out]camCAM for which to set the ReferencePosition
[in]utm_positiongeometry_msgs::PointStamped describing the given utm position
[in]zonethe UTM zone (zero means UPS) of the given position
[in]northphemisphere (true means north, false means south)

Definition at line 237 of file cam_setters_common.h.

237 {
238 setFromUTMPosition(cam.cam.cam_parameters.basic_container.reference_position, utm_position, zone, northp);
239}
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.

◆ setGenerationDeltaTime() [1/2]

void setGenerationDeltaTime ( CAM & cam,
const uint64_t unix_nanosecs,
const uint16_t n_leap_seconds = etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.end()->second )
inline

Set the Generation Delta Time object.

Parameters
camCAM to set the GenerationDeltaTime-Value for
unix_nanosecsTimestamp in unix-nanoseconds to set the GenerationDeltaTime-Value from
n_leap_secondsNumber of leap seconds since 2004 for the given timestamp (Default: etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.end()->second)

Definition at line 63 of file cam_setters_common.h.

65 {
66 setGenerationDeltaTime(cam.cam.generation_delta_time, unix_nanosecs, n_leap_seconds);
67}
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.

◆ setGenerationDeltaTime() [2/2]

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 )
inline

Set the GenerationDeltaTime-Value.

Parameters
generation_delta_timeGenerationDeltaTime to set the GenerationDeltaTime-Value for
unix_nanosecsTimestamp in unix-nanoseconds to set the GenerationDeltaTime-Value from
n_leap_secondsNumber of leap seconds since 2004 for the given timestamp (Default: etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.end()->second)

Definition at line 46 of file cam_setters_common.h.

48 {
49 TimestampIts t_its;
50 setTimestampITS(t_its, unix_nanosecs, n_leap_seconds);
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;
54}
void setTimestampITS(TimestampIts &timestamp_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.
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

◆ setHeading() [1/2]

void setHeading ( CAM & cam,
const double heading_val )
inline

Set the Heading for a CAM.

0.0° equals WGS84 North, 90.0° equals WGS84 East, 180.0° equals WGS84 South and 270.0° equals WGS84 West HeadingConfidence is set to UNAVAILABLE

Parameters
camCAM to set the ReferencePosition
valueHeading value in degree as decimal number

Definition at line 116 of file cam_setters_common.h.

116 {
117 setHeading(cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.heading,
118 heading_val);
119}
void setHeading(Heading &heading, const double value)
Set the Heading object.

◆ setHeading() [2/2]

void setHeading ( Heading & heading,
const double value )
inline

Set the Heading object.

0.0° equals WGS84 North, 90.0° equals WGS84 East, 180.0° equals WGS84 South and 270.0° equals WGS84 West HeadingConfidence is set to UNAVAILABLE

Parameters
headingobject to set
valueHeading value in degree as decimal number

Definition at line 102 of file cam_setters_common.h.

102 {
103 heading.heading_confidence.value = HeadingConfidence::UNAVAILABLE;
104 setHeadingValue(heading.heading_value, value);
105}
void setHeadingValue(HeadingValue &heading, const double value)
Set the HeadingValue object.

◆ setHeadingValue()

void setHeadingValue ( HeadingValue & heading,
const double value )
inline

Set the HeadingValue object.

0.0° equals WGS84 North, 90.0° equals WGS84 East, 180.0° equals WGS84 South and 270.0° equals WGS84 West

Parameters
headingobject to set
valueHeading value in degree as decimal number

Definition at line 87 of file cam_setters_common.h.

87 {
88 int64_t deg = (int64_t)std::round(value * 1e1);
89 throwIfOutOfRange(deg, HeadingValue::MIN, HeadingValue::MAX, "HeadingValue");
90 heading.value = deg;
91}

◆ setLateralAcceleration()

void setLateralAcceleration ( CAM & cam,
const double lat_accel )
inline

Set the lateral acceleration.

Parameters
camCAM to set the acceleration value s
lat_accellateral acceleration to set in m/s^2 as decimal number (left is positiv), if not available use 16.1 m/s^2

Definition at line 201 of file cam_setters_common.h.

201 {
203 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.lateral_acceleration,
204 lat_accel);
205 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency
206 .lateral_acceleration_is_present = true;
207}
void setLateralAcceleration(CAM &cam, const double lat_accel)
Set the lateral acceleration.

◆ setLightBarSirenInUse()

void setLightBarSirenInUse ( LightBarSirenInUse & light_bar_siren_in_use,
const std::vector< bool > & bits )
inline

Set the Lightbar Siren In Use by a vector of bools.

Parameters
light_bar_siren_in_use
bits

Definition at line 312 of file cam_setters_common.h.

312 {
313 setBitString(light_bar_siren_in_use, bits);
314}

◆ setLongitudinalAcceleration()

void setLongitudinalAcceleration ( CAM & cam,
const double lon_accel )
inline

Set the longitudinal acceleration.

Parameters
camCAM to set the acceleration value s
lon_accellongitudinal acceleration to set in m/s^2 as decimal number (braking is negative), if not available use 16.1 m/s^2

Definition at line 189 of file cam_setters_common.h.

189 {
191 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.longitudinal_acceleration,
192 lon_accel);
193}
void setLongitudinalAcceleration(CAM &cam, const double lon_accel)
Set the longitudinal acceleration.

◆ setReferencePosition()

void setReferencePosition ( CAM & cam,
const double latitude,
const double longitude,
const double altitude = AltitudeValue::UNAVAILABLE )
inline

Set the ReferencePosition for a CAM.

This function sets the latitude, longitude, and altitude of the CAMs reference position. If the altitude is not provided, it is set to AltitudeValue::UNAVAILABLE.

Parameters
camCAM to set the ReferencePosition
latitudeThe latitude value position in degree as decimal number.
longitudeThe longitude value in degree as decimal number.
altitudeThe altitude value (above the reference ellipsoid surface) in meter as decimal number (optional).

Definition at line 220 of file cam_setters_common.h.

221 {
222 setReferencePosition(cam.cam.cam_parameters.basic_container.reference_position, latitude, longitude, altitude);
223}
void setReferencePosition(CAM &cam, const double latitude, const double longitude, const double altitude=AltitudeValue::UNAVAILABLE)
Set the ReferencePosition for a CAM.

◆ setSpecialTransportType()

void setSpecialTransportType ( SpecialTransportType & special_transport_type,
const std::vector< bool > & bits )
inline

Set the Special Transport Type by a vector of bools.

Parameters
special_transport_type
bits

Definition at line 302 of file cam_setters_common.h.

302 {
303 setBitString(special_transport_type, bits);
304}

◆ setSpeed()

void setSpeed ( CAM & cam,
const double speed_val )
inline

Set the vehicle speed.

Parameters
camCAM to set the speed value
speed_valspeed value to set in m/s as decimal number

Definition at line 179 of file cam_setters_common.h.

179 {
180 setSpeed(cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.speed, speed_val);
181}
void setSpeed(CAM &cam, const double speed_val)
Set the vehicle speed.

◆ setStationType()

void setStationType ( CAM & cam,
const uint8_t value )
inline

Set the StationType for a CAM.

Parameters
camCAM-Message to set the station_type value
valuestation_type value to set

Definition at line 75 of file cam_setters_common.h.

75 {
76 setStationType(cam.cam.cam_parameters.basic_container.station_type, value);
77}
void setStationType(CAM &cam, const uint8_t value)
Set the StationType for a CAM.

◆ setVehicleDimensions()

void setVehicleDimensions ( CAM & cam,
const double vehicle_length,
const double vehicle_width )
inline

Set the vehicle dimensions.

Parameters
camCAM to set the vehicle dimensions
vehicle_lengthvehicle length in meter as decimal number
vehicle_widthvehicle width in meter as decimal number

Definition at line 165 of file cam_setters_common.h.

165 {
167 cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.vehicle_length,
168 vehicle_length);
169 setVehicleWidth(cam.cam.cam_parameters.high_frequency_container.basic_vehicle_container_high_frequency.vehicle_width,
170 vehicle_width);
171}
void setVehicleLength(VehicleLength &vehicle_length, const double value)
Set the VehicleLength object.
void setVehicleWidth(VehicleWidth &vehicle_width, const double value)
Set the VehicleWidth object.

◆ setVehicleLength()

void setVehicleLength ( VehicleLength & vehicle_length,
const double value )
inline

Set the VehicleLength object.

VehicleLengthConfidenceIndication is set to UNAVAILABLE

Parameters
vehicle_lengthobject to set
valueVehicleLengthValue in meter as decimal number

Definition at line 153 of file cam_setters_common.h.

153 {
154 vehicle_length.vehicle_length_confidence_indication.value = VehicleLengthConfidenceIndication::UNAVAILABLE;
155 setVehicleLengthValue(vehicle_length.vehicle_length_value, value);
156}
void setVehicleLengthValue(VehicleLengthValue &vehicle_length, const double value)
Set the VehicleLengthValue object.

◆ setVehicleLengthValue()

void setVehicleLengthValue ( VehicleLengthValue & vehicle_length,
const double value )
inline

Set the VehicleLengthValue object.

Parameters
vehicle_lengthobject to set
valueVehicleLengthValue in meter as decimal number

Definition at line 139 of file cam_setters_common.h.

139 {
140 int64_t length = (int64_t)std::round(value * 1e1);
141 throwIfOutOfRange(length, VehicleLengthValue::MIN, VehicleLengthValue::MAX, "VehicleLengthValue");
142 vehicle_length.value = length;
143}

◆ setVehicleWidth()

void setVehicleWidth ( VehicleWidth & vehicle_width,
const double value )
inline

Set the VehicleWidth object.

Parameters
vehicle_widthobject to set
valueVehicleWidth in meter as decimal number

Definition at line 127 of file cam_setters_common.h.

127 {
128 int64_t width = (int64_t)std::round(value * 1e1);
129 throwIfOutOfRange(width, VehicleWidth::MIN, VehicleWidth::MAX, "VehicleWidthValue");
130 vehicle_width.value = width;
131}