etsi_its_messages v3.3.0
 
Loading...
Searching...
No Matches
mcm_setters.h File Reference

Setter functions for the UULM MCM (TR) More...

Go to the source code of this file.

Functions

void etsi_its_mcm_uulm_msgs::access::setItsPduHeader (MCM &mcm, const uint32_t station_id, const uint8_t protocol_version=2)
 Sets the ITS PDU header for the given MCM message.
 
void etsi_its_mcm_uulm_msgs::access::setGenerationDeltaTime (MCM &mcm, const uint64_t unix_nanosecs, const uint16_t n_leap_seconds=etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin() ->second)
 Set the Generation Delta Time object.
 
void etsi_its_mcm_uulm_msgs::access::setStationType (MCM &mcm, const int value)
 Set the StationType for a MCM.
 
void etsi_its_mcm_uulm_msgs::access::setLatitude (Latitude &latitude, const double deg)
 Set the Latitude object.
 
void etsi_its_mcm_uulm_msgs::access::setLongitude (Longitude &longitude, const double deg)
 Set the Longitude object.
 
void etsi_its_mcm_uulm_msgs::access::setAltitudeValue (AltitudeValue &altitude, const double value)
 Set the AltitudeValue object.
 
void etsi_its_mcm_uulm_msgs::access::setAltitude (Altitude &altitude, const double value)
 Set the Altitude object.
 
void etsi_its_mcm_uulm_msgs::access::setReferencePosition (MCM &mcm, const double latitude, const double longitude, const double altitude=AltitudeValue::UNAVAILABLE)
 Set the ReferencePosition for an MCM.
 
void etsi_its_mcm_uulm_msgs::access::setFromUTMPosition (MCM &mcm, const gm::PointStamped &utm_position, const int zone, const bool northp)
 Set the ReferencePosition of a MCM from a given UTM-Position.
 
void etsi_its_mcm_uulm_msgs::access::setSpeedValue (SpeedValue &speed, const double value)
 Set the SpeedValue object.
 
void etsi_its_mcm_uulm_msgs::access::setHeadingValue (HeadingValue &heading, const double value)
 Set the HeadingValue object.
 
template<typename T>
void etsi_its_mcm_uulm_msgs::access::setRoadUserDimension (T &dim, const double value)
 Sets the dimension value for a road user (width or length).
 
void etsi_its_mcm_uulm_msgs::access::setRoadUserState (RoadUserContainer &road_user_container, const uint8_t type, const double speed, const double heading, const double length, const double width)
 Sets the state of a road user in the given container.
 
void etsi_its_mcm_uulm_msgs::access::setCartesianCoordinateLarge (CartesianCoordinateLarge &coordinate, const double value)
 Sets the value of a CartesianCoordinateLarge object.
 
void etsi_its_mcm_uulm_msgs::access::setWaypoint (Waypoint &waypoint, const double x, const double y)
 Sets the coordinates of a Waypoint object.
 

Detailed Description

Setter functions for the UULM MCM (TR)

Definition in file mcm_setters.h.

Function Documentation

◆ setAltitude()

void etsi_its_mcm_uulm_msgs::access::setAltitude ( Altitude & altitude,
const double value )
inline

Set the Altitude object.

Parameters
altitudeobject to set
valueAltitude value (above the reference ellipsoid surface) in meter as decimal number

Definition at line 132 of file mcm_setters.h.

132 {
133 altitude.altitude_confidence.value = AltitudeConfidence::UNAVAILABLE;
134 setAltitudeValue(altitude.altitude_value, value);
135}
void setAltitudeValue(AltitudeValue &altitude, const double value)
Set the AltitudeValue object.

◆ setAltitudeValue()

void etsi_its_mcm_uulm_msgs::access::setAltitudeValue ( AltitudeValue & altitude,
const double value )
inline

Set the AltitudeValue object.

Parameters
altitudeobject to set
valueAltitudeValue value (above the reference ellipsoid surface) in meter as decimal number

Definition at line 115 of file mcm_setters.h.

