etsi_its_messages v3.1.0
 
Loading...
Searching...
No Matches
cdd_v2-1-1_setters.h File Reference

Setter functions for the ETSI ITS Common Data Dictionary (CDD) v2.1.1. More...

#include <etsi_its_msgs_utils/impl/cdd/cdd_setters_common.h>
#include <etsi_its_msgs_utils/impl/checks.h>
#include <GeographicLib/UTMUPS.hpp>
#include <cstring>

Go to the source code of this file.

Functions

void setStationId (StationId &station_id, const uint32_t id_value)
 Set the Station Id object.
 
void setItsPduHeader (ItsPduHeader &header, const uint8_t message_id, const uint32_t station_id, const uint8_t protocol_version=0)
 Set the Its Pdu Header object.
 
void setStationType (TrafficParticipantType &station_type, const uint8_t value)
 Set the Station Type.
 
void setLongitudinalAccelerationValue (AccelerationValue &accel, const double value)
 Set the LongitudinalAccelerationValue object.
 
void setLongitudinalAcceleration (AccelerationComponent &accel, const double value, const double confidence)
 Set the LongitudinalAcceleration object.
 
void setLateralAccelerationValue (AccelerationValue &accel, const double value)
 Set the LateralAccelerationValue object.
 
void setLateralAcceleration (AccelerationComponent &accel, const double value, const double confidence)
 Set the LateralAcceleration object.
 
template<typename PositionConfidenceEllipse, typename Wgs84AngleValue = decltype(PositionConfidenceEllipse::semi_major_axis_orientation)>
void setPositionConfidenceEllipse (PositionConfidenceEllipse &position_confidence_ellipse, const double semi_major_axis, const double semi_minor_axis, const double orientation)
 Set the Position Confidence Ellipse object.
 
template<typename PositionConfidenceEllipse>
void setPositionConfidenceEllipse (PositionConfidenceEllipse &position_confidence_ellipse, const std::array< double, 4 > &covariance_matrix, const double object_heading)
 Set the Position Confidence Ellipse object.
 
template<typename PositionConfidenceEllipse>
void setWGSPositionConfidenceEllipse (PositionConfidenceEllipse &position_confidence_ellipse, const std::array< double, 4 > &covariance_matrix)
 Set the Position Confidence Ellipse object.
 

Detailed Description

Setter functions for the ETSI ITS Common Data Dictionary (CDD) v2.1.1.

Definition in file cdd_v2-1-1_setters.h.

Function Documentation

◆ setItsPduHeader()

void setItsPduHeader ( ItsPduHeader & header,
const uint8_t message_id,
const uint32_t station_id,
const uint8_t protocol_version = 0 )
inline

Set the Its Pdu Header object.

Parameters
headerItsPduHeader to be set
message_idID of the message
station_id
protocol_version

Definition at line 59 of file cdd_v2-1-1_setters.h.

60 {
61 setStationId(header.station_id, station_id);
62 throwIfOutOfRange(message_id, MessageId::MIN, MessageId::MAX, "MessageID");
63 header.message_id.value = message_id;
64 throwIfOutOfRange(protocol_version, OrdinalNumber1B::MIN, OrdinalNumber1B::MAX, "ProtocolVersion");
65 header.protocol_version.value = protocol_version;
66}
void setStationId(StationId &station_id, const uint32_t id_value)
Set the Station Id 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

◆ setLateralAcceleration()

void setLateralAcceleration ( AccelerationComponent & accel,
const double value,
const double confidence )
inline

Set the LateralAcceleration object.

AccelerationConfidence is set to UNAVAILABLE

Parameters
accelobject to set
valueLaterallAccelerationValue in m/s^2 as decimal number (left is positive)

Definition at line 134 of file cdd_v2-1-1_setters.h.

134 {
135 setAccelerationConfidence(accel.confidence, confidence);
136 setLateralAccelerationValue(accel.value, value);
137}
void setAccelerationConfidence(AccelerationConfidence &accel_confidence, const double value)
Set the Acceleration Confidence object.
void setLateralAccelerationValue(AccelerationValue &accel, const double value)
Set the LateralAccelerationValue object.

◆ setLateralAccelerationValue()

void setLateralAccelerationValue ( AccelerationValue & accel,
const double value )
inline

Set the LateralAccelerationValue object.

Parameters
accelobject to set
valueLateralAccelerationValue in m/s^2 as decimal number (left is positive)

Definition at line 115 of file cdd_v2-1-1_setters.h.

115 {
116 int64_t accel_val = (int64_t)std::round(value * 1e1);
117 if (accel_val >= AccelerationValue::MIN && accel_val <= AccelerationValue::MAX) {
118 accel.value = accel_val;
119 } else if (accel_val < AccelerationValue::MIN) {
120 accel.value = AccelerationValue::MIN;
121 } else if (accel_val > AccelerationValue::MAX) {
122 accel.value = AccelerationValue::MAX - 1;
123 }
124}

◆ setLongitudinalAcceleration()

void setLongitudinalAcceleration ( AccelerationComponent & accel,
const double value,
const double confidence )
inline

Set the LongitudinalAcceleration object.

AccelerationConfidence is set to UNAVAILABLE

Parameters
accelobject to set
valueLongitudinalAccelerationValue in m/s^2 as decimal number (braking is negative)

Definition at line 104 of file cdd_v2-1-1_setters.h.

104 {
105 setAccelerationConfidence(accel.confidence, confidence);
106 setLongitudinalAccelerationValue(accel.value, value);
107}
void setLongitudinalAccelerationValue(AccelerationValue &accel, const double value)
Set the LongitudinalAccelerationValue object.

