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

Getter functions for the ETSI ITS CPM (TS) More...

Go to the source code of this file.

Functions

uint32_t etsi_its_cpm_ts_msgs::access::getStationID (const ItsPduHeader &header)
 Get the StationID of ItsPduHeader.
 
double etsi_its_cpm_ts_msgs::access::getLatitude (const Latitude &latitude)
 Get the Latitude value.
 
double etsi_its_cpm_ts_msgs::access::getLongitude (const Longitude &longitude)
 Get the Longitude value.
 
double etsi_its_cpm_ts_msgs::access::getAltitude (const Altitude &altitude)
 Get the Altitude value.
 
double etsi_its_cpm_ts_msgs::access::getSpeed (const Speed &speed)
 Get the vehicle speed.
 
template<typename T>
gm::PointStamped etsi_its_cpm_ts_msgs::access::getUTMPosition (const T &reference_position, int &zone, bool &northp)
 Get the UTM Position defined by the given ReferencePosition.
 
double etsi_its_cpm_ts_msgs::access::getLongitudinalAcceleration (const AccelerationComponent &longitudinal_acceleration)
 Get the longitudinal acceleration.
 
double etsi_its_cpm_ts_msgs::access::getLateralAcceleration (const AccelerationComponent &lateral_acceleration)
 Get the lateral acceleration.
 
uint32_t etsi_its_cpm_ts_msgs::access::getStationID (const CollectivePerceptionMessage &cpm)
 Retrieves the station ID from the given CPM.
 
TimestampIts etsi_its_cpm_ts_msgs::access::getReferenceTime (const CollectivePerceptionMessage &cpm)
 Get the Reference Time object.
 
uint64_t etsi_its_cpm_ts_msgs::access::getReferenceTimeValue (const CollectivePerceptionMessage &cpm)
 Get the ReferenceTime-Value.
 
double etsi_its_cpm_ts_msgs::access::getLatitude (const CollectivePerceptionMessage &cpm)
 Get the Latitude value of CPM.
 
double etsi_its_cpm_ts_msgs::access::getLongitude (const CollectivePerceptionMessage &cpm)
 Get the Longitude value of CPM.
 
double etsi_its_cpm_ts_msgs::access::getAltitude (const CollectivePerceptionMessage &cpm)
 Get the Altitude value of CPM.
 
gm::PointStamped etsi_its_cpm_ts_msgs::access::getUTMPosition (const CollectivePerceptionMessage &cpm, int &zone, bool &northp)
 Get the UTM Position defined within the ManagementContainer of the CPM.
 
gm::PointStamped etsi_its_cpm_ts_msgs::access::getUTMPosition (const CollectivePerceptionMessage &cpm)
 Get the UTM Position defined within the ManagementContainer of the CPM.
 
std::vector< uint8_t > etsi_its_cpm_ts_msgs::access::getCpmContainerIds (const CollectivePerceptionMessage &cpm)
 Retrieves the container IDs from a CPM.
 
WrappedCpmContainer etsi_its_cpm_ts_msgs::access::getCpmContainer (const CollectivePerceptionMessage &cpm, const uint8_t container_id)
 
WrappedCpmContainer etsi_its_cpm_ts_msgs::access::getPerceivedObjectContainer (const CollectivePerceptionMessage &cpm)
 Retrieves the perceived object container from a CPM.
 
uint8_t etsi_its_cpm_ts_msgs::access::getNumberOfPerceivedObjects (const WrappedCpmContainer &container)
 
uint8_t etsi_its_cpm_ts_msgs::access::getNumberOfPerceivedObjects (const CollectivePerceptionMessage &cpm)
 
PerceivedObject etsi_its_cpm_ts_msgs::access::getPerceivedObject (const WrappedCpmContainer &container, const uint8_t i)
 Retrieves the PerceivedObject at the specified index from the given WrappedCpmContainer.
 
uint16_t etsi_its_cpm_ts_msgs::access::getIdOfPerceivedObject (const PerceivedObject &object)
 Retrieves the ID of a perceived object.
 
int32_t etsi_its_cpm_ts_msgs::access::getCartesianCoordinate (const CartesianCoordinateWithConfidence &coordinate)
 Retrieves the Cartesian coordinate value from a CartesianCoordinateWithConfidence object.
 
uint16_t etsi_its_cpm_ts_msgs::access::getCartesianCoordinateConfidence (const CartesianCoordinateWithConfidence &coordinate)
 Retrieves the confidence value from a CartesianCoordinateWithConfidence object.
 
gm::Point etsi_its_cpm_ts_msgs::access::getPositionOfPerceivedObject (const PerceivedObject &object)
 
uint16_t etsi_its_cpm_ts_msgs::access::getCartesianAngle (const CartesianAngle &angle)
 Get the Cartesian angle of the PerceivedObject.
 
uint8_t etsi_its_cpm_ts_msgs::access::getCartesianAngleConfidence (const CartesianAngle &angle)
 Get the confidence of the Cartesian angle.
 
gm::Quaternion etsi_its_cpm_ts_msgs::access::getOrientationOfPerceivedObject (const PerceivedObject &object)
 Calculates the orientation of a perceived object.
 
double etsi_its_cpm_ts_msgs::access::getYawOfPerceivedObject (const PerceivedObject &object)
 Get the yaw of the PerceivedObject.
 
gm::Pose etsi_its_cpm_ts_msgs::access::getPoseOfPerceivedObject (const PerceivedObject &object)
 Get the pose of the PerceivedObject.
 
int16_t etsi_its_cpm_ts_msgs::access::getYawRateOfPerceivedObject (const PerceivedObject &object)
 Get the yaw rate of the PerceivedObject.
 
double etsi_its_cpm_ts_msgs::access::getVelocityComponent (const VelocityComponent &velocity)
 Get the velocity component of the PerceivedObject.
 
double etsi_its_cpm_ts_msgs::access::getVelocityComponentConfidence (const VelocityComponent &velocity)
 Get the confidence of the velocity component.
 
gm::Vector3 etsi_its_cpm_ts_msgs::access::getCartesianVelocityOfPerceivedObject (const PerceivedObject &object)
 Get the Cartesian velocity of the PerceivedObject.
 
double etsi_its_cpm_ts_msgs::access::getAccelerationComponent (const AccelerationComponent &acceleration)
 Get the acceleration component of the PerceivedObject.
 
double etsi_its_cpm_ts_msgs::access::getAccelerationComponentConfidence (const AccelerationComponent &acceleration)
 Get the confidence of the acceleration component.
 
gm::Vector3 etsi_its_cpm_ts_msgs::access::getCartesianAccelerationOfPerceivedObject (const PerceivedObject &object)
 Get the Cartesian acceleration of the PerceivedObject.
 
uint16_t etsi_its_cpm_ts_msgs::access::getXDimensionOfPerceivedObject (const PerceivedObject &object)
 Gets the x-dimension of a perceived object.
 
uint16_t etsi_its_cpm_ts_msgs::access::getYDimensionOfPerceivedObject (const PerceivedObject &object)
 Retrieves the y-dimension of a perceived object.
 
uint16_t etsi_its_cpm_ts_msgs::access::getZDimensionOfPerceivedObject (const PerceivedObject &object)
 Retrieves the z-dimension of a perceived object.
 
gm::Vector3 etsi_its_cpm_ts_msgs::access::getDimensionsOfPerceivedObject (const PerceivedObject &object)
 Retrieves the dimensions of a perceived object.
 
gm::PointStamped etsi_its_cpm_ts_msgs::access::getUTMPositionOfPerceivedObject (const CollectivePerceptionMessage &cpm, const PerceivedObject &object)
 Calculates the UTM position of a perceived object based on the CPMs referencep position.
 

Detailed Description

Getter functions for the ETSI ITS CPM (TS)

Definition in file cpm_ts_getters.h.

Function Documentation

◆ getAccelerationComponent()

double etsi_its_cpm_ts_msgs::access::getAccelerationComponent ( const AccelerationComponent & acceleration)
inline

Get the acceleration component of the PerceivedObject.

Parameters
accelerationAccelerationComponent to get the value from
Returns
double value of the acceleration component in m/s^2

Definition at line 488 of file cpm_ts_getters.h.

◆ getAccelerationComponentConfidence()

double etsi_its_cpm_ts_msgs::access::getAccelerationComponentConfidence ( const AccelerationComponent & acceleration)
inline

Get the confidence of the acceleration component.

Parameters
accelerationAccelerationComponent to get the confidence from
Returns
double value of the confidence of the acceleration component in m/s^2

Definition at line 498 of file cpm_ts_getters.h.

◆ getAltitude() [1/2]

double etsi_its_cpm_ts_msgs::access::getAltitude ( const Altitude & altitude)
inline

Get the Altitude value.

Parameters
altitudeto get the Altitude value from
Returns
Altitude value (above the reference ellipsoid surface) in meter as decimal number

Definition at line 68 of file cpm_ts_getters.h.

◆ getAltitude() [2/2]

double etsi_its_cpm_ts_msgs::access::getAltitude ( const CollectivePerceptionMessage & cpm)
inline

Get the Altitude value of CPM.

Parameters
cpmCPM to get the Altitude value from
Returns
Altitude value in (above the reference ellipsoid surface) in meter as decimal number

Definition at line 188 of file cpm_ts_getters.h.

◆ getCartesianAccelerationOfPerceivedObject()

gm::Vector3 etsi_its_cpm_ts_msgs::access::getCartesianAccelerationOfPerceivedObject ( const PerceivedObject & object)
inline

Get the Cartesian acceleration of the PerceivedObject.

Parameters
objectPerceivedObject to get the Cartesian acceleration from
Returns
gm::Vector3 Cartesian acceleration of the PerceivedObject in m/s^2 (local coordinate system)
Exceptions
std::invalid_argumentIf the acceleration is no cartesian acceleration.

Definition at line 509 of file cpm_ts_getters.h.

◆ getCartesianAngle()

uint16_t etsi_its_cpm_ts_msgs::access::getCartesianAngle ( const CartesianAngle & angle)
inline

Get the Cartesian angle of the PerceivedObject.