115 {
116 int64_t alt_in_cm = (int64_t)std::round(value * 1e2);
117 if (alt_in_cm >= AltitudeValue::MIN && alt_in_cm <= AltitudeValue::MAX) {
118 altitude.value = alt_in_cm;
119 } else if (alt_in_cm < AltitudeValue::MIN) {
120 altitude.value = AltitudeValue::MIN;
121 } else if (alt_in_cm > AltitudeValue::MAX) {
122 altitude.value = AltitudeValue::MAX;
123 }
124}

◆ setCartesianCoordinateLarge()

void etsi_its_mcm_uulm_msgs::access::setCartesianCoordinateLarge ( CartesianCoordinateLarge & coordinate,
const double value )
inline

Sets the value of a CartesianCoordinateLarge object.

If the converted value is outside the valid range, sets the value to NEGATIVE_OUT_OF_RANGE or POSITIVE_OUT_OF_RANGE accordingly.

Parameters
coordinateReference to the CartesianCoordinateLarge object to set.
valueThe coordinate value in meters.

Definition at line 272 of file mcm_setters.h.

272 {
273 auto coord_value = std::round(value * 1e2); // convert m to cm
274 if (coord_value < CartesianCoordinateLarge::MIN) {
275 coord_value = CartesianCoordinateLarge::NEGATIVE_OUT_OF_RANGE;
276 } else if (coord_value > CartesianCoordinateLarge::MAX) {
277 coord_value = CartesianCoordinateLarge::POSITIVE_OUT_OF_RANGE;
278 }
279 coordinate.value = static_cast<decltype(coordinate.value)>(coord_value);
280}

◆ setFromUTMPosition()

void etsi_its_mcm_uulm_msgs::access::setFromUTMPosition ( MCM & mcm,
const gm::PointStamped & utm_position,
const int zone,
const bool northp )
inline

Set the ReferencePosition of a MCM 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]mcmMCM 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 182 of file mcm_setters.h.

182 {
183 std::string required_frame_prefix = "utm_";
184 if (utm_position.header.frame_id.rfind(required_frame_prefix, 0) != 0) {
185 throw std::invalid_argument("Frame-ID of UTM Position '" + utm_position.header.frame_id +
186 "' does not start with required prefix '" + required_frame_prefix + "'!");
187 }
188 double latitude, longitude;
189 try {
190 GeographicLib::UTMUPS::Reverse(zone, northp, utm_position.point.x, utm_position.point.y, latitude, longitude);
191 } catch (GeographicLib::GeographicErr& e) {
192 throw std::invalid_argument(e.what());
193 }
194 setReferencePosition(mcm, latitude, longitude, utm_position.point.z);
195}
void setReferencePosition(MCM &mcm, const double latitude, const double longitude, const double altitude=AltitudeValue::UNAVAILABLE)
Set the ReferencePosition for an MCM.

◆ setGenerationDeltaTime()

void etsi_its_mcm_uulm_msgs::access::setGenerationDeltaTime ( MCM & mcm,
const uint64_t unix_nanosecs,
const uint16_t n_leap_seconds = etsi_its_msgs::LEAP_SECOND_INSERTIONS_SINCE_2004.rbegin()->second )
inline

Set the Generation Delta Time object.

Parameters
mcmMCM 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 (Defaults to the todays number of leap seconds since 2004.)

Definition at line 63 of file mcm_setters.h.

65 {
66 uint64_t t_its = unix_nanosecs * 1e-6 + (uint64_t)(n_leap_seconds * 1e3) - etsi_its_msgs::UNIX_SECONDS_2004 * 1e3;
67 uint16_t gdt_value = t_its % 65536;
68 throwIfOutOfRange(gdt_value, GenerationDeltaTime::MIN, GenerationDeltaTime::MAX, "GenerationDeltaTime");
69 mcm.mcm.generation_delta_time.value = gdt_value;
70}
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 mcm_access.h:47

◆ setHeadingValue()

void etsi_its_mcm_uulm_msgs::access::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 219 of file mcm_setters.h.

219 {
220 int64_t deg = (int64_t)std::round(value * 1e1);
221 throwIfOutOfRange(deg, HeadingValue::MIN, HeadingValue::MAX, "HeadingValue");
222 heading.value = deg;
223}

