etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
cam_ts_setters.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
3
8
9#pragma once
10
11namespace etsi_its_cam_ts_msgs::access {
12
14
16
21 * @param station_id
22 * @param protocol_version
23 */
24inline void setItsPduHeader(CAM& cam, const uint32_t station_id, const uint8_t protocol_version = 0) {
25 setItsPduHeader(cam.header, MessageId::CAM, station_id, protocol_version);
26}
27
28/**
29 * @brief Set the confidence of the reference position
30 *
31 * @param cam CAM-Message to set the confidence
32 * @param covariance_matrix The four values of the covariance matrix in the order: cov_xx, cov_xy, cov_yx, cov_yy
33 * The matrix has to be SPD, otherwise a std::invalid_argument exception is thrown.
34 * Its coordinate system is aligned with the object (x = longitudinal, y = lateral)
35 * @param object_heading heading of the object in rad, with respect to WGS84
36 */
37inline void setRefPosConfidence(CAM& cam, const std::array<double, 4>& covariance_matrix, const double object_heading) {
38 // First ensure, that the object has the correct heading by setting its value
39 double orientation = object_heading * 180 / M_PI; // Convert to degrees
40 // Normalize to [0, 360)
41 orientation = std::fmod(orientation + 360, 360);
42 while (orientation < 0) {
43 orientation += 360;
44 }
45 while (orientation >= 360) {
46 orientation -= 360;
47 }
48 setHeading(cam, orientation);
49 setPositionConfidenceEllipse(cam.cam.cam_parameters.basic_container.reference_position.position_confidence_ellipse,
50 covariance_matrix, object_heading);
51}
53/**
54 * @brief Set the confidence of the reference position
55 *
56 * @param cam CAM-Message to set the confidence
57 * @param covariance_matrix The four values of the covariance matrix in the order: cov_xx, cov_xy, cov_yx, cov_yy
58 * The matrix has to be SPD, otherwise a std::invalid_argument exception is thrown.
59 * Its coordinate system is WGS84 (x = North, y = East)
60 */
61inline void setWGSRefPosConfidence(CAM& cam, const std::array<double, 4>& covariance_matrix) {
62 setWGSPositionConfidenceEllipse(cam.cam.cam_parameters.basic_container.reference_position.position_confidence_ellipse,
63 covariance_matrix);
64}
65
67} // namespace etsi_its_cam_ts_msgs::access
Common setter functions for the ETSI ITS CAM (EN and TS).
void setHeading(CAM &cam, const double heading_val, const double confidence=std::numeric_limits< double >::infinity())
Set the Heading for a CAM.
void setWGSRefPosConfidence(CAM &cam, const std::array< double, 4 > &covariance_matrix)
Set the confidence of the reference position.
void setWGSPositionConfidenceEllipse(PositionConfidenceEllipse &position_confidence_ellipse, const std::array< double, 4 > &covariance_matrix)
Set the Position Confidence Ellipse object.
void setRefPosConfidence(CAM &cam, const std::array< double, 4 > &covariance_matrix, const double object_heading)
Set the confidence of the reference position.
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.
Setter functions for the ETSI ITS Common Data Dictionary (CDD) v2.1.1.
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.