Parameters
objectPerceivedObject to get the Cartesian angle from
Returns
unit16_t Cartesian angle of the PerceivedObject in 0,1 degrees

Definition at line 364 of file cpm_ts_getters.h.

◆ getCartesianAngleConfidence()

uint8_t etsi_its_cpm_ts_msgs::access::getCartesianAngleConfidence ( const CartesianAngle & angle)
inline

Get the confidence of the Cartesian angle.

Parameters
angleCartesianAngle to get the confidence from
Returns
uint8_t confidence of the Cartesian angle in 0,1 degrees

Definition at line 372 of file cpm_ts_getters.h.

372{

◆ getCartesianCoordinate()

int32_t etsi_its_cpm_ts_msgs::access::getCartesianCoordinate ( const CartesianCoordinateWithConfidence & coordinate)
inline

Retrieves the Cartesian coordinate value from a CartesianCoordinateWithConfidence object.

Parameters
coordinateThe CartesianCoordinateWithConfidence object from which to retrieve the value.
Returns
The Cartesian coordinate value in centimeters.

Definition at line 328 of file cpm_ts_getters.h.

328 {
329 gm::Pose pose;
330 pose.position = getPositionOfPerceivedObject(object);
gm::Point getPositionOfPerceivedObject(const PerceivedObject &object)

◆ getCartesianCoordinateConfidence()

uint16_t etsi_its_cpm_ts_msgs::access::getCartesianCoordinateConfidence ( const CartesianCoordinateWithConfidence & coordinate)
inline

Retrieves the confidence value from a CartesianCoordinateWithConfidence object.

Parameters
coordinateThe CartesianCoordinateWithConfidence object from which to retrieve the confidence value.
Returns
The confidence value of the CartesianCoordinateWithConfidence object in centimeters.

Definition at line 338 of file cpm_ts_getters.h.

◆ getCartesianVelocityOfPerceivedObject()

gm::Vector3 etsi_its_cpm_ts_msgs::access::getCartesianVelocityOfPerceivedObject ( const PerceivedObject & object)
inline

Get the Cartesian velocity of the PerceivedObject.

Parameters
objectPerceivedObject to get the Cartesian velocity from
Returns
gm::Vector3 Cartesian velocity of the PerceivedObject in m/s (local coordinate system)
Exceptions
std::invalid_argumentIf the velocity is no cartesian velocity.

Definition at line 468 of file cpm_ts_getters.h.

470 {
471 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
472 return object.object_dimension_z.value.value;
473}
474

◆ getCpmContainer()

WrappedCpmContainer etsi_its_cpm_ts_msgs::access::getCpmContainer ( const CollectivePerceptionMessage & cpm,
const uint8_t container_id )
inline

Retrieves the CpmContainer with the specified container ID from the CPM.

Parameters
cpmThe CPM from which to retrieve the CpmContainer.
container_idThe ID of the CpmContainer to retrieve.
Returns
The CpmContainer with the specified container ID.
Exceptions
std::invalid_argumentif no CpmContainer with the specified ID is found in the CPM.

Definition at line 247 of file cpm_ts_getters.h.

◆ getCpmContainerIds()

std::vector< uint8_t > etsi_its_cpm_ts_msgs::access::getCpmContainerIds ( const CollectivePerceptionMessage & cpm)
inline

Retrieves the container IDs from a CPM.

This function iterates over the cpm_containers array in the given CPM and extracts the container IDs into a vector of uint8_t.

Parameters
cpmThe CPM from which to retrieve the container IDs.
Returns
A vector containing the container IDs.

Definition at line 231 of file cpm_ts_getters.h.

◆ getDimensionsOfPerceivedObject()

gm::Vector3 etsi_its_cpm_ts_msgs::access::getDimensionsOfPerceivedObject ( const PerceivedObject & object)
inline

Retrieves the dimensions of a perceived object.

This function extracts the dimensions of a perceived object from the given PerceivedObject. The dimensions are returned as a gm::Vector3 object with the x, y, and z dimensions in meters.

Parameters
objectThe PerceivedObject for which to calculate the dimensions.
Returns
The dimensions of the perceived object as a gm::Vector3 object in meters.

Definition at line 580 of file cpm_ts_getters.h.

625inline uint32_t getStationID(const CollectivePerceptionMessage &cpm) { return getStationID(cpm.header); }
626
633inline TimestampIts getReferenceTime(const CollectivePerceptionMessage &cpm) {
634 return cpm.payload.management_container.reference_time;
635}
636
643inline uint64_t getReferenceTimeValue(const CollectivePerceptionMessage &cpm) { return getReferenceTime(cpm).value; }
644
651inline double getLatitude(const CollectivePerceptionMessage &cpm) {
652 return getLatitude(cpm.payload.management_container.reference_position.latitude);
653}
654
661inline double getLongitude(const CollectivePerceptionMessage &cpm) {
662 return getLongitude(cpm.payload.management_container.reference_position.longitude);
663}
664
671inline double getAltitude(const CollectivePerceptionMessage &cpm) {
672 return getAltitude(cpm.payload.management_container.reference_position.altitude);
673}
674
686inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm, int &zone, bool &northp) {
687 return getUTMPosition(cpm.payload.management_container.reference_position, zone, northp);
688}
689
699inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm) {
700 int zone;
701 bool northp;
702 return getUTMPosition(cpm, zone, northp);
703}
704
714inline std::vector<uint8_t> getCpmContainerIds(const CollectivePerceptionMessage &cpm) {
715 std::vector<uint8_t> container_ids;
716 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
717 container_ids.push_back(cpm.payload.cpm_containers.value.array[i].container_id.value);
718 }
719 return container_ids;
720}
721
730inline WrappedCpmContainer getCpmContainer(const CollectivePerceptionMessage &cpm, const uint8_t container_id) {
731 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
732 if (cpm.payload.cpm_containers.value.array[i].container_id.value == container_id) {
733 return cpm.payload.cpm_containers.value.array[i];
734 }
735 }
736 throw std::invalid_argument("No Container with ID " + std::to_string(container_id) + " found in CPM");
737}
738
747inline WrappedCpmContainer getPerceivedObjectContainer(const CollectivePerceptionMessage &cpm) {
748 return getCpmContainer(cpm, WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER);
749}
750
758inline uint8_t getNumberOfPerceivedObjects(const WrappedCpmContainer &container) {
759 if (container.container_id.value != WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER) {
760 throw std::invalid_argument("Container is not a PerceivedObjectContainer");
761 }
762 uint8_t number = container.container_data_perceived_object_container.number_of_perceived_objects.value;
763 return number;
764}
765
772inline uint8_t getNumberOfPerceivedObjects(const CollectivePerceptionMessage &cpm) {
774}
775
779
788inline PerceivedObject getPerceivedObject(const WrappedCpmContainer &container, const uint8_t i) {
789 if (i >= getNumberOfPerceivedObjects(container)) {
790 throw std::invalid_argument("Index out of range");
791 }
792 return container.container_data_perceived_object_container.perceived_objects.array[i];
793}
794
803inline uint16_t getIdOfPerceivedObject(const PerceivedObject &object) { return object.object_id.value; }
804
811inline int32_t getCartesianCoordinate(const CartesianCoordinateWithConfidence &coordinate) {
812 return coordinate.value.value;
813}
814
821inline uint16_t getCartesianCoordinateConfidence(const CartesianCoordinateWithConfidence &coordinate) {
822 return coordinate.confidence.value;
823}
824
831inline gm::Point getPositionOfPerceivedObject(const PerceivedObject &object) {
832 gm::Point point;
833 point.x = double(getCartesianCoordinate(object.position.x_coordinate)) / 100.0;
834 point.y = double(getCartesianCoordinate(object.position.y_coordinate)) / 100.0;
835 if (object.position.z_coordinate_is_present) {
836 point.z = double(getCartesianCoordinate(object.position.z_coordinate)) / 100.0;
837 }
838 return point;
839}
840
847inline uint16_t getCartesianAngle(const CartesianAngle &angle) { return angle.value.value; }
848
855inline uint8_t getCartesianAngleConfidence(const CartesianAngle &angle) { return angle.confidence.value; }
856
867inline gm::Quaternion getOrientationOfPerceivedObject(const PerceivedObject &object) {
868 if (!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
869 tf2::Quaternion q;
870 double roll{0}, pitch{0}, yaw{0};
871
872 if (object.angles.x_angle_is_present) {
873 roll = (((double(getCartesianAngle(object.angles.x_angle)) / 10.0) - 180.0) / 180.0) *
874 M_PI; // TODO: check if 0-360 -> -180-180 is correct
875 }
876 if (object.angles.y_angle_is_present) {
877 pitch = (((double(getCartesianAngle(object.angles.y_angle)) / 10.0) - 180.0) / 180.0) *
878 M_PI; // TODO: check if 0-360 -> -180-180 is correct
879 }
880 yaw = (((double(getCartesianAngle(object.angles.z_angle)) / 10.0) - 180.0) / 180.0) *
881 M_PI; // TODO: check if 0-360 -> -180-180 is correct
882 q.setRPY(roll, pitch, yaw);
883
884 return tf2::toMsg(q);
885}
886
893inline double getYawOfPerceivedObject(const PerceivedObject &object) {
894 gm::Quaternion orientation = getOrientationOfPerceivedObject(object);
895 tf2::Quaternion q(orientation.x, orientation.y, orientation.z, orientation.w);
896 double roll, pitch, yaw;
897 tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);
898 return yaw;
899}
900
907inline gm::Pose getPoseOfPerceivedObject(const PerceivedObject &object) {
908 gm::Pose pose;
909 pose.position = getPositionOfPerceivedObject(object);
910 pose.orientation = getOrientationOfPerceivedObject(object);
911 return pose;
912}
913
921inline int16_t getYawRateOfPerceivedObject(const PerceivedObject &object) {
922 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
923 return object.z_angular_velocity.value.value;
924}
925
932inline double getVelocityComponent(const VelocityComponent &velocity) { return double(velocity.value.value) / 100.0; }
933
940inline double getVelocityComponentConfidence(const VelocityComponent &velocity) {
941 return double(velocity.confidence.value) / 100.0;
942}
943
951inline gm::Vector3 getCartesianVelocityOfPerceivedObject(const PerceivedObject &object) {
952 if (!object.velocity_is_present) throw std::invalid_argument("No velocity present in PerceivedObject");
953 if (object.velocity.choice != Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
954 throw std::invalid_argument("Velocity is not Cartesian");
955 }
956 gm::Vector3 velocity;
957 velocity.x = getVelocityComponent(object.velocity.cartesian_velocity.x_velocity);
958 velocity.y = getVelocityComponent(object.velocity.cartesian_velocity.y_velocity);
959 if (object.velocity.cartesian_velocity.z_velocity_is_present) {
960 velocity.z = getVelocityComponent(object.velocity.cartesian_velocity.z_velocity);
961 }
962 return velocity;
963}
964
971inline double getAccelerationComponent(const AccelerationComponent &acceleration) {
972 return double(acceleration.value.value) / 10.0;
973}
974
981inline double getAccelerationComponentConfidence(const AccelerationComponent &acceleration) {
982 return double(acceleration.confidence.value) / 10.0;
983}
984
992inline gm::Vector3 getCartesianAccelerationOfPerceivedObject(const PerceivedObject &object) {
993 if (!object.acceleration_is_present) throw std::invalid_argument("No acceleration present in PerceivedObject");
994 if (object.acceleration.choice != Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
995 throw std::invalid_argument("Acceleration is not Cartesian");
996 }
997 gm::Vector3 acceleration;
998 acceleration.x = getAccelerationComponent(object.acceleration.cartesian_acceleration.x_acceleration);
999 acceleration.y = getAccelerationComponent(object.acceleration.cartesian_acceleration.y_acceleration);
1000 if (object.acceleration.cartesian_acceleration.z_acceleration_is_present) {
1001 acceleration.z = getAccelerationComponent(object.acceleration.cartesian_acceleration.z_acceleration);
1002 }
1003 return acceleration;
1004}
1005
1017inline uint16_t getXDimensionOfPerceivedObject(const PerceivedObject &object) {
1018 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
1019 return object.object_dimension_x.value.value;
1020}
1021
1033inline uint16_t getYDimensionOfPerceivedObject(const PerceivedObject &object) {
1034 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
1035 return object.object_dimension_y.value.value;
1036}
1037
1049inline uint16_t getZDimensionOfPerceivedObject(const PerceivedObject &object) {
1050 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
1051 return object.object_dimension_z.value.value;
1052}
1053
1063inline gm::Vector3 getDimensionsOfPerceivedObject(const PerceivedObject &object) {
1064 gm::Vector3 dimensions;
1065 dimensions.x = double(getXDimensionOfPerceivedObject(object)) / 10.0;
1066 dimensions.y = double(getYDimensionOfPerceivedObject(object)) / 10.0;
1067 dimensions.z = double(getZDimensionOfPerceivedObject(object)) / 10.0;
1068 return dimensions;
1069}
1070
1081inline gm::PointStamped getUTMPositionOfPerceivedObject(const CollectivePerceptionMessage &cpm,
1082 const PerceivedObject &object) {
1083 gm::PointStamped utm_position;
1084 gm::PointStamped reference_position = getUTMPosition(cpm);
1085 gm::Point relative_position = getPositionOfPerceivedObject(object);
1086
1087 utm_position.header.frame_id = reference_position.header.frame_id;
1088 utm_position.point.x = reference_position.point.x + relative_position.x;
1089 utm_position.point.y = reference_position.point.y + relative_position.y;
1090 utm_position.point.z = reference_position.point.z + relative_position.z;
1091
1092 return utm_position;
1093}
1094
1095} // namespace etsi_its_cpm_ts_msgs::access
Getter functions for the ETSI ITS Common Data Dictionary (CDD) v2.1.1.
double getAltitude(const Altitude &altitude)
Get the Altitude value.
uint16_t getZDimensionOfPerceivedObject(const PerceivedObject &object)
Retrieves the z-dimension of a perceived object.
uint8_t getNumberOfPerceivedObjects(const WrappedCpmContainer &container)
uint16_t getCartesianCoordinateConfidence(const CartesianCoordinateWithConfidence &coordinate)
Retrieves the confidence value from a CartesianCoordinateWithConfidence object.
uint8_t getCartesianAngleConfidence(const CartesianAngle &angle)
Get the confidence of the Cartesian angle.
uint16_t getYDimensionOfPerceivedObject(const PerceivedObject &object)
Retrieves the y-dimension of a perceived object.
double getVelocityComponent(const VelocityComponent &velocity)
Get the velocity component of the PerceivedObject.
WrappedCpmContainer getPerceivedObjectContainer(const CollectivePerceptionMessage &cpm)
Retrieves the perceived object container from a CPM.
gm::Vector3 getDimensionsOfPerceivedObject(const PerceivedObject &object)
Retrieves the dimensions of a perceived object.
gm::Pose getPoseOfPerceivedObject(const PerceivedObject &object)
Get the pose of the PerceivedObject.
int16_t getYawRateOfPerceivedObject(const PerceivedObject &object)
Get the yaw rate of the PerceivedObject.
double getYawOfPerceivedObject(const PerceivedObject &object)
Get the yaw of the PerceivedObject.
double getLongitude(const Longitude &longitude)
Get the Longitude value.
uint32_t getStationID(const ItsPduHeader &header)
Get the StationID of ItsPduHeader.
gm::PointStamped getUTMPositionOfPerceivedObject(const CollectivePerceptionMessage &cpm, const PerceivedObject &object)
Calculates the UTM position of a perceived object based on the CPMs referencep position.
double getLatitude(const Latitude &latitude)
Get the Latitude value.
uint16_t getCartesianAngle(const CartesianAngle &angle)
Get the Cartesian angle of the PerceivedObject.
double getVelocityComponentConfidence(const VelocityComponent &velocity)
Get the confidence of the velocity component.
uint16_t getIdOfPerceivedObject(const PerceivedObject &object)
Retrieves the ID of a perceived object.
gm::Vector3 getCartesianVelocityOfPerceivedObject(const PerceivedObject &object)
Get the Cartesian velocity of the PerceivedObject.
uint16_t getXDimensionOfPerceivedObject(const PerceivedObject &object)
Gets the x-dimension of a perceived object.
std::vector< uint8_t > getCpmContainerIds(const CollectivePerceptionMessage &cpm)
Retrieves the container IDs from a CPM.
double getAccelerationComponentConfidence(const AccelerationComponent &acceleration)
Get the confidence of the acceleration component.
WrappedCpmContainer getCpmContainer(const CollectivePerceptionMessage &cpm, const uint8_t container_id)
PerceivedObject getPerceivedObject(const WrappedCpmContainer &container, const uint8_t i)
Retrieves the PerceivedObject at the specified index from the given WrappedCpmContainer.
gm::Vector3 getCartesianAccelerationOfPerceivedObject(const PerceivedObject &object)
Get the Cartesian acceleration of the PerceivedObject.
double getAccelerationComponent(const AccelerationComponent &acceleration)
Get the acceleration component of the PerceivedObject.
gm::Quaternion getOrientationOfPerceivedObject(const PerceivedObject &object)
Calculates the orientation of a perceived object.
gm::PointStamped getUTMPosition(const T &reference_position, int &zone, bool &northp)
Get the UTM Position defined by the given ReferencePosition.