◆ setItsPduHeader()

void etsi_its_mcm_uulm_msgs::access::setItsPduHeader ( MCM & mcm,
const uint32_t station_id,
const uint8_t protocol_version = 2 )
inline

Sets the ITS PDU header for the given MCM message.

Parameters
mcmReference to the MCM message whose header will be set.
station_idThe unique identifier of the ITS station.
protocol_versionThe protocol version to use (default is 2).
Exceptions
std::out_of_rangeif the protocol_version is outside the valid range defined by OrdinalNumber1B::MIN and OrdinalNumber1B::MAX.

Definition at line 49 of file mcm_setters.h.

49 {
50 mcm.header.message_id.value = MessageId::MCM;
51 mcm.header.station_id.value = station_id;
52 throwIfOutOfRange(protocol_version, OrdinalNumber1B::MIN, OrdinalNumber1B::MAX, "ProtocolVersion");
53 mcm.header.protocol_version.value = protocol_version;
54}

◆ setLatitude()

void etsi_its_mcm_uulm_msgs::access::setLatitude ( Latitude & latitude,
const double deg )
inline

Set the Latitude object.

Parameters
latitudeobject to set
degLatitude value in degree as decimal number

Definition at line 91 of file mcm_setters.h.

91 {
92 int64_t angle_in_10_micro_degree = (int64_t)std::round(deg * 1e7);
93 throwIfOutOfRange(angle_in_10_micro_degree, Latitude::MIN, Latitude::MAX, "Latitude");
94 latitude.value = angle_in_10_micro_degree;
95}

◆ setLongitude()

void etsi_its_mcm_uulm_msgs::access::setLongitude ( Longitude & longitude,
const double deg )
inline

Set the Longitude object.

Parameters
longitudeobject to set
degLongitude value in degree as decimal number

Definition at line 103 of file mcm_setters.h.

103 {
104 int64_t angle_in_10_micro_degree = (int64_t)std::round(deg * 1e7);
105 throwIfOutOfRange(angle_in_10_micro_degree, Longitude::MIN, Longitude::MAX, "Longitude");
106 longitude.value = angle_in_10_micro_degree;
107}

◆ setReferencePosition()

void etsi_its_mcm_uulm_msgs::access::setReferencePosition ( MCM & mcm,
const double latitude,
const double longitude,
const double altitude = AltitudeValue::UNAVAILABLE )
inline

Set the ReferencePosition for an MCM.

If the altitude is not provided, it is set to AltitudeValue::UNAVAILABLE. Resets all Confidence values to UNAVAILABLE.

Parameters
mcmMCM object to set the reference position in.
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 148 of file mcm_setters.h.

149 {
150 setLatitude(mcm.mcm.mcm_parameters.basic_container.reference_position.latitude, latitude);
151 setLongitude(mcm.mcm.mcm_parameters.basic_container.reference_position.longitude, longitude);
152 if (altitude != AltitudeValue::UNAVAILABLE) {
153 setAltitude(mcm.mcm.mcm_parameters.basic_container.reference_position.altitude, altitude);
154 } else {
155 mcm.mcm.mcm_parameters.basic_container.reference_position.altitude.altitude_value.value =
156 AltitudeValue::UNAVAILABLE;
157 mcm.mcm.mcm_parameters.basic_container.reference_position.altitude.altitude_confidence.value =
158 AltitudeConfidence::UNAVAILABLE;
159 }
160
161 // reset PositionConfidenceEllipse to unavailable
162 mcm.mcm.mcm_parameters.basic_container.reference_position.position_confidence_ellipse.semi_major_axis_length.value =
163 SemiAxisLength::UNAVAILABLE;
164 mcm.mcm.mcm_parameters.basic_container.reference_position.position_confidence_ellipse.semi_minor_axis_length.value =
165 SemiAxisLength::UNAVAILABLE;
166 mcm.mcm.mcm_parameters.basic_container.reference_position.position_confidence_ellipse.semi_major_axis_orientation
167 .value = Wgs84AngleValue::UNAVAILABLE;
168}
void setAltitude(Altitude &altitude, const double value)
Set the Altitude object.
void setLatitude(Latitude &latitude, const double deg)
Set the Latitude object.
Definition mcm_setters.h:91
void setLongitude(Longitude &longitude, const double deg)
Set the Longitude object.

