Get the acceleration component of the PerceivedObject.
892 {
893
895
905
912inline TimestampIts getReferenceTime(const CollectivePerceptionMessage &cpm) {
913 return cpm.payload.management_container.reference_time;
914}
915
922inline uint64_t getReferenceTimeValue(const CollectivePerceptionMessage &cpm) { return getReferenceTime(cpm).value; }
923
930inline double getLatitude(
const CollectivePerceptionMessage &cpm) {
931 return getLatitude(cpm.payload.management_container.reference_position.latitude);
932}
933
940inline double getLongitude(
const CollectivePerceptionMessage &cpm) {
941 return getLongitude(cpm.payload.management_container.reference_position.longitude);
942}
943
950inline double getAltitude(
const CollectivePerceptionMessage &cpm) {
951 return getAltitude(cpm.payload.management_container.reference_position.altitude);
952}
953
965inline gm::PointStamped
getUTMPosition(
const CollectivePerceptionMessage &cpm,
int &zone,
bool &northp) {
966 return getUTMPosition(cpm.payload.management_container.reference_position, zone, northp);
967}
968
978inline gm::PointStamped
getUTMPosition(
const CollectivePerceptionMessage &cpm) {
979 int zone;
980 bool northp;
982}
983
993inline std::vector<uint8_t>
getCpmContainerIds(
const CollectivePerceptionMessage &cpm) {
994 std::vector<uint8_t> container_ids;
995 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
996 container_ids.push_back(cpm.payload.cpm_containers.value.array[i].container_id.value);
997 }
998 return container_ids;
999}
1000
1009inline WrappedCpmContainer
getCpmContainer(
const CollectivePerceptionMessage &cpm,
const uint8_t container_id) {
1010 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
1011 if (cpm.payload.cpm_containers.value.array[i].container_id.value == container_id) {
1012 return cpm.payload.cpm_containers.value.array[i];
1013 }
1014 }
1015 throw std::invalid_argument("No Container with ID " + std::to_string(container_id) + " found in CPM");
1016}
1017
1027 return getCpmContainer(cpm, WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER);
1028}
1029
1038 if (container.container_id.value != WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER) {
1039 throw std::invalid_argument("Container is not a PerceivedObjectContainer");
1040 }
1041 uint8_t number = container.container_data_perceived_object_container.number_of_perceived_objects.value;
1042 return number;
1043}
1044
1053}
1054
1058
1067inline PerceivedObject
getPerceivedObject(
const WrappedCpmContainer &container,
const uint8_t i) {
1069 throw std::invalid_argument("Index out of range");
1070 }
1071 return container.container_data_perceived_object_container.perceived_objects.array[i];
1072}
1073
1083 if (!object.object_id_is_present) {
1084 throw std::invalid_argument("No object_id present in PerceivedObject");
1085 }
1086 return object.object_id.value;
1087}
1088
1096 return coordinate.value.value;
1097}
1098
1106 return coordinate.confidence.value;
1107}
1108
1116 gm::Point point;
1119 if (object.position.z_coordinate_is_present) {
1121 }
1122 return point;
1123}
1124
1135 double z_confidence = object.position.z_coordinate_is_present
1137 : std::numeric_limits<double>::infinity();
1138 return std::make_tuple(x_confidence, y_confidence, z_confidence);
1139}
1140
1147inline uint16_t
getCartesianAngle(
const CartesianAngle &angle) {
return angle.value.value; }
1148
1156
1168 if (!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
1169 tf2::Quaternion q;
1170 double roll{0}, pitch{0}, yaw{0};
1171
1172 if (object.angles.x_angle_is_present) {
1174 M_PI;
1175 }
1176 if (object.angles.y_angle_is_present) {
1177 pitch = (((double(
getCartesianAngle(
object.angles.y_angle)) / 10.0) ) / 180.0) *
1178 M_PI;
1179 }
1181 M_PI;
1182
1183 q.setRPY(roll, pitch, yaw);
1184
1185 return tf2::toMsg(q);
1186}
1187
1196 tf2::Quaternion q(orientation.x, orientation.y, orientation.z, orientation.w);
1197 double roll, pitch, yaw;
1198 tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);
1199 return yaw;
1200}
1201
1210 if(!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
1211 double yaw_confidence = object.angles.z_angle.confidence.value / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
1212 yaw_confidence *= M_PI / 180.0;
1213 return yaw_confidence;
1214}
1215
1223 gm::Pose pose;
1226 return pose;
1227}
1228
1237 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
1238 return object.z_angular_velocity.value.value * M_PI / 180.0;
1239}
1240
1251 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
1252 auto val = object.z_angular_velocity.confidence.value;
1253 static const std::map<uint8_t, double> confidence_map = {
1254 {AngularSpeedConfidence::UNAVAILABLE, 0.0},
1255 {AngularSpeedConfidence::DEG_SEC_01, 1.0},
1256 {AngularSpeedConfidence::DEG_SEC_02, 2.0},
1257 {AngularSpeedConfidence::DEG_SEC_05, 5.0},
1258 {AngularSpeedConfidence::DEG_SEC_10, 10.0},
1259 {AngularSpeedConfidence::DEG_SEC_20, 20.0},
1260 {AngularSpeedConfidence::DEG_SEC_50, 50.0},
1261 {AngularSpeedConfidence::OUT_OF_RANGE, std::numeric_limits<double>::infinity()},
1262 };
1263 return confidence_map.at(val) * M_PI / 180.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
1264}
1265
1272inline double getVelocityComponent(
const VelocityComponent &velocity) {
return double(velocity.value.value) / 100.0; }
1273
1281 return double(velocity.confidence.value) / 100.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
1282}
1283
1292 if (!object.velocity_is_present) {
1293 throw std::invalid_argument("No velocity present in PerceivedObject");
1294 }
1295 gm::Vector3 velocity;
1296 if (object.velocity.choice == Velocity3dWithConfidence::CHOICE_POLAR_VELOCITY) {
1297 double speed =
getSpeed(
object.velocity.polar_velocity.velocity_magnitude);
1298 double angle =
getCartesianAngle(
object.velocity.polar_velocity.velocity_direction) * M_PI / 180.0 / 10.0;
1299 velocity.x = speed * cos(angle);
1300 velocity.y = speed * sin(angle);
1301 if (object.velocity.polar_velocity.z_velocity_is_present) {
1303 }
1304 } else if (object.velocity.choice == Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
1307 if (object.velocity.cartesian_velocity.z_velocity_is_present) {
1309 }
1310 } else {
1311 throw std::invalid_argument("Velocity is neither Polar nor Cartesian");
1312 }
1313 return velocity;
1314}
1315
1325 if (!object.velocity_is_present) {
1326 throw std::invalid_argument("No velocity present in PerceivedObject");
1327 }
1328 if (object.velocity.choice == Velocity3dWithConfidence::CHOICE_POLAR_VELOCITY) {
1329 double speed_confidence =
getSpeedConfidence(
object.velocity.polar_velocity.velocity_magnitude) / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
1330 double angle_confidence =
getCartesianAngleConfidence(
object.velocity.polar_velocity.velocity_direction) * M_PI / 180.0 / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
1331 double speed =
getSpeed(
object.velocity.polar_velocity.velocity_magnitude);
1332 double angle =
getCartesianAngle(
object.velocity.polar_velocity.velocity_direction) * M_PI / 180.0 / 10.0;
1333 double lateral_confidence = speed * angle_confidence;
1334 double x_confidence = speed_confidence * cos(angle) * cos(angle)
1335 + lateral_confidence * sin(angle) * sin(angle);
1336 double y_confidence = speed_confidence * sin(angle) * sin(angle)
1337 + lateral_confidence * cos(angle) * cos(angle);
1338
1339 double z_confidence = object.velocity.polar_velocity.z_velocity_is_present
1341 : std::numeric_limits<double>::infinity();
1342 return std::make_tuple(x_confidence, y_confidence, z_confidence);
1343 } else if (object.velocity.choice == Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
1346 double z_confidence = object.velocity.cartesian_velocity.z_velocity_is_present
1348 : std::numeric_limits<double>::infinity();
1349 return std::make_tuple(x_confidence, y_confidence, z_confidence);
1350 } else {
1351 throw std::invalid_argument("Velocity is neither Polar nor Cartesian");
1352 }
1353
1354}
1355
1363 return double(acceleration.value.value) / 10.0;
1364}
1365
1373 return double(acceleration.confidence.value) / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
1374}
1375
1384 if (!object.acceleration_is_present) {
1385 throw std::invalid_argument("No acceleration present in PerceivedObject");
1386 }
1387 gm::Vector3 acceleration;
1388
1389 if (object.acceleration.choice == Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
1392 if (object.acceleration.cartesian_acceleration.z_acceleration_is_present) {
1394 }
1395 } else if (object.acceleration.choice == Acceleration3dWithConfidence::CHOICE_POLAR_ACCELERATION) {
1397 double angle =
getCartesianAngle(
object.acceleration.polar_acceleration.acceleration_direction) * M_PI / 180.0 / 10.0;
1398 acceleration.x = magnitude * cos(angle);
1399 acceleration.y = magnitude * sin(angle);
1400 if (object.acceleration.polar_acceleration.z_acceleration_is_present) {
1402 }
1403 } else {
1404 throw std::invalid_argument("Acceleration is neither Cartesian nor Polar");
1405 }
1406
1407 return acceleration;
1408}
1409
1419 if (!object.acceleration_is_present) throw std::invalid_argument("No acceleration present in PerceivedObject");
1420
1421 if (object.acceleration.choice == Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
1424 double z_confidence = object.acceleration.cartesian_acceleration.z_acceleration_is_present
1426 : std::numeric_limits<double>::infinity();
1427 return std::make_tuple(x_confidence, y_confidence, z_confidence);
1428 } else if (object.acceleration.choice == Acceleration3dWithConfidence::CHOICE_POLAR_ACCELERATION) {
1430 double angle_confidence =
getCartesianAngleConfidence(
object.acceleration.polar_acceleration.acceleration_direction) * M_PI / 180.0 / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
1432 double angle =
getCartesianAngle(
object.acceleration.polar_acceleration.acceleration_direction) * M_PI / 180.0 / 10.0;
1433 double lateral_confidence = magnitude * angle_confidence;
1434 double x_confidence = magnitude_confidence * cos(angle) * cos(angle)
1435 + lateral_confidence * sin(angle) * sin(angle);
1436 double y_confidence = magnitude_confidence * sin(angle) * sin(angle)
1437 + lateral_confidence * cos(angle) * cos(angle);
1438
1439 double z_confidence = object.acceleration.polar_acceleration.z_acceleration_is_present
1441 : std::numeric_limits<double>::infinity();
1442 return std::make_tuple(x_confidence, y_confidence, z_confidence);
1443 } else {
1444 throw std::invalid_argument("Acceleration is neither Cartesian nor Polar");
1445 }
1446}
1447
1460 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
1461 return object.object_dimension_x.value.value;
1462}
1463
1472 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
1473 return object.object_dimension_x.confidence.value;
1474}
1475
1488 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
1489 return object.object_dimension_y.value.value;
1490}
1491
1500 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
1501 return object.object_dimension_y.confidence.value;
1502}
1503
1516 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
1517 return object.object_dimension_z.value.value;
1518}
1519
1528 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
1529 return object.object_dimension_z.confidence.value;
1530}
1531
1542 gm::Vector3 dimensions;
1546 return dimensions;
1547}
1548
1559 return {conf_x, conf_y, conf_z};
1560}
1561
1573 const PerceivedObject &object) {
1574 gm::PointStamped utm_position;
1577
1578 utm_position.header.frame_id = reference_position.header.frame_id;
1579 utm_position.point.x = reference_position.point.x + relative_position.x;
1580 utm_position.point.y = reference_position.point.y + relative_position.y;
1581 utm_position.point.z = reference_position.point.z + relative_position.z;
1582
1583 return utm_position;
1584}
1585
1597}
1598
1605inline uint8_t
getSensorID(
const SensorInformation &sensor_information) {
1606 return sensor_information.sensor_id.value;
1607}
1608
1615inline uint8_t
getSensorType(
const SensorInformation &sensor_information) {
1616 return sensor_information.sensor_type.value;
1617}
1618
1619}
Getter functions for the ETSI ITS Common Data Dictionary (CDD) v2.1.1.
double getYawRateConfidenceOfPerceivedObject(const PerceivedObject &object)
Get the Yaw Rate Confidence Of Perceived Object.
double getSpeed(const Speed &speed)
Get the vehicle speed.
double getAccelerationMagnitude(const AccelerationMagnitude &acceleration_magnitude)
Get the AccelerationMagnitude value.
std::tuple< double, double, double > getDimensionsConfidenceOfPerceivedObject(const PerceivedObject &object)
Get the Dimensions Confidence Of Perceived Object.
std::tuple< double, double, double > getCartesianAccelerationConfidenceOfPerceivedObject(const PerceivedObject &object)
Get the Cartesian Acceleration Confidence Of Perceived Object.
double getYawConfidenceOfPerceivedObject(const PerceivedObject &object)
Get the Yaw Confidence Of Perceived Object object.
int32_t getCartesianCoordinate(const CartesianCoordinateWithConfidence &coordinate)
Retrieves the Cartesian coordinate value from a CartesianCoordinateWithConfidence object.
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)
gm::Point getPositionOfPerceivedObject(const PerceivedObject &object)
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.
uint8_t getSensorType(const SensorInformation &sensor_information)
Get the sensorType of a SensorInformation object.
double getYawRateOfPerceivedObject(const PerceivedObject &object)
Get the yaw rate of the PerceivedObject.
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.
double getSpeedConfidence(const Speed &speed)
Get the Speed Confidence.
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.
uint8_t getYDimensionConfidenceOfPerceivedObject(const PerceivedObject &object)
Gets the confidence of the y-dimension of a perceived object.
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.
std::tuple< double, double, double > getCartesianVelocityConfidenceOfPerceivedObject(const PerceivedObject &object)
Get the Cartesian Velocity Confidence Of Perceived Object object.
uint8_t getZDimensionConfidenceOfPerceivedObject(const PerceivedObject &object)
Gets the confidence of the z-dimension of a perceived object.
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.
std::array< double, 4 > getWGSPosConfidenceEllipse(const PosConfidenceEllipse &position_confidence_ellipse)
Get the covariance matrix of the position confidence ellipse.
uint8_t getXDimensionConfidenceOfPerceivedObject(const PerceivedObject &object)
Gets the confidence of the x-dimension of a perceived object.
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.
double getAccelerationMagnitudeConfidence(const AccelerationMagnitude &acceleration_magnitude)
Get the AccelerationMagnitude Confidence.
uint8_t getSensorID(const SensorInformation &sensor_information)
Get the sensorId of a SensorInformation 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.
const std::array< double, 4 > getWGSRefPosConfidence(const CollectivePerceptionMessage &cpm)
Get the confidence ellipse of the reference position as Covariance matrix.
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.
std::tuple< double, double, double > getPositionConfidenceOfPerceivedObject(const PerceivedObject &object)
Get the Position Confidences Of Perceived Object.
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.