◆ getIdOfPerceivedObject()

uint16_t etsi_its_cpm_ts_msgs::access::getIdOfPerceivedObject ( const PerceivedObject & object)
inline

Retrieves the ID of a perceived object.

This function takes a PerceivedObject as input and returns the ID of the object.

Parameters
objectThe PerceivedObject for which to retrieve the ID.
Returns
The ID of the perceived object.

Definition at line 320 of file cpm_ts_getters.h.

◆ getLateralAcceleration()

double etsi_its_cpm_ts_msgs::access::getLateralAcceleration ( const AccelerationComponent & lateral_acceleration)
inline

Get the lateral acceleration.

Parameters
lateralAccelerationto get the lateral acceleration from
Returns
lateral acceleration in m/s^2 as decimal number (left is positive)

Definition at line 128 of file cpm_ts_getters.h.

◆ getLatitude() [1/2]

double etsi_its_cpm_ts_msgs::access::getLatitude ( const CollectivePerceptionMessage & cpm)
inline

Get the Latitude value of CPM.

Parameters
cpmCPM to get the Latitude value from
Returns
Latitude value in degree as decimal number

Definition at line 168 of file cpm_ts_getters.h.

168 {
169 return getCpmContainer(cpm, WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER);
170}

◆ getLatitude() [2/2]

double etsi_its_cpm_ts_msgs::access::getLatitude ( const Latitude & latitude)
inline

Get the Latitude value.

Parameters
latitudeto get the Latitude value from
Returns
Latitude value in degree as decimal number

Definition at line 52 of file cpm_ts_getters.h.

◆ getLongitude() [1/2]

double etsi_its_cpm_ts_msgs::access::getLongitude ( const CollectivePerceptionMessage & cpm)
inline

Get the Longitude value of CPM.

Parameters
cpmCPM to get the Longitude value from
Returns
Longitude value in degree as decimal number

Definition at line 178 of file cpm_ts_getters.h.