◆ setRoadUserDimension()

template<typename T>
void etsi_its_mcm_uulm_msgs::access::setRoadUserDimension ( T & dim,
const double value )
inline

Sets the dimension value for a road user (width or length).

Template Parameters
TType representing the road user dimension, which must have static MIN and MAX members and a value member.
Parameters
dimReference to the dimension object to be set.
valueThe dimension value (in meters) to be set.
Exceptions
std::exceptionif the scaled value is out of the allowed range.

Definition at line 235 of file mcm_setters.h.

235 {
236 int64_t dim_value = (int64_t)std::round(value * 1e1);
237 throwIfOutOfRange(dim_value, T::MIN, T::MAX, "RoadUserDimension (Width/Length)");
238 dim.value = dim_value;
239}

◆ setRoadUserState()

void etsi_its_mcm_uulm_msgs::access::setRoadUserState ( RoadUserContainer & road_user_container,
const uint8_t type,
const double speed,
const double heading,
const double length,
const double width )
inline

Sets the state of a road user in the given container.

This function updates the road user type, speed, heading, length, and width of the specified RoadUserContainer object.

Parameters
road_user_containerReference to the RoadUserContainer to update.
typeThe type of the road user (as a uint8_t value).
speedThe speed of the road user (in m/s).
headingThe heading of the road user (in degrees).
lengthThe length of the road user (in meters).
widthThe width of the road user (in meters).

Definition at line 254 of file mcm_setters.h.

255 {
256 road_user_container.road_user_state.road_user_type.value = type;
257 setSpeedValue(road_user_container.road_user_state.speed, speed);
258 setHeadingValue(road_user_container.road_user_state.heading, heading);
259 setRoadUserDimension(road_user_container.road_user_state.length, length);
260 setRoadUserDimension(road_user_container.road_user_state.width, width);
261}
void setHeadingValue(HeadingValue &heading, const double value)
Set the HeadingValue object.
void setSpeedValue(SpeedValue &speed, const double value)
Set the SpeedValue object.
void setRoadUserDimension(T &dim, const double value)
Sets the dimension value for a road user (width or length).

◆ setSpeedValue()

void etsi_its_mcm_uulm_msgs::access::setSpeedValue ( SpeedValue & speed,
const double value )
inline

Set the SpeedValue object.

Parameters
speedobject to set
valueSpeedValue in m/s as decimal number

Definition at line 205 of file mcm_setters.h.

205 {
206 auto speed_val = std::round(value * 1e2);
207 throwIfOutOfRange(speed_val, SpeedValue::MIN, SpeedValue::MAX, "SpeedValue");
208 speed.value = static_cast<decltype(speed.value)>(speed_val);
209}

◆ setStationType()

void etsi_its_mcm_uulm_msgs::access::setStationType ( MCM & mcm,
const int value )
inline

Set the StationType for a MCM.

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

Definition at line 80 of file mcm_setters.h.

80 {
81 throwIfOutOfRange(value, TrafficParticipantType::MIN, TrafficParticipantType::MAX, "StationType");
82 mcm.mcm.mcm_parameters.basic_container.station_type.value = value;
83}

◆ setWaypoint()

void etsi_its_mcm_uulm_msgs::access::setWaypoint ( Waypoint & waypoint,
const double x,
const double y )
inline

Sets the coordinates of a Waypoint object.

Parameters
waypointReference to the Waypoint object to be modified.
xThe x-coordinate value to set (in meters as decimal number).
yThe y-coordinate value to set (in meters as decimal number).

Definition at line 289 of file mcm_setters.h.

289 {
290 setCartesianCoordinateLarge(waypoint.x_distance, x);
291 setCartesianCoordinateLarge(waypoint.y_distance, y);
292}
void setCartesianCoordinateLarge(CartesianCoordinateLarge &coordinate, const double value)
Sets the value of a CartesianCoordinateLarge object.