◆ setLongitudinalAccelerationValue()

void setLongitudinalAccelerationValue ( AccelerationValue & accel,
const double value )
inline

Set the LongitudinalAccelerationValue object.

Parameters
accelobject to set
valueLongitudinalAccelerationValue in m/s^2 as decimal number (braking is negative)

Definition at line 85 of file cdd_v2-1-1_setters.h.

85 {
86 int64_t accel_val = (int64_t)std::round(value * 1e1);
87 if (accel_val >= AccelerationValue::MIN && accel_val <= AccelerationValue::MAX) {
88 accel.value = accel_val;
89 } else if (accel_val < AccelerationValue::MIN) {
90 accel.value = AccelerationValue::MIN;
91 } else if (accel_val > AccelerationValue::MAX) {
92 accel.value = AccelerationValue::MAX - 1;
93 }
94}

◆ setPositionConfidenceEllipse() [1/2]

template<typename PositionConfidenceEllipse, typename Wgs84AngleValue = decltype(PositionConfidenceEllipse::semi_major_axis_orientation)>
void setPositionConfidenceEllipse ( PositionConfidenceEllipse & position_confidence_ellipse,
const double semi_major_axis,
const double semi_minor_axis,
const double orientation )
inline

Set the Position Confidence Ellipse object.

Parameters
position_confidence_ellipseThe position confidence ellipse to set
semi_major_axisThe length of the semi-major axis in meters
semi_minor_axisThe length of the semi-minor axis in meters
orientationThe orientation of the semi-major axis in degrees, relative to WGS84

Definition at line 148 of file cdd_v2-1-1_setters.h.

149 {
150 setSemiAxis(position_confidence_ellipse.semi_major_axis_length, semi_major_axis);
151 setSemiAxis(position_confidence_ellipse.semi_minor_axis_length, semi_minor_axis);
152 setHeadingValue(position_confidence_ellipse.semi_major_axis_orientation, orientation);
153}
void setSemiAxis(SemiAxisLength &semi_axis_length, const double length)
Set the Semi Axis length.
void setHeadingValue(HeadingValue &heading, const double value)
Set the HeadingValue object.

◆ setPositionConfidenceEllipse() [2/2]

template<typename PositionConfidenceEllipse>
void setPositionConfidenceEllipse ( PositionConfidenceEllipse & position_confidence_ellipse,
const std::array< double, 4 > & covariance_matrix,
const double object_heading )
inline

Set the Position Confidence Ellipse object.

Parameters
position_confidence_ellipse
covariance_matrixThe four values of the covariance matrix in the order: cov_xx, cov_xy, cov_yx, cov_yy The matrix has to be SPD, otherwise a std::invalid_argument exception is thrown. Its coordinate system is aligned with the object (x = longitudinal, y = lateral)
object_headingThe heading of the object in rad, with respect to WGS84

Definition at line 165 of file cdd_v2-1-1_setters.h.

165 {
166 auto [semi_major_axis, semi_minor_axis, orientation] = confidenceEllipseFromCovMatrix(covariance_matrix, object_heading);
167 setPositionConfidenceEllipse(position_confidence_ellipse, semi_major_axis, semi_minor_axis, orientation);
168}
std::tuple< double, double, double > confidenceEllipseFromCovMatrix(const std::array< double, 4 > &covariance_matrix, const double object_heading)
Gets the values needed to set a confidence ellipse from a covariance matrix.
void setPositionConfidenceEllipse(PositionConfidenceEllipse &position_confidence_ellipse, const double semi_major_axis, const double semi_minor_axis, const double orientation)
Set the Position Confidence Ellipse object.

◆ setStationId()

void setStationId ( StationId & station_id,
const uint32_t id_value )
inline

Set the Station Id object.

Parameters
station_id
id_value

Definition at line 46 of file cdd_v2-1-1_setters.h.

46 {
47 throwIfOutOfRange(id_value, StationId::MIN, StationId::MAX, "StationId");
48 station_id.value = id_value;
49}

◆ setStationType()

void setStationType ( TrafficParticipantType & station_type,
const uint8_t value )
inline

Set the Station Type.

Parameters
station_type
value

Definition at line 74 of file cdd_v2-1-1_setters.h.

74 {
75 throwIfOutOfRange(value, TrafficParticipantType::MIN, TrafficParticipantType::MAX, "StationType");
76 station_type.value = value;
77}

◆ setWGSPositionConfidenceEllipse()

template<typename PositionConfidenceEllipse>
void setWGSPositionConfidenceEllipse ( PositionConfidenceEllipse & position_confidence_ellipse,
const std::array< double, 4 > & covariance_matrix )
inline

Set the Position Confidence Ellipse object.

Parameters
position_confidence_ellipse
covariance_matrixThe four values of the covariance matrix in the order: cov_xx, cov_xy, cov_yx, cov_yy The matrix has to be SPD, otherwise a std::invalid_argument exception is thrown. Its coordinate system is aligned with the WGS axes (x = North, y = East)
object_headingThe heading of the object in rad, with respect to WGS84

Definition at line 180 of file cdd_v2-1-1_setters.h.

180 {
181 auto [semi_major_axis, semi_minor_axis, orientation] = confidenceEllipseFromWGSCovMatrix(covariance_matrix);
182 setPositionConfidenceEllipse(position_confidence_ellipse, semi_major_axis, semi_minor_axis, orientation);
183}
std::tuple< double, double, double > confidenceEllipseFromWGSCovMatrix(const std::array< double, 4 > &covariance_matrix)
Gets the values needed to set a confidence ellipse from a covariance matrix.