179 {
180 if (container.container_id.value != WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER) {

◆ getLongitude() [2/2]

double etsi_its_cpm_ts_msgs::access::getLongitude ( const Longitude & longitude)
inline

Get the Longitude value.

Parameters
longitudeto get the Longitude value from
Returns
Longitude value in degree as decimal number

Definition at line 60 of file cpm_ts_getters.h.

◆ getLongitudinalAcceleration()

double etsi_its_cpm_ts_msgs::access::getLongitudinalAcceleration ( const AccelerationComponent & longitudinal_acceleration)
inline

Get the longitudinal acceleration.

Parameters
longitudinalAccelerationto get the longitudinal acceleration from
Returns
longitudinal acceleration in m/s^2 as decimal number (left is positive)

Definition at line 118 of file cpm_ts_getters.h.

120 {

◆ getNumberOfPerceivedObjects() [1/2]

uint8_t etsi_its_cpm_ts_msgs::access::getNumberOfPerceivedObjects ( const CollectivePerceptionMessage & cpm)
inline

Retrieves the number of perceived objects from the given CPM.

Parameters
cpmThe CPM from which to retrieve the number of perceived objects.
Returns
The number of perceived objects.

Definition at line 289 of file cpm_ts_getters.h.

291 {0}, pitch{0}, yaw{0};

◆ getNumberOfPerceivedObjects() [2/2]

uint8_t etsi_its_cpm_ts_msgs::access::getNumberOfPerceivedObjects ( const WrappedCpmContainer & container)
inline

Retrieves the number of perceived objects from the given perceived object container.

Parameters
containerThe perceived object container to retrieve the number of perceived objects from.
Returns
The number of perceived objects.
Exceptions
std::invalid_argumentif the container is not a PerceivedObjectContainer.

Definition at line 275 of file cpm_ts_getters.h.

276 { return angle.confidence.value; }
277

◆ getOrientationOfPerceivedObject()

gm::Quaternion etsi_its_cpm_ts_msgs::access::getOrientationOfPerceivedObject ( const PerceivedObject & object)
inline

Calculates the orientation of a perceived object.

This function calculates the orientation of a perceived object based on the angles provided in the PerceivedObject structure. The angles are converted to radians and used to set the roll, pitch, and yaw values of a tf2::Quaternion object. The resulting quaternion is then converted to a gm::Quaternion message and returned.

Parameters
objectThe PerceivedObject structure containing the angles of the perceived object.
Returns
gm::Quaternion The orientation of the perceived object in radians from -pi to pi.

Definition at line 384 of file cpm_ts_getters.h.

402inline double getAccelerationComponentConfidence(const AccelerationComponent &acceleration) {

◆ getPerceivedObject()

PerceivedObject etsi_its_cpm_ts_msgs::access::getPerceivedObject ( const WrappedCpmContainer & container,
const uint8_t i )
inline

Retrieves the PerceivedObject at the specified index from the given WrappedCpmContainer.

Parameters
containerThe WrappedCpmContainer from which to retrieve the PerceivedObject (should be a PerceivedObjectContainer).
iThe index of the PerceivedObject to retrieve.
Returns
The PerceivedObject at the specified index.
Exceptions
std::invalid_argumentif the index is out of range.

Definition at line 305 of file cpm_ts_getters.h.

◆ getPerceivedObjectContainer()

WrappedCpmContainer etsi_its_cpm_ts_msgs::access::getPerceivedObjectContainer ( const CollectivePerceptionMessage & cpm)
inline

Retrieves the perceived object container from a CPM.

This function returns the perceived object container from the given CPM.

Parameters
cpmThe CPM from which to retrieve the perceived object container.
Returns
The perceived object container.

Definition at line 264 of file cpm_ts_getters.h.

◆ getPoseOfPerceivedObject()

gm::Pose etsi_its_cpm_ts_msgs::access::getPoseOfPerceivedObject ( const PerceivedObject & object)
inline

Get the pose of the PerceivedObject.

Parameters
objectPerceivedObject to get the pose from
Returns
gm::Pose pose of the PerceivedObject (position in m, orientation in rad)

Definition at line 424 of file cpm_ts_getters.h.

◆ getPositionOfPerceivedObject()

gm::Point etsi_its_cpm_ts_msgs::access::getPositionOfPerceivedObject ( const PerceivedObject & object)
inline

Returns the position of a perceived object.

Parameters
objectThe perceived object.
Returns
The position of the perceived object as a gm::Point (all values in meters).

Definition at line 348 of file cpm_ts_getters.h.

353 { return double(velocity.value.value) / 100.0; }
354

◆ getReferenceTime()

TimestampIts etsi_its_cpm_ts_msgs::access::getReferenceTime ( const CollectivePerceptionMessage & cpm)
inline

Get the Reference Time object.

Parameters
cpmCPM to get the ReferenceTime-Value from
Returns
TimestampIts

Definition at line 150 of file cpm_ts_getters.h.

◆ getReferenceTimeValue()

uint64_t etsi_its_cpm_ts_msgs::access::getReferenceTimeValue ( const CollectivePerceptionMessage & cpm)
inline

Get the ReferenceTime-Value.

Parameters
cpmCPM to get the ReferenceTime-Value from
Returns
uint64_t the ReferenceTime-Value in milliseconds

Definition at line 160 of file cpm_ts_getters.h.

◆ getSpeed()

double etsi_its_cpm_ts_msgs::access::getSpeed ( const Speed & speed)
inline

Get the vehicle speed.

Parameters
speedto get the speed value from
Returns
speed value in m/s as decimal number

Definition at line 76 of file cpm_ts_getters.h.

◆ getStationID() [1/2]

uint32_t etsi_its_cpm_ts_msgs::access::getStationID ( const CollectivePerceptionMessage & cpm)
inline

Retrieves the station ID from the given CPM.

This function extracts the station ID from the header of the provided CPM.

Parameters
cpmThe CPM from which to retrieve the station ID.
Returns
The station ID extracted from the header of the CPM.

Definition at line 142 of file cpm_ts_getters.h.

◆ getStationID() [2/2]

uint32_t etsi_its_cpm_ts_msgs::access::getStationID ( const ItsPduHeader & header)
inline

Get the StationID of ItsPduHeader.

Parameters
headerItsPduHeader to get the StationID value from
Returns
stationID value

Definition at line 44 of file cpm_ts_getters.h.

◆ getUTMPosition() [1/3]

gm::PointStamped etsi_its_cpm_ts_msgs::access::getUTMPosition ( const CollectivePerceptionMessage & cpm)
inline

Get the UTM Position defined within the ManagementContainer of the CPM.

The position is transformed into UTM by using GeographicLib::UTMUPS The altitude value is directly used as z-Coordinate

Parameters
cpmCPM from which to extract the UTM position.
Returns
geometry_msgs::PointStamped of the given position with the UTM zone and hemisphere as frame_id

Definition at line 216 of file cpm_ts_getters.h.

◆ getUTMPosition() [2/3]

gm::PointStamped etsi_its_cpm_ts_msgs::access::getUTMPosition ( const CollectivePerceptionMessage & cpm,
int & zone,
bool & northp )
inline

Get the UTM Position defined within the ManagementContainer of the CPM.

The position is transformed into UTM by using GeographicLib::UTMUPS The altitude value is directly used as z-Coordinate

Parameters
[in]cpmCPM to get the UTM Position from
[out]zonethe UTM zone (zero means UPS)
[out]northphemisphere (true means north, false means south)
Returns
geometry_msgs::PointStamped of the given position with the UTM zone and hemisphere as frame_id

Definition at line 203 of file cpm_ts_getters.h.

◆ getUTMPosition() [3/3]

template<typename T>
gm::PointStamped etsi_its_cpm_ts_msgs::access::getUTMPosition ( const T & reference_position,
int & zone,
bool & northp )
inline

Get the UTM Position defined by the given ReferencePosition.

The position is transformed into UTM by using GeographicLib::UTMUPS The altitude value is directly used as z-Coordinate

Parameters
[in]reference_positionReferencePosition or ReferencePositionWithConfidence to get the UTM Position from
[out]zonethe UTM zone (zero means UPS)
[out]northphemisphere (true means north, false means south)
Returns
gm::PointStamped geometry_msgs::PointStamped of the given position

Definition at line 90 of file cpm_ts_getters.h.

107inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm, int &zone, bool &northp) {
108 return getUTMPosition(cpm.payload.management_container.reference_position, zone, northp);
gm::PointStamped getUTMPosition(const CAM &cam, int &zone, bool &northp)
Get the UTM Position defined within the BasicContainer of the CAM.

◆ getUTMPositionOfPerceivedObject()

gm::PointStamped etsi_its_cpm_ts_msgs::access::getUTMPositionOfPerceivedObject ( const CollectivePerceptionMessage & cpm,
const PerceivedObject & object )
inline

Calculates the UTM position of a perceived object based on the CPMs referencep position.

This function takes a CPM and a PerceivedObject as input parameters and calculates the UTM position of the object. The UTM position is calculated by adding the relative position of the object to the UTM position of the reference point in the CPM.

Parameters
cpmThe Collective Perception Message (CPM) containing the reference position.
objectThe PerceivedObject for which the UTM position needs to be calculated.
Returns
The UTM position of the perceived object.

Definition at line 598 of file cpm_ts_getters.h.

631 {
632
634
643inline uint32_t getStationID(const CollectivePerceptionMessage &cpm) { return getStationID(cpm.header); }
644
651inline TimestampIts getReferenceTime(const CollectivePerceptionMessage &cpm) {
652 return cpm.payload.management_container.reference_time;
653}
654
661inline uint64_t getReferenceTimeValue(const CollectivePerceptionMessage &cpm) { return getReferenceTime(cpm).value; }
662
669inline double getLatitude(const CollectivePerceptionMessage &cpm) {
670 return getLatitude(cpm.payload.management_container.reference_position.latitude);
671}
672
679inline double getLongitude(const CollectivePerceptionMessage &cpm) {
680 return getLongitude(cpm.payload.management_container.reference_position.longitude);
681}
682
689inline double getAltitude(const CollectivePerceptionMessage &cpm) {
690 return getAltitude(cpm.payload.management_container.reference_position.altitude);
691}
692
704inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm, int &zone, bool &northp) {
705 return getUTMPosition(cpm.payload.management_container.reference_position, zone, northp);
706}
707
717inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm) {
718 int zone;
719 bool northp;
720 return getUTMPosition(cpm, zone, northp);
721}
722
732inline std::vector<uint8_t> getCpmContainerIds(const CollectivePerceptionMessage &cpm) {
733 std::vector<uint8_t> container_ids;
734 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
735 container_ids.push_back(cpm.payload.cpm_containers.value.array[i].container_id.value);
736 }
737 return container_ids;
738}
739
748inline WrappedCpmContainer getCpmContainer(const CollectivePerceptionMessage &cpm, const uint8_t container_id) {
749 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
750 if (cpm.payload.cpm_containers.value.array[i].container_id.value == container_id) {
751 return cpm.payload.cpm_containers.value.array[i];
752 }
753 }
754 throw std::invalid_argument("No Container with ID " + std::to_string(container_id) + " found in CPM");
755}
756
765inline WrappedCpmContainer getPerceivedObjectContainer(const CollectivePerceptionMessage &cpm) {
766 return getCpmContainer(cpm, WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER);
767}
768
776inline uint8_t getNumberOfPerceivedObjects(const WrappedCpmContainer &container) {
777 if (container.container_id.value != WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER) {
778 throw std::invalid_argument("Container is not a PerceivedObjectContainer");
779 }
780 uint8_t number = container.container_data_perceived_object_container.number_of_perceived_objects.value;
781 return number;
782}
783
790inline uint8_t getNumberOfPerceivedObjects(const CollectivePerceptionMessage &cpm) {
792}
793
797
806inline PerceivedObject getPerceivedObject(const WrappedCpmContainer &container, const uint8_t i) {
807 if (i >= getNumberOfPerceivedObjects(container)) {
808 throw std::invalid_argument("Index out of range");
809 }
810 return container.container_data_perceived_object_container.perceived_objects.array[i];
811}
812
821inline uint16_t getIdOfPerceivedObject(const PerceivedObject &object) { return object.object_id.value; }
822
829inline int32_t getCartesianCoordinate(const CartesianCoordinateWithConfidence &coordinate) {
830 return coordinate.value.value;
831}
832
839inline uint16_t getCartesianCoordinateConfidence(const CartesianCoordinateWithConfidence &coordinate) {
840 return coordinate.confidence.value;
841}
842
849inline gm::Point getPositionOfPerceivedObject(const PerceivedObject &object) {
850 gm::Point point;
851 point.x = double(getCartesianCoordinate(object.position.x_coordinate)) / 100.0;
852 point.y = double(getCartesianCoordinate(object.position.y_coordinate)) / 100.0;
853 if (object.position.z_coordinate_is_present) {
854 point.z = double(getCartesianCoordinate(object.position.z_coordinate)) / 100.0;
855 }
856 return point;
857}
858
865inline uint16_t getCartesianAngle(const CartesianAngle &angle) { return angle.value.value; }
866
873inline uint8_t getCartesianAngleConfidence(const CartesianAngle &angle) { return angle.confidence.value; }
874
885inline gm::Quaternion getOrientationOfPerceivedObject(const PerceivedObject &object) {
886 if (!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
887 tf2::Quaternion q;
888 double roll{0}, pitch{0}, yaw{0};
889
890 if (object.angles.x_angle_is_present) {
891 roll = (((double(getCartesianAngle(object.angles.x_angle)) / 10.0) - 180.0) / 180.0) *
892 M_PI; // TODO: check if 0-360 -> -180-180 is correct
893 }
894 if (object.angles.y_angle_is_present) {
895 pitch = (((double(getCartesianAngle(object.angles.y_angle)) / 10.0) - 180.0) / 180.0) *
896 M_PI; // TODO: check if 0-360 -> -180-180 is correct
897 }
898 yaw = (((double(getCartesianAngle(object.angles.z_angle)) / 10.0) - 180.0) / 180.0) *
899 M_PI; // TODO: check if 0-360 -> -180-180 is correct
900 q.setRPY(roll, pitch, yaw);
901
902 return tf2::toMsg(q);
903}
904
911inline double getYawOfPerceivedObject(const PerceivedObject &object) {
912 gm::Quaternion orientation = getOrientationOfPerceivedObject(object);
913 tf2::Quaternion q(orientation.x, orientation.y, orientation.z, orientation.w);
914 double roll, pitch, yaw;
915 tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);
916 return yaw;
917}
918
925inline gm::Pose getPoseOfPerceivedObject(const PerceivedObject &object) {
926 gm::Pose pose;
927 pose.position = getPositionOfPerceivedObject(object);
928 pose.orientation = getOrientationOfPerceivedObject(object);
929 return pose;
930}
931
939inline int16_t getYawRateOfPerceivedObject(const PerceivedObject &object) {
940 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
941 return object.z_angular_velocity.value.value;
942}
943
950inline double getVelocityComponent(const VelocityComponent &velocity) { return double(velocity.value.value) / 100.0; }
951
958inline double getVelocityComponentConfidence(const VelocityComponent &velocity) {
959 return double(velocity.confidence.value) / 100.0;
960}
961
969inline gm::Vector3 getCartesianVelocityOfPerceivedObject(const PerceivedObject &object) {
970 if (!object.velocity_is_present) throw std::invalid_argument("No velocity present in PerceivedObject");
971 if (object.velocity.choice != Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
972 throw std::invalid_argument("Velocity is not Cartesian");
973 }
974 gm::Vector3 velocity;
975 velocity.x = getVelocityComponent(object.velocity.cartesian_velocity.x_velocity);
976 velocity.y = getVelocityComponent(object.velocity.cartesian_velocity.y_velocity);
977 if (object.velocity.cartesian_velocity.z_velocity_is_present) {
978 velocity.z = getVelocityComponent(object.velocity.cartesian_velocity.z_velocity);
979 }
980 return velocity;
981}
982
989inline double getAccelerationComponent(const AccelerationComponent &acceleration) {
990 return double(acceleration.value.value) / 10.0;
991}
992
999inline double getAccelerationComponentConfidence(const AccelerationComponent &acceleration) {
1000 return double(acceleration.confidence.value) / 10.0;
1001}
1002
1010inline gm::Vector3 getCartesianAccelerationOfPerceivedObject(const PerceivedObject &object) {
1011 if (!object.acceleration_is_present) throw std::invalid_argument("No acceleration present in PerceivedObject");
1012 if (object.acceleration.choice != Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
1013 throw std::invalid_argument("Acceleration is not Cartesian");
1014 }
1015 gm::Vector3 acceleration;
1016 acceleration.x = getAccelerationComponent(object.acceleration.cartesian_acceleration.x_acceleration);
1017 acceleration.y = getAccelerationComponent(object.acceleration.cartesian_acceleration.y_acceleration);
1018 if (object.acceleration.cartesian_acceleration.z_acceleration_is_present) {
1019 acceleration.z = getAccelerationComponent(object.acceleration.cartesian_acceleration.z_acceleration);
1020 }
1021 return acceleration;
1022}
1023
1035inline uint16_t getXDimensionOfPerceivedObject(const PerceivedObject &object) {
1036 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
1037 return object.object_dimension_x.value.value;
1038}
1039
1051inline uint16_t getYDimensionOfPerceivedObject(const PerceivedObject &object) {
1052 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
1053 return object.object_dimension_y.value.value;
1054}
1055
1067inline uint16_t getZDimensionOfPerceivedObject(const PerceivedObject &object) {
1068 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
1069 return object.object_dimension_z.value.value;
1070}
1071
1081inline gm::Vector3 getDimensionsOfPerceivedObject(const PerceivedObject &object) {
1082 gm::Vector3 dimensions;
1083 dimensions.x = double(getXDimensionOfPerceivedObject(object)) / 10.0;
1084 dimensions.y = double(getYDimensionOfPerceivedObject(object)) / 10.0;
1085 dimensions.z = double(getZDimensionOfPerceivedObject(object)) / 10.0;
1086 return dimensions;
1087}
1088
1099inline gm::PointStamped getUTMPositionOfPerceivedObject(const CollectivePerceptionMessage &cpm,
1100 const PerceivedObject &object) {
1101 gm::PointStamped utm_position;
1102 gm::PointStamped reference_position = getUTMPosition(cpm);
1103 gm::Point relative_position = getPositionOfPerceivedObject(object);
1104
1105 utm_position.header.frame_id = reference_position.header.frame_id;
1106 utm_position.point.x = reference_position.point.x + relative_position.x;
1107 utm_position.point.y = reference_position.point.y + relative_position.y;
1108 utm_position.point.z = reference_position.point.z + relative_position.z;
1109
1110 return utm_position;
1111}
1112
1113} // namespace etsi_its_cpm_ts_msgs::access

