etsi_its_messages v3.3.0
 
Loading...
Searching...
No Matches
cpm_ts_getters.h
Go to the documentation of this file.
1/*
2=============================================================================
3MIT License
4
5Copyright (c) 2023-2025 Institute for Automotive Engineering (ika), RWTH Aachen University
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24=============================================================================
25*/
26
31
32#pragma once
33
34#include <tuple>
35
36namespace etsi_its_cpm_ts_msgs::access {
37
39
48inline uint32_t getStationID(const CollectivePerceptionMessage &cpm) { return getStationID(cpm.header); }
49
56inline TimestampIts getReferenceTime(const CollectivePerceptionMessage &cpm) {
57 return cpm.payload.management_container.reference_time;
58}
59
66inline uint64_t getReferenceTimeValue(const CollectivePerceptionMessage &cpm) { return getReferenceTime(cpm).value; }
67
71 * @param cpm CPM to get the Latitude value from
72 * @return Latitude value in degree as decimal number
73 */
74inline double getLatitude(const CollectivePerceptionMessage &cpm) {
75 return getLatitude(cpm.payload.management_container.reference_position.latitude);
76}
77
84inline double getLongitude(const CollectivePerceptionMessage &cpm) {
85 return getLongitude(cpm.payload.management_container.reference_position.longitude);
86}
87
92 * @return Altitude value in (above the reference ellipsoid surface) in meter as decimal number
93 */
94inline double getAltitude(const CollectivePerceptionMessage &cpm) {
95 return getAltitude(cpm.payload.management_container.reference_position.altitude);
96}
97
104 * @param[in] cpm CPM to get the UTM Position from
105 * @param[out] zone the UTM zone (zero means UPS)
106 * @param[out] northp hemisphere (true means north, false means south)
107 * @return geometry_msgs::PointStamped of the given position with the UTM zone and hemisphere as frame_id
108 */
109inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm, int &zone, bool &northp) {
110 return getUTMPosition(cpm.payload.management_container.reference_position, zone, northp);
111}
112
114 * @brief Get the UTM Position defined within the ManagementContainer of the CPM
115 *
116 * The position is transformed into UTM by using GeographicLib::UTMUPS
117 * The altitude value is directly used as z-Coordinate
118 *
119 * @param cpm CPM from which to extract the UTM position.
120 * @return geometry_msgs::PointStamped of the given position with the UTM zone and hemisphere as frame_id
121 */
122inline gm::PointStamped getUTMPosition(const CollectivePerceptionMessage &cpm) {
123 int zone;
124 bool northp;
125 return getUTMPosition(cpm, zone, northp);
126}
127
131 * This function iterates over the cpm_containers array in the given CPM
132 * and extracts the container IDs into a vector of uint8_t.
133 *
134 * @param cpm The CPM from which to retrieve the container IDs.
135 * @return A vector containing the container IDs.
136 */
137inline std::vector<uint8_t> getCpmContainerIds(const CollectivePerceptionMessage &cpm) {
138 std::vector<uint8_t> container_ids;
139 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
140 container_ids.push_back(cpm.payload.cpm_containers.value.array[i].container_id.value);
141 }
142 return container_ids;
143}
144
149
153inline WrappedCpmContainer getCpmContainer(const CollectivePerceptionMessage &cpm, const uint8_t container_id) {
154 for (int i = 0; i < cpm.payload.cpm_containers.value.array.size(); i++) {
155 if (cpm.payload.cpm_containers.value.array[i].container_id.value == container_id) {
156 return cpm.payload.cpm_containers.value.array[i];
157 }
158 }
159 throw std::invalid_argument("No Container with ID " + std::to_string(container_id) + " found in CPM");
160}
161
170inline WrappedCpmContainer getPerceivedObjectContainer(const CollectivePerceptionMessage &cpm) {
171 return getCpmContainer(cpm, WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER);
172}
173
179 * @throws std::invalid_argument if the container is not a PerceivedObjectContainer.
180 */
181inline uint8_t getNumberOfPerceivedObjects(const WrappedCpmContainer &container) {
182 if (container.container_id.value != WrappedCpmContainer::CHOICE_CONTAINER_DATA_PERCEIVED_OBJECT_CONTAINER) {
183 throw std::invalid_argument("Container is not a PerceivedObjectContainer");
184 }
185 uint8_t number = container.container_data_perceived_object_container.number_of_perceived_objects.value;
186 return number;
187}
188
190 * Retrieves the number of perceived objects from the given CPM.
191 *
192 * @param cpm The CPM from which to retrieve the number of perceived objects.
193 * @return The number of perceived objects.
194 */
195inline uint8_t getNumberOfPerceivedObjects(const CollectivePerceptionMessage &cpm) {
197}
198
202
205
211inline PerceivedObject getPerceivedObject(const WrappedCpmContainer &container, const uint8_t i) {
212 if (i >= getNumberOfPerceivedObjects(container)) {
213 throw std::invalid_argument("Index out of range");
215 return container.container_data_perceived_object_container.perceived_objects.array[i];
216}
217
225 */
226inline uint16_t getIdOfPerceivedObject(const PerceivedObject &object) {
227 if (!object.object_id_is_present) {
228 throw std::invalid_argument("No object_id present in PerceivedObject");
229 }
230 return object.object_id.value;
231}
232
239inline int32_t getCartesianCoordinate(const CartesianCoordinateWithConfidence &coordinate) {
240 return coordinate.value.value;
241}
242
244 * @brief Retrieves the confidence value from a CartesianCoordinateWithConfidence object.
245 *
246 * @param coordinate The CartesianCoordinateWithConfidence object from which to retrieve the confidence value.
247 * @return The confidence value of the CartesianCoordinateWithConfidence object in centimeters.
248 */
249inline uint16_t getCartesianCoordinateConfidence(const CartesianCoordinateWithConfidence &coordinate) {
250 return coordinate.confidence.value;
251}
252
259inline gm::Point getPositionOfPerceivedObject(const PerceivedObject &object) {
260 gm::Point point;
261 point.x = double(getCartesianCoordinate(object.position.x_coordinate)) / 100.0;
262 point.y = double(getCartesianCoordinate(object.position.y_coordinate)) / 100.0;
263 if (object.position.z_coordinate_is_present) {
264 point.z = double(getCartesianCoordinate(object.position.z_coordinate)) / 100.0;
265 }
266 return point;
267}
268
273 * @return std::tuple<double, double, double> x,y and z standard deviations of the positions in meters.
274 * The z standard deviation is infinity if the z coordinate is not present.
275 */
276inline std::tuple<double, double, double> getPositionConfidenceOfPerceivedObject(const PerceivedObject &object) {
277 double x_confidence = double(getCartesianCoordinateConfidence(object.position.x_coordinate)) / 100.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
278 double y_confidence = double(getCartesianCoordinateConfidence(object.position.y_coordinate)) / 100.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
279 double z_confidence = object.position.z_coordinate_is_present
280 ? double(getCartesianCoordinateConfidence(object.position.z_coordinate)) / 100.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR
281 : std::numeric_limits<double>::infinity();
282 return std::make_tuple(x_confidence, y_confidence, z_confidence);
283}
284
286 * @brief Get the Cartesian angle of the PerceivedObject
287 *
288 * @param object PerceivedObject to get the Cartesian angle from
289 * @return unit16_t Cartesian angle of the PerceivedObject in 0,1 degrees
290 */
291inline uint16_t getCartesianAngle(const CartesianAngle &angle) { return angle.value.value; }
292
299inline uint8_t getCartesianAngleConfidence(const CartesianAngle &angle) { return angle.confidence.value; }
300
303
311inline gm::Quaternion getOrientationOfPerceivedObject(const PerceivedObject &object) {
312 if (!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
313 tf2::Quaternion q;
314 double roll{0}, pitch{0}, yaw{0};
315
316 if (object.angles.x_angle_is_present) {
317 roll = (((double(getCartesianAngle(object.angles.x_angle)) / 10.0) ) / 180.0) *
318 M_PI;
319 }
320 if (object.angles.y_angle_is_present) {
321 pitch = (((double(getCartesianAngle(object.angles.y_angle)) / 10.0) ) / 180.0) *
322 M_PI;
323 }
324 yaw = (((double(getCartesianAngle(object.angles.z_angle)) / 10.0)) / 180.0) *
325 M_PI;
326 // This wraps from -pi ti pi because setRPY only uses cos and sin of the angles
327 q.setRPY(roll, pitch, yaw);
328
329 return tf2::toMsg(q);
330}
331
332/**
333 * @brief Get the yaw of the PerceivedObject
334 *
335 * @param object PerceivedObject to get the yaw from
336 * @return double yaw of the PerceivedObject in radians from -pi to pi
337 */
338inline double getYawOfPerceivedObject(const PerceivedObject &object) {
339 gm::Quaternion orientation = getOrientationOfPerceivedObject(object);
340 tf2::Quaternion q(orientation.x, orientation.y, orientation.z, orientation.w);
341 double roll, pitch, yaw;
342 tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);
343 return yaw;
344}
345
353inline double getYawConfidenceOfPerceivedObject(const PerceivedObject &object) {
354 if(!object.angles_is_present) throw std::invalid_argument("No angles present in PerceivedObject");
355 double yaw_confidence = object.angles.z_angle.confidence.value / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
356 yaw_confidence *= M_PI / 180.0; // convert to radians
357 return yaw_confidence;
358}
359
361
366inline gm::Pose getPoseOfPerceivedObject(const PerceivedObject &object) {
367 gm::Pose pose;
368 pose.position = getPositionOfPerceivedObject(object);
369 pose.orientation = getOrientationOfPerceivedObject(object);
370 return pose;
371}
372
374
380inline double getYawRateOfPerceivedObject(const PerceivedObject &object) {
381 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
382 return object.z_angular_velocity.value.value * M_PI / 180.0; // convert to rad/s
384
387
394inline double getYawRateConfidenceOfPerceivedObject(const PerceivedObject &object) {
395 if (!object.z_angular_velocity_is_present) throw std::invalid_argument("No yaw rate present in PerceivedObject");
396 auto val = object.z_angular_velocity.confidence.value;
397 static const std::map<uint8_t, double> confidence_map = {
398 {AngularSpeedConfidence::UNAVAILABLE, 0.0},
399 {AngularSpeedConfidence::DEG_SEC_01, 1.0},
400 {AngularSpeedConfidence::DEG_SEC_02, 2.0},
401 {AngularSpeedConfidence::DEG_SEC_05, 5.0},
402 {AngularSpeedConfidence::DEG_SEC_10, 10.0},
403 {AngularSpeedConfidence::DEG_SEC_20, 20.0},
404 {AngularSpeedConfidence::DEG_SEC_50, 50.0},
405 {AngularSpeedConfidence::OUT_OF_RANGE, std::numeric_limits<double>::infinity()},
406 };
407 return confidence_map.at(val) * M_PI / 180.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR; // convert to rad/s
408}
409
410
416inline double getVelocityComponent(const VelocityComponent &velocity) { return double(velocity.value.value) / 100.0; }
424inline double getVelocityComponentConfidence(const VelocityComponent &velocity) {
425 return double(velocity.confidence.value) / 100.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
426}
427
428
435inline gm::Vector3 getCartesianVelocityOfPerceivedObject(const PerceivedObject &object) {
436 if (!object.velocity_is_present) {
437 throw std::invalid_argument("No velocity present in PerceivedObject");
438 }
439 gm::Vector3 velocity;
440 if (object.velocity.choice == Velocity3dWithConfidence::CHOICE_POLAR_VELOCITY) {
441 double speed = getSpeed(object.velocity.polar_velocity.velocity_magnitude);
442 double angle = getCartesianAngle(object.velocity.polar_velocity.velocity_direction) * M_PI / 180.0 / 10.0; // convert to radians
443 velocity.x = speed * cos(angle);
444 velocity.y = speed * sin(angle);
445 if (object.velocity.polar_velocity.z_velocity_is_present) {
446 velocity.z = getVelocityComponent(object.velocity.cartesian_velocity.z_velocity);
447 }
448 } else if (object.velocity.choice == Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
449 velocity.x = getVelocityComponent(object.velocity.cartesian_velocity.x_velocity);
450 velocity.y = getVelocityComponent(object.velocity.cartesian_velocity.y_velocity);
451 if (object.velocity.cartesian_velocity.z_velocity_is_present) {
452 velocity.z = getVelocityComponent(object.velocity.cartesian_velocity.z_velocity);
453 }
454 } else {
455 throw std::invalid_argument("Velocity is neither Polar nor Cartesian");
456 }
457 return velocity;
458}
459
460/**
461 * @brief Get the Cartesian Velocity Confidence Of Perceived Object object
462 *
463 * @param object PerceivedObject to get the Cartesian velocity from
464 * @return std::tuple<double, double, double> the x,y and z standard deviations of the velocity in m/s
465 * The z standard deviation is infinity if the z velocity is not present.
466 * @throws std::invalid_argument If the velocity is no cartesian velocity.
467 */
468inline std::tuple<double, double, double> getCartesianVelocityConfidenceOfPerceivedObject(const PerceivedObject &object) {
469 if (!object.velocity_is_present) {
470 throw std::invalid_argument("No velocity present in PerceivedObject");
471 }
472 if (object.velocity.choice == Velocity3dWithConfidence::CHOICE_POLAR_VELOCITY) {
473 double speed_confidence = getSpeedConfidence(object.velocity.polar_velocity.velocity_magnitude) / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
474 double angle_confidence = getCartesianAngleConfidence(object.velocity.polar_velocity.velocity_direction) * M_PI / 180.0 / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR; // convert to radians
475 double speed = getSpeed(object.velocity.polar_velocity.velocity_magnitude);
476 double angle = getCartesianAngle(object.velocity.polar_velocity.velocity_direction) * M_PI / 180.0 / 10.0; // convert to radians
477 double lateral_confidence = speed * angle_confidence; // not exactly, but best approximation
478 double x_confidence = speed_confidence * cos(angle) * cos(angle)
479 + lateral_confidence * sin(angle) * sin(angle);
480 double y_confidence = speed_confidence * sin(angle) * sin(angle)
481 + lateral_confidence * cos(angle) * cos(angle);
482 // neglect xy covariance, as it is not present in the output of this function
483 double z_confidence = object.velocity.polar_velocity.z_velocity_is_present
484 ? getVelocityComponentConfidence(object.velocity.cartesian_velocity.z_velocity)
485 : std::numeric_limits<double>::infinity();
486 return std::make_tuple(x_confidence, y_confidence, z_confidence);
487 } else if (object.velocity.choice == Velocity3dWithConfidence::CHOICE_CARTESIAN_VELOCITY) {
488 double x_confidence = getVelocityComponentConfidence(object.velocity.cartesian_velocity.x_velocity);
489 double y_confidence = getVelocityComponentConfidence(object.velocity.cartesian_velocity.y_velocity);
490 double z_confidence = object.velocity.cartesian_velocity.z_velocity_is_present
491 ? getVelocityComponentConfidence(object.velocity.cartesian_velocity.z_velocity)
492 : std::numeric_limits<double>::infinity();
493 return std::make_tuple(x_confidence, y_confidence, z_confidence);
494 } else {
495 throw std::invalid_argument("Velocity is neither Polar nor Cartesian");
496 }
497
498}
499
504 * @return double value of the acceleration component in m/s^2
505 */
506inline double getAccelerationComponent(const AccelerationComponent &acceleration) {
507 return double(acceleration.value.value) / 10.0;
508}
509
512
516inline double getAccelerationComponentConfidence(const AccelerationComponent &acceleration) {
517 return double(acceleration.confidence.value) / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
518}
519
521 * @brief Get the Cartesian acceleration of the PerceivedObject
522 *
523 * @param object PerceivedObject to get the Cartesian acceleration from
524 * @return gm::Vector3 Cartesian acceleration of the PerceivedObject in m/s^2 (local coordinate system)
525 * @throws std::invalid_argument If the acceleration is no cartesian acceleration.
526 */
527inline gm::Vector3 getCartesianAccelerationOfPerceivedObject(const PerceivedObject &object) {
528 if (!object.acceleration_is_present) {
529 throw std::invalid_argument("No acceleration present in PerceivedObject");
530 }
531 gm::Vector3 acceleration;
533 if (object.acceleration.choice == Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
534 acceleration.x = getAccelerationComponent(object.acceleration.cartesian_acceleration.x_acceleration);
535 acceleration.y = getAccelerationComponent(object.acceleration.cartesian_acceleration.y_acceleration);
536 if (object.acceleration.cartesian_acceleration.z_acceleration_is_present) {
537 acceleration.z = getAccelerationComponent(object.acceleration.cartesian_acceleration.z_acceleration);
538 }
539 } else if (object.acceleration.choice == Acceleration3dWithConfidence::CHOICE_POLAR_ACCELERATION) {
540 double magnitude = getAccelerationMagnitude(object.acceleration.polar_acceleration.acceleration_magnitude);
541 double angle = getCartesianAngle(object.acceleration.polar_acceleration.acceleration_direction) * M_PI / 180.0 / 10.0; // convert to radians
542 acceleration.x = magnitude * cos(angle);
543 acceleration.y = magnitude * sin(angle);
544 if (object.acceleration.polar_acceleration.z_acceleration_is_present) {
545 acceleration.z = getAccelerationComponent(object.acceleration.polar_acceleration.z_acceleration);
547 } else {
548 throw std::invalid_argument("Acceleration is neither Cartesian nor Polar");
549 }
550
551 return acceleration;
552}
553
562inline std::tuple<double, double, double> getCartesianAccelerationConfidenceOfPerceivedObject(const PerceivedObject &object) {
563 if (!object.acceleration_is_present) throw std::invalid_argument("No acceleration present in PerceivedObject");
564
565 if (object.acceleration.choice == Acceleration3dWithConfidence::CHOICE_CARTESIAN_ACCELERATION) {
566 double x_confidence = getAccelerationComponentConfidence(object.acceleration.cartesian_acceleration.x_acceleration);
567 double y_confidence = getAccelerationComponentConfidence(object.acceleration.cartesian_acceleration.y_acceleration);
568 double z_confidence = object.acceleration.cartesian_acceleration.z_acceleration_is_present
569 ? getAccelerationComponentConfidence(object.acceleration.cartesian_acceleration.z_acceleration)
570 : std::numeric_limits<double>::infinity();
571 return std::make_tuple(x_confidence, y_confidence, z_confidence);
572 } else if (object.acceleration.choice == Acceleration3dWithConfidence::CHOICE_POLAR_ACCELERATION) {
573 double magnitude_confidence = getAccelerationMagnitudeConfidence(object.acceleration.polar_acceleration.acceleration_magnitude);
574 double angle_confidence = getCartesianAngleConfidence(object.acceleration.polar_acceleration.acceleration_direction) * M_PI / 180.0 / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR; // convert to radians
575 double magnitude = getAccelerationMagnitude(object.acceleration.polar_acceleration.acceleration_magnitude);
576 double angle = getCartesianAngle(object.acceleration.polar_acceleration.acceleration_direction) * M_PI / 180.0 / 10.0; // convert to radians
577 double lateral_confidence = magnitude * angle_confidence; // best approximation
578 double x_confidence = magnitude_confidence * cos(angle) * cos(angle)
579 + lateral_confidence * sin(angle) * sin(angle);
580 double y_confidence = magnitude_confidence * sin(angle) * sin(angle)
581 + lateral_confidence * cos(angle) * cos(angle);
582 // neglect xy covariance, as it is not present in the output of this function
583 double z_confidence = object.acceleration.polar_acceleration.z_acceleration_is_present
584 ? getAccelerationComponentConfidence(object.acceleration.polar_acceleration.z_acceleration)
585 : std::numeric_limits<double>::infinity();
586 return std::make_tuple(x_confidence, y_confidence, z_confidence);
587 } else {
588 throw std::invalid_argument("Acceleration is neither Cartesian nor Polar");
589 }
591
593
600 * @return The x-dimension of the perceived object in decimeters.
601 * @throws std::invalid_argument if the x-dimension is not present in the PerceivedObject.
602 */
603inline uint16_t getXDimensionOfPerceivedObject(const PerceivedObject &object) {
604 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
605 return object.object_dimension_x.value.value;
606}
607
610 *
611 * @param object The PerceivedObject from which to retrieve the x-dimension confidence.
612 * @return uint8_t The confidence of the x-dimension of the perceived object in decimeters.
613 * @throws std::invalid_argument if the x-dimension is not present in the PerceivedObject.
614 */
615inline uint8_t getXDimensionConfidenceOfPerceivedObject(const PerceivedObject &object) {
616 if (!object.object_dimension_x_is_present) throw std::invalid_argument("No x-dimension present in PerceivedObject");
617 return object.object_dimension_x.confidence.value;
618}
619
627 * @param object The PerceivedObject from which to retrieve the y-dimension.
628 * @return uint16_t y-dimension of the perceived object in in decimeters.
629 * @throws std::invalid_argument if the y-dimension is not present in the PerceivedObject.
630 */
631inline uint16_t getYDimensionOfPerceivedObject(const PerceivedObject &object) {
632 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
633 return object.object_dimension_y.value.value;
634}
635
643inline uint8_t getYDimensionConfidenceOfPerceivedObject(const PerceivedObject &object) {
644 if (!object.object_dimension_y_is_present) throw std::invalid_argument("No y-dimension present in PerceivedObject");
645 return object.object_dimension_y.confidence.value;
646}
647
659inline uint16_t getZDimensionOfPerceivedObject(const PerceivedObject &object) {
660 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
661 return object.object_dimension_z.value.value;
663
671inline uint8_t getZDimensionConfidenceOfPerceivedObject(const PerceivedObject &object) {
672 if (!object.object_dimension_z_is_present) throw std::invalid_argument("No z-dimension present in PerceivedObject");
673 return object.object_dimension_z.confidence.value;
674}
675
682
685inline gm::Vector3 getDimensionsOfPerceivedObject(const PerceivedObject &object) {
686 gm::Vector3 dimensions;
687 dimensions.x = double(getXDimensionOfPerceivedObject(object)) / 10.0;
688 dimensions.y = double(getYDimensionOfPerceivedObject(object)) / 10.0;
689 dimensions.z = double(getZDimensionOfPerceivedObject(object)) / 10.0;
690 return dimensions;
691}
692
696
699inline std::tuple<double, double, double> getDimensionsConfidenceOfPerceivedObject(const PerceivedObject &object) {
700 double conf_x = double(getXDimensionConfidenceOfPerceivedObject(object)) / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
701 double conf_y = double(getYDimensionConfidenceOfPerceivedObject(object)) / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
702 double conf_z = double(getZDimensionConfidenceOfPerceivedObject(object)) / 10.0 / etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR;
703 return {conf_x, conf_y, conf_z};
705
710
716inline gm::PointStamped getUTMPositionOfPerceivedObject(const CollectivePerceptionMessage &cpm,
717 const PerceivedObject &object) {
718 gm::PointStamped utm_position;
719 gm::PointStamped reference_position = getUTMPosition(cpm);
720 gm::Point relative_position = getPositionOfPerceivedObject(object);
721
722 utm_position.header.frame_id = reference_position.header.frame_id;
723 utm_position.point.x = reference_position.point.x + relative_position.x;
724 utm_position.point.y = reference_position.point.y + relative_position.y;
725 utm_position.point.z = reference_position.point.z + relative_position.z;
726
727 return utm_position;
728}
729
731 * @brief Get the confidence ellipse of the reference position as Covariance matrix
732 *
733 * The covariance matrix will have the entries cov_xx, cov_xy, cov_yx, cov_yy
734 * where x is WGS84 North and y is East
735 *
736 * @param cpm The CPM message to get the reference position from
737 * @return const std::array<double, 4> the covariance matrix, as specified above
738 */
739inline const std::array<double, 4> getWGSRefPosConfidence(const CollectivePerceptionMessage &cpm) {
740 return getWGSPosConfidenceEllipse(cpm.payload.management_container.reference_position.position_confidence_ellipse);
741}
742
745 *
746 * @param sensor_information The SensorInformation to get the sensorId from
747 * @return uint8_t The sensorId of a SensorInformation object
748 */
749inline uint8_t getSensorID(const SensorInformation &sensor_information) {
750 return sensor_information.sensor_id.value;
751}
752
759inline uint8_t getSensorType(const SensorInformation &sensor_information) {
760 return sensor_information.sensor_type.value;
761}
762
763} // namespace etsi_its_cpm_ts_msgs::access
double getAccelerationMagnitude(const AccelerationMagnitude &acceleration_magnitude)
Get the AccelerationMagnitude value.
Getter functions for the ETSI ITS Common Data Dictionary (CDD) v2.1.1.
double getSpeed(const Speed &speed)
Get the vehicle speed.
double getAccelerationMagnitude(const AccelerationMagnitude &acceleration_magnitude)
Get the AccelerationMagnitude value.
std::tuple< double, double, double > getCartesianAccelerationConfidenceOfPerceivedObject(const PerceivedObject &object)
Get the Cartesian Acceleration Confidence Of Perceived 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)
uint64_t getReferenceTimeValue(const CollectivePerceptionMessage &cpm)
Get the ReferenceTime-Value.
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.
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.
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.
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.
TimestampIts getReferenceTime(const CollectivePerceptionMessage &cpm)
Get the Reference Time 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)
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.