◆ getVelocityComponent()

double etsi_its_cpm_ts_msgs::access::getVelocityComponent ( const VelocityComponent & velocity)
inline

Get the velocity component of the PerceivedObject.

Parameters
velocityVelocityComponent to get the value from
Returns
double value of the velocity component in m/s

Definition at line 449 of file cpm_ts_getters.h.

◆ getVelocityComponentConfidence()

double etsi_its_cpm_ts_msgs::access::getVelocityComponentConfidence ( const VelocityComponent & velocity)
inline

Get the confidence of the velocity component.

Parameters
velocityVelocityComponent to get the confidence from
Returns
double value of the confidence of the velocity component in m/s

Definition at line 457 of file cpm_ts_getters.h.

◆ getXDimensionOfPerceivedObject()

uint16_t etsi_its_cpm_ts_msgs::access::getXDimensionOfPerceivedObject ( const PerceivedObject & object)
inline

Gets the x-dimension of a perceived object.

This function extracts the x-dimension from a given PerceivedObject. If the x-dimension is not present in the object, it throws an std::invalid_argument exception.

Parameters
objectThe PerceivedObject from which to retrieve the x-dimension.
Returns
The x-dimension of the perceived object in decimeters.
Exceptions
std::invalid_argumentif the x-dimension is not present in the PerceivedObject.

Definition at line 534 of file cpm_ts_getters.h.

567 {
568
570
579inline uint32_t getStationID(const CollectivePerceptionMessage &cpm) { return getStationID(cpm.header); }
580
587inline TimestampIts getReferenceTime(const CollectivePerceptionMessage &cpm) {
588 return cpm.payload.management_container.reference_time;
589}
590
597inline uint64_t getReferenceTimeValue(const CollectivePerceptionMessage &cpm) { return getReferenceTime(cpm).value; }
598
605inline double getLatitude(const CollectivePerceptionMessage &cpm) {
606 return getLatitude(cpm.payload.management_container.reference_position.latitude);
607}
608
615inline double getLongitude(const CollectivePerceptionMessage &cpm) {
616 return getLongitude(cpm.payload.management_container.reference_position.longitude);
617}
618
625inline double getAltitude(const CollectivePerceptionMessage &cpm) {
626 return getAltitude(cpm.payload.management_container.reference_position.altitude);
627}
628
640inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm, int &zone, bool &northp) {
641 return getUTMPosition(cpm.payload.management_container.reference_position, zone, northp);
642}
643
653inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm) {
654 int zone;
655 bool northp;
656 return getUTMPosition(cpm, zone, northp);
657}
658
668inline std::vector<uint8_t> getCpmContainerIds(const CollectivePerceptionMessage &cpm) {
669 std::vector<uint8_t> container_ids;
670 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
671 container_ids.push_back(cpm.payload.cpm_containers.value.array[i].container_id.value);
672 }
673 return container_ids;
674}
675
684inline WrappedCpmContainer getCpmContainer(const CollectivePerceptionMessage &cpm, const uint8_t container_id) {
685 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
686 if (cpm.payload.cpm_containers.value.array[i].container_id.value == container_id) {
687 return cpm.payload.cpm_containers.value.array[i];
688 }
689 }
690 throw std::invalid_argument("No Container with ID " + std::to_string(container_id) + " found in CPM");
691}
692
701inline WrappedCpmContainer getPerceivedObjectContainer(const CollectivePerceptionMessage &cpm) {
702 return getCpmContainer(cpm, WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER);
703}
704
712inline uint8_t getNumberOfPerceivedObjects(const WrappedCpmContainer &container) {
713 if (container.container_id.value != WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER) {
714 throw std::invalid_argument("Container is not a PerceivedObjectContainer");
715 }
716 uint8_t number = container.container_data_perceived_object_container.number_of_perceived_objects.value;
717 return number;
718}
719
726inline uint8_t getNumberOfPerceivedObjects(const CollectivePerceptionMessage &cpm) {
728}
729
733
742inline PerceivedObject getPerceivedObject(const WrappedCpmContainer &container, const uint8_t i) {
743 if (i >= getNumberOfPerceivedObjects(container)) {
744 throw std::invalid_argument("Index out of range");
745 }
746 return container.container_data_perceived_object_container.perceived_objects.array[i];
747}
748
757inline uint16_t getIdOfPerceivedObject(const PerceivedObject &object) { return object.object_id.value; }
758
765inline int32_t getCartesianCoordinate(const CartesianCoordinateWithConfidence &coordinate) {
766 return coordinate.value.value;
767}
768
775inline uint16_t getCartesianCoordinateConfidence(const CartesianCoordinateWithConfidence &coordinate) {
776 return coordinate.confidence.value;
777}
778
785inline gm::Point getPositionOfPerceivedObject(const PerceivedObject &object) {
786 gm::Point point;
787 point.x = double(getCartesianCoordinate(object.position.x_coordinate)) / 100.0;
788 point.y = double(getCartesianCoordinate(object.position.y_coordinate)) / 100.0;
789 if (object.position.z_coordinate_is_present) {
790 point.z = double(getCartesianCoordinate(object.position.z_coordinate)) / 100.0;
791 }
792 return point;
793}
794
801inline uint16_t getCartesianAngle(const CartesianAngle &angle) { return angle.value.value; }
802
809inline uint8_t getCartesianAngleConfidence(const CartesianAngle &angle) { return angle.confidence.value; }
810
821inline gm::Quaternion getOrientationOfPerceivedObject(const PerceivedObject &object) {
822 if (!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
823 tf2::Quaternion q;
824 double roll{0}, pitch{0}, yaw{0};
825
826 if (object.angles.x_angle_is_present) {
827 roll = (((double(getCartesianAngle(object.angles.x_angle)) / 10.0) - 180.0) / 180.0) *
828 M_PI; // TODO: check if 0-360 -> -180-180 is correct
829 }
830 if (object.angles.y_angle_is_present) {
831 pitch = (((double(getCartesianAngle(object.angles.y_angle)) / 10.0) - 180.0) / 180.0) *
832 M_PI; // TODO: check if 0-360 -> -180-180 is correct
833 }
834 yaw = (((double(getCartesianAngle(object.angles.z_angle)) / 10.0) - 180.0) / 180.0) *
835 M_PI; // TODO: check if 0-360 -> -180-180 is correct
836 q.setRPY(roll, pitch, yaw);
837
838 return tf2::toMsg(q);
839}
840
847inline double getYawOfPerceivedObject(const PerceivedObject &object) {
848 gm::Quaternion orientation = getOrientationOfPerceivedObject(object);
849 tf2::Quaternion q(orientation.x, orientation.y, orientation.z, orientation.w);
850 double roll, pitch, yaw;
851 tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);
852 return yaw;
853}
854
861inline gm::Pose getPoseOfPerceivedObject(const PerceivedObject &object) {
862 gm::Pose pose;
863 pose.position = getPositionOfPerceivedObject(object);
864 pose.orientation = getOrientationOfPerceivedObject(object);
865 return pose;
866}
867
875inline int16_t getYawRateOfPerceivedObject(const PerceivedObject &object) {
876 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
877 return object.z_angular_velocity.value.value;
878}
879
886inline double getVelocityComponent(const VelocityComponent &velocity) { return double(velocity.value.value) / 100.0; }
887
894inline double getVelocityComponentConfidence(const VelocityComponent &velocity) {
895 return double(velocity.confidence.value) / 100.0;
896}
897
905inline gm::Vector3 getCartesianVelocityOfPerceivedObject(const PerceivedObject &object) {
906 if (!object.velocity_is_present) throw std::invalid_argument("No velocity present in PerceivedObject");
907 if (object.velocity.choice != Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
908 throw std::invalid_argument("Velocity is not Cartesian");
909 }
910 gm::Vector3 velocity;
911 velocity.x = getVelocityComponent(object.velocity.cartesian_velocity.x_velocity);
912 velocity.y = getVelocityComponent(object.velocity.cartesian_velocity.y_velocity);
913 if (object.velocity.cartesian_velocity.z_velocity_is_present) {
914 velocity.z = getVelocityComponent(object.velocity.cartesian_velocity.z_velocity);
915 }
916 return velocity;
917}
918
925inline double getAccelerationComponent(const AccelerationComponent &acceleration) {
926 return double(acceleration.value.value) / 10.0;
927}
928
935inline double getAccelerationComponentConfidence(const AccelerationComponent &acceleration) {
936 return double(acceleration.confidence.value) / 10.0;
937}
938
946inline gm::Vector3 getCartesianAccelerationOfPerceivedObject(const PerceivedObject &object) {
947 if (!object.acceleration_is_present) throw std::invalid_argument("No acceleration present in PerceivedObject");
948 if (object.acceleration.choice != Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
949 throw std::invalid_argument("Acceleration is not Cartesian");
950 }
951 gm::Vector3 acceleration;
952 acceleration.x = getAccelerationComponent(object.acceleration.cartesian_acceleration.x_acceleration);
953 acceleration.y = getAccelerationComponent(object.acceleration.cartesian_acceleration.y_acceleration);
954 if (object.acceleration.cartesian_acceleration.z_acceleration_is_present) {
955 acceleration.z = getAccelerationComponent(object.acceleration.cartesian_acceleration.z_acceleration);
956 }
957 return acceleration;
958}
959
971inline uint16_t getXDimensionOfPerceivedObject(const PerceivedObject &object) {
972 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
973 return object.object_dimension_x.value.value;
974}
975
987inline uint16_t getYDimensionOfPerceivedObject(const PerceivedObject &object) {
988 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
989 return object.object_dimension_y.value.value;
990}
991
1003inline uint16_t getZDimensionOfPerceivedObject(const PerceivedObject &object) {
1004 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
1005 return object.object_dimension_z.value.value;
1006}
1007
1017inline gm::Vector3 getDimensionsOfPerceivedObject(const PerceivedObject &object) {
1018 gm::Vector3 dimensions;
1019 dimensions.x = double(getXDimensionOfPerceivedObject(object)) / 10.0;
1020 dimensions.y = double(getYDimensionOfPerceivedObject(object)) / 10.0;
1021 dimensions.z = double(getZDimensionOfPerceivedObject(object)) / 10.0;
1022 return dimensions;
1023}
1024
1035inline gm::PointStamped getUTMPositionOfPerceivedObject(const CollectivePerceptionMessage &cpm,
1036 const PerceivedObject &object) {
1037 gm::PointStamped utm_position;
1038 gm::PointStamped reference_position = getUTMPosition(cpm);
1039 gm::Point relative_position = getPositionOfPerceivedObject(object);
1040
1041 utm_position.header.frame_id = reference_position.header.frame_id;
1042 utm_position.point.x = reference_position.point.x + relative_position.x;
1043 utm_position.point.y = reference_position.point.y + relative_position.y;
1044 utm_position.point.z = reference_position.point.z + relative_position.z;
1045
1046 return utm_position;
1047}
1048
1049} // namespace etsi_its_cpm_ts_msgs::access

◆ getYawOfPerceivedObject()

double etsi_its_cpm_ts_msgs::access::getYawOfPerceivedObject ( const PerceivedObject & object)
inline

Get the yaw of the PerceivedObject.

Parameters
objectPerceivedObject to get the yaw from
Returns
double yaw of the PerceivedObject in radians from -pi to pi

Definition at line 410 of file cpm_ts_getters.h.

413 {
414 if (!object.acceleration_is_present) throw std::invalid_argument("No acceleration present in PerceivedObject");
415 if (object.acceleration.choice != Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
416 throw std::invalid_argument("Acceleration is not Cartesian");

◆ getYawRateOfPerceivedObject()

int16_t etsi_its_cpm_ts_msgs::access::getYawRateOfPerceivedObject ( const PerceivedObject & object)
inline

Get the yaw rate of the PerceivedObject.

Parameters
objectPerceivedObject to get the yaw rate from
Returns
int16_t yaw rate of the PerceivedObject in deg/s
Exceptions
std::invalid_argumentIf the yaw rate is not present in the object.

Definition at line 438 of file cpm_ts_getters.h.

438 {
439 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
440 return object.object_dimension_x.value.value;
441}

◆ getYDimensionOfPerceivedObject()

uint16_t etsi_its_cpm_ts_msgs::access::getYDimensionOfPerceivedObject ( const PerceivedObject & object)
inline

Retrieves the y-dimension of a perceived object.

This function extracts the y-dimension from a given PerceivedObject. If the y-dimension is not present in the object, it throws an std::invalid_argument exception.

Parameters
objectThe PerceivedObject from which to retrieve the y-dimension.
Returns
uint16_t y-dimension of the perceived object in in decimeters.
Exceptions
std::invalid_argumentif the y-dimension is not present in the PerceivedObject.

Definition at line 550 of file cpm_ts_getters.h.

583 {
584
586
595inline uint32_t getStationID(const CollectivePerceptionMessage &cpm) { return getStationID(cpm.header); }
596
603inline TimestampIts getReferenceTime(const CollectivePerceptionMessage &cpm) {
604 return cpm.payload.management_container.reference_time;
605}
606
613inline uint64_t getReferenceTimeValue(const CollectivePerceptionMessage &cpm) { return getReferenceTime(cpm).value; }
614
621inline double getLatitude(const CollectivePerceptionMessage &cpm) {
622 return getLatitude(cpm.payload.management_container.reference_position.latitude);
623}
624
631inline double getLongitude(const CollectivePerceptionMessage &cpm) {
632 return getLongitude(cpm.payload.management_container.reference_position.longitude);
633}
634
641inline double getAltitude(const CollectivePerceptionMessage &cpm) {
642 return getAltitude(cpm.payload.management_container.reference_position.altitude);
643}
644
656inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm, int &zone, bool &northp) {
657 return getUTMPosition(cpm.payload.management_container.reference_position, zone, northp);
658}
659
669inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm) {
670 int zone;
671 bool northp;
672 return getUTMPosition(cpm, zone, northp);
673}
674
684inline std::vector<uint8_t> getCpmContainerIds(const CollectivePerceptionMessage &cpm) {
685 std::vector<uint8_t> container_ids;
686 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
687 container_ids.push_back(cpm.payload.cpm_containers.value.array[i].container_id.value);
688 }
689 return container_ids;
690}
691
700inline WrappedCpmContainer getCpmContainer(const CollectivePerceptionMessage &cpm, const uint8_t container_id) {
701 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
702 if (cpm.payload.cpm_containers.value.array[i].container_id.value == container_id) {
703 return cpm.payload.cpm_containers.value.array[i];
704 }
705 }
706 throw std::invalid_argument("No Container with ID " + std::to_string(container_id) + " found in CPM");
707}
708
717inline WrappedCpmContainer getPerceivedObjectContainer(const CollectivePerceptionMessage &cpm) {
718 return getCpmContainer(cpm, WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER);
719}
720
728inline uint8_t getNumberOfPerceivedObjects(const WrappedCpmContainer &container) {
729 if (container.container_id.value != WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER) {
730 throw std::invalid_argument("Container is not a PerceivedObjectContainer");
731 }
732 uint8_t number = container.container_data_perceived_object_container.number_of_perceived_objects.value;
733 return number;
734}
735
742inline uint8_t getNumberOfPerceivedObjects(const CollectivePerceptionMessage &cpm) {
744}
745
749
758inline PerceivedObject getPerceivedObject(const WrappedCpmContainer &container, const uint8_t i) {
759 if (i >= getNumberOfPerceivedObjects(container)) {
760 throw std::invalid_argument("Index out of range");
761 }
762 return container.container_data_perceived_object_container.perceived_objects.array[i];
763}
764
773inline uint16_t getIdOfPerceivedObject(const PerceivedObject &object) { return object.object_id.value; }
774
781inline int32_t getCartesianCoordinate(const CartesianCoordinateWithConfidence &coordinate) {
782 return coordinate.value.value;
783}
784
791inline uint16_t getCartesianCoordinateConfidence(const CartesianCoordinateWithConfidence &coordinate) {
792 return coordinate.confidence.value;
793}
794
801inline gm::Point getPositionOfPerceivedObject(const PerceivedObject &object) {
802 gm::Point point;
803 point.x = double(getCartesianCoordinate(object.position.x_coordinate)) / 100.0;
804 point.y = double(getCartesianCoordinate(object.position.y_coordinate)) / 100.0;
805 if (object.position.z_coordinate_is_present) {
806 point.z = double(getCartesianCoordinate(object.position.z_coordinate)) / 100.0;
807 }
808 return point;
809}
810
817inline uint16_t getCartesianAngle(const CartesianAngle &angle) { return angle.value.value; }
818
825inline uint8_t getCartesianAngleConfidence(const CartesianAngle &angle) { return angle.confidence.value; }
826
837inline gm::Quaternion getOrientationOfPerceivedObject(const PerceivedObject &object) {
838 if (!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
839 tf2::Quaternion q;
840 double roll{0}, pitch{0}, yaw{0};
841
842 if (object.angles.x_angle_is_present) {
843 roll = (((double(getCartesianAngle(object.angles.x_angle)) / 10.0) - 180.0) / 180.0) *
844 M_PI; // TODO: check if 0-360 -> -180-180 is correct
845 }
846 if (object.angles.y_angle_is_present) {
847 pitch = (((double(getCartesianAngle(object.angles.y_angle)) / 10.0) - 180.0) / 180.0) *
848 M_PI; // TODO: check if 0-360 -> -180-180 is correct
849 }
850 yaw = (((double(getCartesianAngle(object.angles.z_angle)) / 10.0) - 180.0) / 180.0) *
851 M_PI; // TODO: check if 0-360 -> -180-180 is correct
852 q.setRPY(roll, pitch, yaw);
853
854 return tf2::toMsg(q);
855}
856
863inline double getYawOfPerceivedObject(const PerceivedObject &object) {
864 gm::Quaternion orientation = getOrientationOfPerceivedObject(object);
865 tf2::Quaternion q(orientation.x, orientation.y, orientation.z, orientation.w);
866 double roll, pitch, yaw;
867 tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);
868 return yaw;
869}
870
877inline gm::Pose getPoseOfPerceivedObject(const PerceivedObject &object) {
878 gm::Pose pose;
879 pose.position = getPositionOfPerceivedObject(object);
880 pose.orientation = getOrientationOfPerceivedObject(object);
881 return pose;
882}
883
891inline int16_t getYawRateOfPerceivedObject(const PerceivedObject &object) {
892 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
893 return object.z_angular_velocity.value.value;
894}
895
902inline double getVelocityComponent(const VelocityComponent &velocity) { return double(velocity.value.value) / 100.0; }
903
910inline double getVelocityComponentConfidence(const VelocityComponent &velocity) {
911 return double(velocity.confidence.value) / 100.0;
912}
913
921inline gm::Vector3 getCartesianVelocityOfPerceivedObject(const PerceivedObject &object) {
922 if (!object.velocity_is_present) throw std::invalid_argument("No velocity present in PerceivedObject");
923 if (object.velocity.choice != Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
924 throw std::invalid_argument("Velocity is not Cartesian");
925 }
926 gm::Vector3 velocity;
927 velocity.x = getVelocityComponent(object.velocity.cartesian_velocity.x_velocity);
928 velocity.y = getVelocityComponent(object.velocity.cartesian_velocity.y_velocity);
929 if (object.velocity.cartesian_velocity.z_velocity_is_present) {
930 velocity.z = getVelocityComponent(object.velocity.cartesian_velocity.z_velocity);
931 }
932 return velocity;
933}
934
941inline double getAccelerationComponent(const AccelerationComponent &acceleration) {
942 return double(acceleration.value.value) / 10.0;
943}
944
951inline double getAccelerationComponentConfidence(const AccelerationComponent &acceleration) {
952 return double(acceleration.confidence.value) / 10.0;
953}
954
962inline gm::Vector3 getCartesianAccelerationOfPerceivedObject(const PerceivedObject &object) {
963 if (!object.acceleration_is_present) throw std::invalid_argument("No acceleration present in PerceivedObject");
964 if (object.acceleration.choice != Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
965 throw std::invalid_argument("Acceleration is not Cartesian");
966 }
967 gm::Vector3 acceleration;
968 acceleration.x = getAccelerationComponent(object.acceleration.cartesian_acceleration.x_acceleration);
969 acceleration.y = getAccelerationComponent(object.acceleration.cartesian_acceleration.y_acceleration);
970 if (object.acceleration.cartesian_acceleration.z_acceleration_is_present) {
971 acceleration.z = getAccelerationComponent(object.acceleration.cartesian_acceleration.z_acceleration);
972 }
973 return acceleration;
974}
975
987inline uint16_t getXDimensionOfPerceivedObject(const PerceivedObject &object) {
988 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
989 return object.object_dimension_x.value.value;
990}
991
1003inline uint16_t getYDimensionOfPerceivedObject(const PerceivedObject &object) {
1004 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
1005 return object.object_dimension_y.value.value;
1006}
1007
1019inline uint16_t getZDimensionOfPerceivedObject(const PerceivedObject &object) {
1020 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
1021 return object.object_dimension_z.value.value;
1022}
1023
1033inline gm::Vector3 getDimensionsOfPerceivedObject(const PerceivedObject &object) {
1034 gm::Vector3 dimensions;
1035 dimensions.x = double(getXDimensionOfPerceivedObject(object)) / 10.0;
1036 dimensions.y = double(getYDimensionOfPerceivedObject(object)) / 10.0;
1037 dimensions.z = double(getZDimensionOfPerceivedObject(object)) / 10.0;
1038 return dimensions;
1039}
1040
1051inline gm::PointStamped getUTMPositionOfPerceivedObject(const CollectivePerceptionMessage &cpm,
1052 const PerceivedObject &object) {
1053 gm::PointStamped utm_position;
1054 gm::PointStamped reference_position = getUTMPosition(cpm);
1055 gm::Point relative_position = getPositionOfPerceivedObject(object);
1056
1057 utm_position.header.frame_id = reference_position.header.frame_id;
1058 utm_position.point.x = reference_position.point.x + relative_position.x;
1059 utm_position.point.y = reference_position.point.y + relative_position.y;
1060 utm_position.point.z = reference_position.point.z + relative_position.z;
1061
1062 return utm_position;
1063}
1064
1065} // namespace etsi_its_cpm_ts_msgs::access

◆ getZDimensionOfPerceivedObject()

uint16_t etsi_its_cpm_ts_msgs::access::getZDimensionOfPerceivedObject ( const PerceivedObject & object)
inline

Retrieves the z-dimension of a perceived object.

This function extracts the z-dimension from a given PerceivedObject. If the z-dimension is not present in the object, it throws an std::invalid_argument exception.

Parameters
objectThe PerceivedObject from which to retrieve the z-dimension.
Returns
uint16_t z-dimension of the perceived object in decimeters.
Exceptions
std::invalid_argumentIf the z-dimension is not present in the object.

Definition at line 566 of file cpm_ts_getters.h.

599 {
600
602
611inline uint32_t getStationID(const CollectivePerceptionMessage &cpm) { return getStationID(cpm.header); }
612
619inline TimestampIts getReferenceTime(const CollectivePerceptionMessage &cpm) {
620 return cpm.payload.management_container.reference_time;
621}
622
629inline uint64_t getReferenceTimeValue(const CollectivePerceptionMessage &cpm) { return getReferenceTime(cpm).value; }
630
637inline double getLatitude(const CollectivePerceptionMessage &cpm) {
638 return getLatitude(cpm.payload.management_container.reference_position.latitude);
639}
640
647inline double getLongitude(const CollectivePerceptionMessage &cpm) {
648 return getLongitude(cpm.payload.management_container.reference_position.longitude);
649}
650
657inline double getAltitude(const CollectivePerceptionMessage &cpm) {
658 return getAltitude(cpm.payload.management_container.reference_position.altitude);
659}
660
672inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm, int &zone, bool &northp) {
673 return getUTMPosition(cpm.payload.management_container.reference_position, zone, northp);
674}
675
685inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm) {
686 int zone;
687 bool northp;
688 return getUTMPosition(cpm, zone, northp);
689}
690
700inline std::vector<uint8_t> getCpmContainerIds(const CollectivePerceptionMessage &cpm) {
701 std::vector<uint8_t> container_ids;
702 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
703 container_ids.push_back(cpm.payload.cpm_containers.value.array[i].container_id.value);
704 }
705 return container_ids;
706}
707
716inline WrappedCpmContainer getCpmContainer(const CollectivePerceptionMessage &cpm, const uint8_t container_id) {
717 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
718 if (cpm.payload.cpm_containers.value.array[i].container_id.value == container_id) {
719 return cpm.payload.cpm_containers.value.array[i];
720 }
721 }
722 throw std::invalid_argument("No Container with ID " + std::to_string(container_id) + " found in CPM");
723}
724
733inline WrappedCpmContainer getPerceivedObjectContainer(const CollectivePerceptionMessage &cpm) {
734 return getCpmContainer(cpm, WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER);
735}
736
744inline uint8_t getNumberOfPerceivedObjects(const WrappedCpmContainer &container) {
745 if (container.container_id.value != WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER) {
746 throw std::invalid_argument("Container is not a PerceivedObjectContainer");
747 }
748 uint8_t number = container.container_data_perceived_object_container.number_of_perceived_objects.value;
749 return number;
750}
751
758inline uint8_t getNumberOfPerceivedObjects(const CollectivePerceptionMessage &cpm) {
760}
761
765
774inline PerceivedObject getPerceivedObject(const WrappedCpmContainer &container, const uint8_t i) {
775 if (i >= getNumberOfPerceivedObjects(container)) {
776 throw std::invalid_argument("Index out of range");
777 }
778 return container.container_data_perceived_object_container.perceived_objects.array[i];
779}
780
789inline uint16_t getIdOfPerceivedObject(const PerceivedObject &object) { return object.object_id.value; }
790
797inline int32_t getCartesianCoordinate(const CartesianCoordinateWithConfidence &coordinate) {
798 return coordinate.value.value;
799}
800
807inline uint16_t getCartesianCoordinateConfidence(const CartesianCoordinateWithConfidence &coordinate) {
808 return coordinate.confidence.value;
809}
810
817inline gm::Point getPositionOfPerceivedObject(const PerceivedObject &object) {
818 gm::Point point;
819 point.x = double(getCartesianCoordinate(object.position.x_coordinate)) / 100.0;
820 point.y = double(getCartesianCoordinate(object.position.y_coordinate)) / 100.0;
821 if (object.position.z_coordinate_is_present) {
822 point.z = double(getCartesianCoordinate(object.position.z_coordinate)) / 100.0;
823 }
824 return point;
825}
826
833inline uint16_t getCartesianAngle(const CartesianAngle &angle) { return angle.value.value; }
834
841inline uint8_t getCartesianAngleConfidence(const CartesianAngle &angle) { return angle.confidence.value; }
842
853inline gm::Quaternion getOrientationOfPerceivedObject(const PerceivedObject &object) {
854 if (!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
855 tf2::Quaternion q;
856 double roll{0}, pitch{0}, yaw{0};
857
858 if (object.angles.x_angle_is_present) {
859 roll = (((double(getCartesianAngle(object.angles.x_angle)) / 10.0) - 180.0) / 180.0) *
860 M_PI; // TODO: check if 0-360 -> -180-180 is correct
861 }
862 if (object.angles.y_angle_is_present) {
863 pitch = (((double(getCartesianAngle(object.angles.y_angle)) / 10.0) - 180.0) / 180.0) *
864 M_PI; // TODO: check if 0-360 -> -180-180 is correct
865 }
866 yaw = (((double(getCartesianAngle(object.angles.z_angle)) / 10.0) - 180.0) / 180.0) *
867 M_PI; // TODO: check if 0-360 -> -180-180 is correct
868 q.setRPY(roll, pitch, yaw);
869
870 return tf2::toMsg(q);
871}
872
879inline double getYawOfPerceivedObject(const PerceivedObject &object) {
880 gm::Quaternion orientation = getOrientationOfPerceivedObject(object);
881 tf2::Quaternion q(orientation.x, orientation.y, orientation.z, orientation.w);
882 double roll, pitch, yaw;
883 tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);
884 return yaw;
885}
886
893inline gm::Pose getPoseOfPerceivedObject(const PerceivedObject &object) {
894 gm::Pose pose;
895 pose.position = getPositionOfPerceivedObject(object);
896 pose.orientation = getOrientationOfPerceivedObject(object);
897 return pose;
898}
899
907inline int16_t getYawRateOfPerceivedObject(const PerceivedObject &object) {
908 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
909 return object.z_angular_velocity.value.value;
910}
911
918inline double getVelocityComponent(const VelocityComponent &velocity) { return double(velocity.value.value) / 100.0; }
919
926inline double getVelocityComponentConfidence(const VelocityComponent &velocity) {
927 return double(velocity.confidence.value) / 100.0;
928}
929
937inline gm::Vector3 getCartesianVelocityOfPerceivedObject(const PerceivedObject &object) {
938 if (!object.velocity_is_present) throw std::invalid_argument("No velocity present in PerceivedObject");
939 if (object.velocity.choice != Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
940 throw std::invalid_argument("Velocity is not Cartesian");
941 }
942 gm::Vector3 velocity;
943 velocity.x = getVelocityComponent(object.velocity.cartesian_velocity.x_velocity);
944 velocity.y = getVelocityComponent(object.velocity.cartesian_velocity.y_velocity);
945 if (object.velocity.cartesian_velocity.z_velocity_is_present) {
946 velocity.z = getVelocityComponent(object.velocity.cartesian_velocity.z_velocity);
947 }
948 return velocity;
949}
950
957inline double getAccelerationComponent(const AccelerationComponent &acceleration) {
958 return double(acceleration.value.value) / 10.0;
959}
960
967inline double getAccelerationComponentConfidence(const AccelerationComponent &acceleration) {
968 return double(acceleration.confidence.value) / 10.0;
969}
970
978inline gm::Vector3 getCartesianAccelerationOfPerceivedObject(const PerceivedObject &object) {
979 if (!object.acceleration_is_present) throw std::invalid_argument("No acceleration present in PerceivedObject");
980 if (object.acceleration.choice != Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
981 throw std::invalid_argument("Acceleration is not Cartesian");
982 }
983 gm::Vector3 acceleration;
984 acceleration.x = getAccelerationComponent(object.acceleration.cartesian_acceleration.x_acceleration);
985 acceleration.y = getAccelerationComponent(object.acceleration.cartesian_acceleration.y_acceleration);
986 if (object.acceleration.cartesian_acceleration.z_acceleration_is_present) {
987 acceleration.z = getAccelerationComponent(object.acceleration.cartesian_acceleration.z_acceleration);
988 }
989 return acceleration;
990}
991
1003inline uint16_t getXDimensionOfPerceivedObject(const PerceivedObject &object) {
1004 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
1005 return object.object_dimension_x.value.value;
1006}
1007
1019inline uint16_t getYDimensionOfPerceivedObject(const PerceivedObject &object) {
1020 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
1021 return object.object_dimension_y.value.value;
1022}
1023
1035inline uint16_t getZDimensionOfPerceivedObject(const PerceivedObject &object) {
1036 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
1037 return object.object_dimension_z.value.value;
1038}
1039
1049inline gm::Vector3 getDimensionsOfPerceivedObject(const PerceivedObject &object) {
1050 gm::Vector3 dimensions;
1051 dimensions.x = double(getXDimensionOfPerceivedObject(object)) / 10.0;
1052 dimensions.y = double(getYDimensionOfPerceivedObject(object)) / 10.0;
1053 dimensions.z = double(getZDimensionOfPerceivedObject(object)) / 10.0;
1054 return dimensions;
1055}
1056
1067inline gm::PointStamped getUTMPositionOfPerceivedObject(const CollectivePerceptionMessage &cpm,
1068 const PerceivedObject &object) {
1069 gm::PointStamped utm_position;
1070 gm::PointStamped reference_position = getUTMPosition(cpm);
1071 gm::Point relative_position = getPositionOfPerceivedObject(object);
1072
1073 utm_position.header.frame_id = reference_position.header.frame_id;
1074 utm_position.point.x = reference_position.point.x + relative_position.x;
1075 utm_position.point.y = reference_position.point.y + relative_position.y;
1076 utm_position.point.z = reference_position.point.z + relative_position.z;
1077
1078 return utm_position;
1079}
1080
1081} // namespace etsi_its_cpm_ts_msgs::access