perception_interfaces 1.0.0
Loading...
Searching...
No Matches
Functions
convenience_state_getters.h File Reference

Convenience getter functions for object state members. More...

#include <perception_msgs_utils/impl/checks.h>
#include <perception_msgs_utils/impl/state_getters.h>
#include <perception_msgs_utils/impl/state_index.h>
#include <algorithm>
#include <cmath>

Go to the source code of this file.

Functions

std::vector< double > perception_msgs::object_access::getContinuousState (const ObjectState &state)
 Get the continuous state for a given object state.
 
template<typename T >
std::vector< double > perception_msgs::object_access::getContinuousState (const T &obj)
 Get the continuous state for a given template object that contains an object state.
 
std::vector< long int > perception_msgs::object_access::getDiscreteState (const ObjectState &state)
 Get the discrete state for a given object state.
 
template<typename T >
std::vector< long int > perception_msgs::object_access::getDiscreteState (const T &obj)
 Get the discrete state for a given template object that contains an object state.
 
std::vector< double > perception_msgs::object_access::getContinuousStateCovariance (const ObjectState &state)
 Get the continuous state covariance for a given object state.
 
template<typename T >
std::vector< double > perception_msgs::object_access::getContinuousStateCovariance (const T &obj)
 Get the continuous state covariance for a given template object that contains an object state.
 
double perception_msgs::object_access::getContinuousStateCovarianceAt (const ObjectState &state, const unsigned int i, const unsigned int j)
 Get the continuous state covariance entry (i,j) for a given object state.
 
template<typename T >
double perception_msgs::object_access::getContinuousStateCovarianceAt (const T &obj, const unsigned int i, const unsigned int j)
 Get the continuous state covariance entry (i,j) for a given template object that contains an object state.
 
std::vector< double > perception_msgs::object_access::getContinuousStateCovarianceDiagonal (const ObjectState &state)
 Get the continuous state covariance diagonal for a given object state.
 
template<typename T >
std::vector< double > perception_msgs::object_access::getContinuousStateCovarianceDiagonal (const T &obj)
 Get the continuous state covariance diagonal for a given template object that contains an object state.
 
gm::Point perception_msgs::object_access::getPosition (const ObjectState &state)
 Get the position of a given object state.
 
template<typename T >
gm::Point perception_msgs::object_access::getPosition (const T &obj)
 Get the position of a given template object that contains an object state.
 
gm::Quaternion perception_msgs::object_access::getOrientation (const ObjectState &state)
 Get the orientation of a given object state.
 
template<typename T >
gm::Quaternion perception_msgs::object_access::getOrientation (const T &obj)
 Get the orientation of a given template object that contains an object state.
 
gm::Pose perception_msgs::object_access::getPose (const ObjectState &state)
 Get the pose of a given object state.
 
gm::Point perception_msgs::object_access::getCenterPosition (const ObjectState &state)
 Get the object's geometric center position.
 
template<typename T >
gm::Point perception_msgs::object_access::getCenterPosition (const T &object)
 Get the object's geometric center position.
 
template<typename T >
gm::Pose perception_msgs::object_access::getPose (const T &obj)
 Get the pose of a given template object that contains an object state.
 
std::vector< double > perception_msgs::object_access::getPoseCovariance (const ObjectState &state)
 Get the pose covariance of a given object state.
 
template<typename T >
std::vector< double > perception_msgs::object_access::getPoseCovariance (const T &obj)
 Get the pose covariance of a given template object that contains an object state.
 
gm::PoseWithCovariance perception_msgs::object_access::getPoseWithCovariance (const ObjectState &state)
 Get the pose with covariance of a given object state.
 
template<typename T >
gm::PoseWithCovariance perception_msgs::object_access::getPoseWithCovariance (const T &obj)
 Get the pose with covariance of a given template object that contains an object state.
 
gm::Vector3 perception_msgs::object_access::getVelocity (const ObjectState &state)
 Get the velocity of a given object state.
 
template<typename T >
gm::Vector3 perception_msgs::object_access::getVelocity (const T &obj)
 Get the velocity of a given template object that contains an object state.
 
double perception_msgs::object_access::getVelocityMagnitude (const ObjectState &state)
 Get the velocity magnitude of a given object state.
 
template<typename T >
double perception_msgs::object_access::getVelocityMagnitude (const T &obj)
 Get the velocity magnitude of a given template object that contains an object state.
 
gm::Vector3 perception_msgs::object_access::getAcceleration (const ObjectState &state)
 Get the acceleration of a given object state.
 
template<typename T >
gm::Vector3 perception_msgs::object_access::getAcceleration (const T &obj)
 Get the acceleration of a given template object that contains an object state.
 
double perception_msgs::object_access::getAccelerationMagnitude (const ObjectState &state)
 Get the acceleration magnitude of a given object state.
 
template<typename T >
double perception_msgs::object_access::getAccelerationMagnitude (const T &obj)
 Get the acceleration magnitude of a given template object that contains an object state.
 
double perception_msgs::object_access::getRollInDeg (const ObjectState &state)
 Get the roll in degree of a given object state.
 
template<typename T >
double perception_msgs::object_access::getRollInDeg (const T &obj)
 Get the roll in degree of a given template object that contains an object state.
 
double perception_msgs::object_access::getPitchInDeg (const ObjectState &state)
 Get the pitch in degree of a given object state.
 
template<typename T >
double perception_msgs::object_access::getPitchInDeg (const T &obj)
 Get the pitch in degree of a given template object that contains an object state.
 
double perception_msgs::object_access::getYawInDeg (const ObjectState &state)
 Get the yaw in degree of a given object state.
 
template<typename T >
double perception_msgs::object_access::getYawInDeg (const T &obj)
 Get the yaw in degree of a given template object that contains an object state.
 
gm::PoseWithCovariance perception_msgs::object_access::getVelocityXYZWithCovariance (const ObjectState &state)
 Get the velocity XYZ with covariance of a object state.
 
template<typename T >
gm::PoseWithCovariance perception_msgs::object_access::getVelocityXYZWithCovariance (const T &obj)
 Get the velocity XYZ with covariance of a given template object that contains an object state.
 
gm::Vector3 perception_msgs::object_access::getVelocityXYZ (const ObjectState &state)
 Get the velocity XYZ of a given object state.
 
template<typename T >
gm::Vector3 perception_msgs::object_access::getVelocityXYZ (const T &obj)
 Get the velocity XYZ of a given template object that contains an object state.
 
double perception_msgs::object_access::getVelX (const ObjectState &state)
 Get the x-velocity of a given object state.
 
template<typename T >
double perception_msgs::object_access::getVelX (const T &obj)
 Get the x-velocity of a given template object that contains an object state.
 
double perception_msgs::object_access::getVelY (const ObjectState &state)
 Get the y-velocity of a given object state.
 
template<typename T >
double perception_msgs::object_access::getVelY (const T &obj)
 Get the y-velocity of a given template object that contains an object state.
 
gm::PoseWithCovariance perception_msgs::object_access::getAccelerationXYZWithCovariance (const ObjectState &state)
 Get the acceleration XYZ with covariance of a given object state.
 
template<typename T >
gm::PoseWithCovariance perception_msgs::object_access::getAccelerationXYZWithCovariance (const T &obj)
 Get the acceleration XYZ with covariance of a given template object that contains an object state.
 
gm::Vector3 perception_msgs::object_access::getAccelerationXYZ (const ObjectState &state)
 Get the acceleration XYZ of a given object state.
 
template<typename T >
gm::Vector3 perception_msgs::object_access::getAccelerationXYZ (const T &obj)
 Get the acceleration XYZ of a given template object that contains an object state.
 
double perception_msgs::object_access::getAccX (const ObjectState &state)
 Get the x-acceleration of a given object state.
 
template<typename T >
double perception_msgs::object_access::getAccX (const T &obj)
 Get the x-acceleration of a given template object that contains an object state.
 
double perception_msgs::object_access::getAccY (const ObjectState &state)
 Get the y-acceleration of a given object state.
 
template<typename T >
double perception_msgs::object_access::getAccY (const T &obj)
 Get the y-acceleration of a given template object that contains an object state.
 
ObjectClassification perception_msgs::object_access::getClassWithHighestProbability (const ObjectState &state)
 Get the classification with highest probability of a given object state.
 
template<typename T >
ObjectClassification perception_msgs::object_access::getClassWithHighestProbability (const T &obj)
 Get the classification with highest probability of a given template object that contains an object state.
 

Detailed Description

Convenience getter functions for object state members.

============================================================================ MIT License

Copyright (c) 2025 Institute for Automotive Engineering (ika), RWTH Aachen University

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

SOFTWARE.

Definition in file convenience_state_getters.h.

Function Documentation

◆ getAcceleration() [1/2]

gm::Vector3 perception_msgs::object_access::getAcceleration ( const ObjectState &  state)
inline

Get the acceleration of a given object state.

Parameters
state
Returns
gm::Vector3

Definition at line 425 of file convenience_state_getters.h.

425 {
426 gm::Vector3 acceleration;
427 acceleration.x = getAccLon(state);
428 acceleration.y = getAccLat(state);
429 acceleration.z = 0.0;
430 return acceleration;
431}
double getAccLon(const ObjectState &state)
Get the longitudinal acceleration for a given object state.
double getAccLat(const ObjectState &state)
Get the lateral acceleration for a given object state.

◆ getAcceleration() [2/2]

template<typename T >
gm::Vector3 perception_msgs::object_access::getAcceleration ( const T &  obj)
inline

Get the acceleration of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::Vector3

Definition at line 441 of file convenience_state_getters.h.

441 {
442 return getAcceleration(obj.state);
443}
gm::Vector3 getAcceleration(const ObjectState &state)
Get the acceleration of a given object state.

◆ getAccelerationMagnitude() [1/2]

double perception_msgs::object_access::getAccelerationMagnitude ( const ObjectState &  state)
inline

Get the acceleration magnitude of a given object state.

Parameters
state
Returns
double

Definition at line 451 of file convenience_state_getters.h.

451 {
452 gm::Vector3 acc = getAcceleration(state);
453 using namespace std;
454 return sqrt(pow(acc.x, 2) + pow(acc.y, 2) + pow(acc.z, 2));
455}

◆ getAccelerationMagnitude() [2/2]

template<typename T >
double perception_msgs::object_access::getAccelerationMagnitude ( const T &  obj)
inline

Get the acceleration magnitude of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 465 of file convenience_state_getters.h.

465 {
466 return getAccelerationMagnitude(obj.state);
467}
double getAccelerationMagnitude(const ObjectState &state)
Get the acceleration magnitude of a given object state.

◆ getAccelerationXYZ() [1/2]

gm::Vector3 perception_msgs::object_access::getAccelerationXYZ ( const ObjectState &  state)
inline

Get the acceleration XYZ of a given object state.

Parameters
state
Returns
gm::Vector3

Definition at line 730 of file convenience_state_getters.h.

730 {
731 gm::Vector3 acc_lon_lat, acc_xyz;
732 acc_lon_lat = getAcceleration(state);
733 tf2::Quaternion q;
734 q.setRPY(0.0, 0.0, getYaw(state));
735 gm::TransformStamped tf;
736 tf.transform.rotation = tf2::toMsg(q);
737 tf2::doTransform(acc_lon_lat, acc_xyz, tf);
738 return acc_xyz;
739}
double getYaw(const ObjectState &state)
Get the yaw for a given object state.

◆ getAccelerationXYZ() [2/2]

template<typename T >
gm::Vector3 perception_msgs::object_access::getAccelerationXYZ ( const T &  obj)
inline

Get the acceleration XYZ of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::Vector3

Definition at line 749 of file convenience_state_getters.h.

749 {
750 return getAccelerationXYZ(obj.state);
751}
gm::Vector3 getAccelerationXYZ(const ObjectState &state)
Get the acceleration XYZ of a given object state.

◆ getAccelerationXYZWithCovariance() [1/2]

gm::PoseWithCovariance perception_msgs::object_access::getAccelerationXYZWithCovariance ( const ObjectState &  state)
inline

Get the acceleration XYZ with covariance of a given object state.

Parameters
state
Returns
gm::PoseWithCovariance

Definition at line 669 of file convenience_state_getters.h.

669 {
670 gm::PoseWithCovariance acc_lon_lat, acc_xyz;
671 acc_lon_lat.pose.position.x = getAccLon(state);
672 acc_lon_lat.pose.position.y = getAccLat(state);
673 acc_lon_lat.pose.position.z = 0.0;
674
675 int ix, jx, n = 2;
676 auto model_id = state.model_id;
677 for (int i = 0; i < n; i++) {
678 for (int j = 0; j < n; j++) {
679 if (i == 0 && hasAccLon(model_id))
680 ix = indexAccLon(model_id);
681 else if (i == 1 && hasAccLat(model_id))
682 ix = indexAccLat(model_id);
683 else
684 continue;
685
686 if (j == 0 && hasAccLon(model_id))
687 jx = indexAccLon(model_id);
688 else if (j == 1 && hasAccLat(model_id))
689 jx = indexAccLat(model_id);
690 else
691 continue;
692
693 acc_lon_lat.covariance.at(6 * i + j) = getContinuousStateCovarianceAt(state, ix, jx);
694 }
695 }
696
697 tf2::Quaternion q;
698 q.setRPY(0.0, 0.0, getYaw(state));
699 gm::TransformStamped tf;
700 tf.transform.rotation = tf2::toMsg(q);
701#ifdef ROS1
702 gm::PoseWithCovarianceStamped acc_lon_lat_stamped, acc_xyz_stamped;
703 acc_lon_lat_stamped.pose = acc_lon_lat;
704 tf2::doTransform(acc_lon_lat_stamped, acc_xyz_stamped, tf);
705 acc_xyz = acc_xyz_stamped.pose;
706#else
707 tf2::doTransform(acc_lon_lat, acc_xyz, tf);
708#endif
709 return acc_xyz;
710}
double getContinuousStateCovarianceAt(const ObjectState &state, const unsigned int i, const unsigned int j)
Get the continuous state covariance entry (i,j) for a given object state.
bool hasAccLat(const unsigned char &model_id)
Indicates if given model contains a lateral acceleration.
int indexAccLon(const unsigned char &model_id)
Get the vector-index that stores the longitudinal acceleration for a given model-id.
int indexAccLat(const unsigned char &model_id)
Get the vector-index that stores the lateral acceleration for a given model-id.
bool hasAccLon(const unsigned char &model_id)
Indicates if given model contains a longitudinal acceleration.

◆ getAccelerationXYZWithCovariance() [2/2]

template<typename T >
gm::PoseWithCovariance perception_msgs::object_access::getAccelerationXYZWithCovariance ( const T &  obj)
inline

Get the acceleration XYZ with covariance of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::PoseWithCovariance

Definition at line 720 of file convenience_state_getters.h.

720 {
721 return getAccelerationXYZWithCovariance(obj.state);
722}
gm::PoseWithCovariance getAccelerationXYZWithCovariance(const ObjectState &state)
Get the acceleration XYZ with covariance of a given object state.

◆ getAccX() [1/2]

double perception_msgs::object_access::getAccX ( const ObjectState &  state)
inline

Get the x-acceleration of a given object state.

Parameters
state
Returns
double

Definition at line 759 of file convenience_state_getters.h.

759{ return getAccelerationXYZ(state).x; }

◆ getAccX() [2/2]

template<typename T >
double perception_msgs::object_access::getAccX ( const T &  obj)
inline

Get the x-acceleration of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 769 of file convenience_state_getters.h.

769 {
770 return getAccX(obj.state);
771}
double getAccX(const ObjectState &state)
Get the x-acceleration of a given object state.

◆ getAccY() [1/2]

double perception_msgs::object_access::getAccY ( const ObjectState &  state)
inline

Get the y-acceleration of a given object state.

Parameters
state
Returns
double

Definition at line 779 of file convenience_state_getters.h.

779{ return getAccelerationXYZ(state).y; }

◆ getAccY() [2/2]

template<typename T >
double perception_msgs::object_access::getAccY ( const T &  obj)
inline

Get the y-acceleration of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 789 of file convenience_state_getters.h.

789 {
790 return getAccY(obj.state);
791}
double getAccY(const ObjectState &state)
Get the y-acceleration of a given object state.

◆ getCenterPosition() [1/2]

gm::Point perception_msgs::object_access::getCenterPosition ( const ObjectState &  state)
inline

Get the object's geometric center position.

Parameters
stateThe state to get the center position from
Returns
gm::Point The position of the object's geometric center

Definition at line 242 of file convenience_state_getters.h.

242 {
243 gm::Point position = getPosition(state);
244 const auto orientation = getOrientation(state);
245 const gm::Vector3 offset_to_center = state.reference_point.translation_to_geometric_center;
246 tf2::Quaternion q;
247 tf2::fromMsg(orientation, q);
248 const tf2::Vector3 offset_to_center_tf2(offset_to_center.x, offset_to_center.y, offset_to_center.z);
249 const tf2::Vector3 rotated_offset_to_center = tf2::quatRotate(q, offset_to_center_tf2);
250 position.x += rotated_offset_to_center.x();
251 position.y += rotated_offset_to_center.y();
252 position.z += rotated_offset_to_center.z();
253 return position;
254}
gm::Point getPosition(const ObjectState &state)
Get the position of a given object state.
gm::Quaternion getOrientation(const ObjectState &state)
Get the orientation of a given object state.

◆ getCenterPosition() [2/2]

template<typename T >
gm::Point perception_msgs::object_access::getCenterPosition ( const T &  object)
inline

Get the object's geometric center position.

Template Parameters
T
Parameters
objectThe object to get the center position from
Returns
gm::Position The position of the object's geometric center

Definition at line 264 of file convenience_state_getters.h.

264 {
265 return getCenterPosition(object.state);
266}
gm::Point getCenterPosition(const ObjectState &state)
Get the object's geometric center position.

◆ getClassWithHighestProbability() [1/2]

ObjectClassification perception_msgs::object_access::getClassWithHighestProbability ( const ObjectState &  state)
inline

Get the classification with highest probability of a given object state.

Parameters
state
Returns
ObjectClassification

Definition at line 801 of file convenience_state_getters.h.

801 {
802 ObjectClassification highest_prob_class;
803 auto highest_prob_class_it = std::max_element(
804 state.classifications.begin(), state.classifications.end(),
805 [](const ObjectClassification& c1, const ObjectClassification& c2) { return c1.probability < c2.probability; });
806 if (highest_prob_class_it == state.classifications.end()) {
807 highest_prob_class.probability = -1.0;
808 highest_prob_class.type = ObjectClassification::UNKNOWN;
809 } else {
810 highest_prob_class = *highest_prob_class_it;
811 }
812 return highest_prob_class;
813}

◆ getClassWithHighestProbability() [2/2]

template<typename T >
ObjectClassification perception_msgs::object_access::getClassWithHighestProbability ( const T &  obj)
inline

Get the classification with highest probability of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
ObjectClassification

Definition at line 823 of file convenience_state_getters.h.

823 {
824 return getClassWithHighestProbability(obj.state);
825}
ObjectClassification getClassWithHighestProbability(const ObjectState &state)
Get the classification with highest probability of a given object state.

◆ getContinuousState() [1/2]

std::vector< double > perception_msgs::object_access::getContinuousState ( const ObjectState &  state)
inline

Get the continuous state for a given object state.

Parameters
state
Returns
std::vector<double>

Definition at line 51 of file convenience_state_getters.h.

51 {
53 return state.continuous_state;
54}
void sanityCheckContinuousState(const ObjectState &state)
Perform sanity check on continuous state of given object state.
Definition checks.h:84

◆ getContinuousState() [2/2]

template<typename T >
std::vector< double > perception_msgs::object_access::getContinuousState ( const T &  obj)
inline

Get the continuous state for a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
std::vector<double>

Definition at line 64 of file convenience_state_getters.h.

64 {
65 return getContinuousState(obj.state);
66}
std::vector< double > getContinuousState(const ObjectState &state)
Get the continuous state for a given object state.

◆ getContinuousStateCovariance() [1/2]

std::vector< double > perception_msgs::object_access::getContinuousStateCovariance ( const ObjectState &  state)
inline

Get the continuous state covariance for a given object state.

Parameters
state
Returns
std::vector<double>

Definition at line 97 of file convenience_state_getters.h.

97 {
99 return state.continuous_state_covariance;
100}

◆ getContinuousStateCovariance() [2/2]

template<typename T >
std::vector< double > perception_msgs::object_access::getContinuousStateCovariance ( const T &  obj)
inline

Get the continuous state covariance for a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
std::vector<double>

Definition at line 110 of file convenience_state_getters.h.

110 {
111 return getContinuousStateCovariance(obj.state);
112}
std::vector< double > getContinuousStateCovariance(const ObjectState &state)
Get the continuous state covariance for a given object state.

◆ getContinuousStateCovarianceAt() [1/2]

double perception_msgs::object_access::getContinuousStateCovarianceAt ( const ObjectState &  state,
const unsigned int  i,
const unsigned int  j 
)
inline

Get the continuous state covariance entry (i,j) for a given object state.

Parameters
state
i
j
Returns
double

Definition at line 122 of file convenience_state_getters.h.

122 {
123 const int n = getContinuousStateSize(state);
124 const std::vector<double> covariance = getContinuousStateCovariance(state);
125 return covariance[n * i + j];
126}
int getContinuousStateSize(const ObjectState &state)
Get the continuous state size for a given object state.
Definition utils.h:51

◆ getContinuousStateCovarianceAt() [2/2]

template<typename T >
double perception_msgs::object_access::getContinuousStateCovarianceAt ( const T &  obj,
const unsigned int  i,
const unsigned int  j 
)
inline

Get the continuous state covariance entry (i,j) for a given template object that contains an object state.

Template Parameters
T
Parameters
obj
i
j
Returns
double

Definition at line 138 of file convenience_state_getters.h.

138 {
139 return getContinuousStateCovarianceAt(obj.state, i, j);
140}

◆ getContinuousStateCovarianceDiagonal() [1/2]

std::vector< double > perception_msgs::object_access::getContinuousStateCovarianceDiagonal ( const ObjectState &  state)
inline

Get the continuous state covariance diagonal for a given object state.

Parameters
state
Returns
std::vector<double>

Definition at line 148 of file convenience_state_getters.h.

148 {
149 const int n = getContinuousStateSize(state);
150 std::vector<double> diagonal(n);
151 for (int i = 0; i < n; i++) diagonal[i] = getContinuousStateCovarianceAt(state, i, i);
152 return diagonal;
153}

◆ getContinuousStateCovarianceDiagonal() [2/2]

template<typename T >
std::vector< double > perception_msgs::object_access::getContinuousStateCovarianceDiagonal ( const T &  obj)
inline

Get the continuous state covariance diagonal for a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
std::vector<double>

Definition at line 163 of file convenience_state_getters.h.

163 {
164 return getContinuousStateCovarianceDiagonal(obj.state);
165}
std::vector< double > getContinuousStateCovarianceDiagonal(const ObjectState &state)
Get the continuous state covariance diagonal for a given object state.

◆ getDiscreteState() [1/2]

std::vector< long int > perception_msgs::object_access::getDiscreteState ( const ObjectState &  state)
inline

Get the discrete state for a given object state.

Parameters
state
Returns
std::vector<long int>

Definition at line 74 of file convenience_state_getters.h.

74 {
76 return state.discrete_state;
77}

◆ getDiscreteState() [2/2]

template<typename T >
std::vector< long int > perception_msgs::object_access::getDiscreteState ( const T &  obj)
inline

Get the discrete state for a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
std::vector<long int>

Definition at line 87 of file convenience_state_getters.h.

87 {
88 return getDiscreteState(obj.state);
89}
std::vector< long int > getDiscreteState(const ObjectState &state)
Get the discrete state for a given object state.

◆ getOrientation() [1/2]

gm::Quaternion perception_msgs::object_access::getOrientation ( const ObjectState &  state)
inline

Get the orientation of a given object state.

Parameters
state
Returns
gm::Quaternion

Definition at line 201 of file convenience_state_getters.h.

201 {
202 tf2::Quaternion q;
203 double roll{0}, pitch{0}, yaw{0};
204 if (hasRoll(state.model_id)) roll = getRoll(state);
205 if (hasPitch(state.model_id)) pitch = getPitch(state);
206 if (hasYaw(state.model_id)) yaw = getYaw(state);
207 q.setRPY(roll, pitch, yaw);
208 return tf2::toMsg(q);
209}
double getRoll(const ObjectState &state)
Get the roll for a given object state.
double getPitch(const ObjectState &state)
Get the pitch for a given object state.
bool hasYaw(const unsigned char &model_id)
Indicates if given model contains a yaw.
bool hasRoll(const unsigned char &model_id)
Indicates if given model contains a roll.
bool hasPitch(const unsigned char &model_id)
Indicates if given model contains a pitch.

◆ getOrientation() [2/2]

template<typename T >
gm::Quaternion perception_msgs::object_access::getOrientation ( const T &  obj)
inline

Get the orientation of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::Quaternion

Definition at line 219 of file convenience_state_getters.h.

219 {
220 return getOrientation(obj.state);
221}

◆ getPitchInDeg() [1/2]

double perception_msgs::object_access::getPitchInDeg ( const ObjectState &  state)
inline

Get the pitch in degree of a given object state.

Parameters
state
Returns
double

Definition at line 497 of file convenience_state_getters.h.

497{ return getPitch(state) * 180.0 / M_PI; }

◆ getPitchInDeg() [2/2]

template<typename T >
double perception_msgs::object_access::getPitchInDeg ( const T &  obj)
inline

Get the pitch in degree of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 507 of file convenience_state_getters.h.

507 {
508 return getPitchInDeg(obj.state);
509}
double getPitchInDeg(const ObjectState &state)
Get the pitch in degree of a given object state.

◆ getPose() [1/2]

gm::Pose perception_msgs::object_access::getPose ( const ObjectState &  state)
inline

Get the pose of a given object state.

Parameters
state
Returns
gm::Pose

Definition at line 229 of file convenience_state_getters.h.

229 {
230 gm::Pose pose;
231 pose.position = getPosition(state);
232 pose.orientation = getOrientation(state);
233 return pose;
234}

◆ getPose() [2/2]

template<typename T >
gm::Pose perception_msgs::object_access::getPose ( const T &  obj)
inline

Get the pose of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::Pose

Definition at line 276 of file convenience_state_getters.h.

276 {
277 return getPose(obj.state);
278}
gm::Pose getPose(const ObjectState &state)
Get the pose of a given object state.

◆ getPoseCovariance() [1/2]

std::vector< double > perception_msgs::object_access::getPoseCovariance ( const ObjectState &  state)
inline

Get the pose covariance of a given object state.

Parameters
state
Returns
std::vector<double>

Definition at line 286 of file convenience_state_getters.h.

286 {
287 const int n = 6;
288 const int model_id = state.model_id;
289 std::vector<double> pose_covariance(n * n, 0.0);
290 int ix, jx;
291 for (int i = 0; i < n; i++) {
292 for (int j = 0; j < n; j++) {
293 if (i == 0 && hasX(model_id))
294 ix = indexX(model_id);
295 else if (i == 1 && hasY(model_id))
296 ix = indexY(model_id);
297 else if (i == 2 && hasZ(model_id))
298 ix = indexZ(model_id);
299 else if (i == 3 && hasRoll(model_id))
300 ix = indexRoll(model_id);
301 else if (i == 4 && hasPitch(model_id))
302 ix = indexPitch(model_id);
303 else if (i == 5 && hasYaw(model_id))
304 ix = indexYaw(model_id);
305 else
306 continue;
307
308 if (j == 0 && hasX(model_id))
309 jx = indexX(model_id);
310 else if (j == 1 && hasY(model_id))
311 jx = indexY(model_id);
312 else if (j == 2 && hasZ(model_id))
313 jx = indexZ(model_id);
314 else if (j == 3 && hasRoll(model_id))
315 jx = indexRoll(model_id);
316 else if (j == 4 && hasPitch(model_id))
317 jx = indexPitch(model_id);
318 else if (j == 5 && hasYaw(model_id))
319 jx = indexYaw(model_id);
320 else
321 continue;
322
323 pose_covariance[n * i + j] = getContinuousStateCovarianceAt(state, ix, jx);
324 }
325 }
326 return pose_covariance;
327}
int indexRoll(const unsigned char &model_id)
Get the vector-index that stores the roll for a given model-id.
bool hasZ(const unsigned char &model_id)
Indicates if given model contains a z-position.
bool hasY(const unsigned char &model_id)
Indicates if given model contains a y-position.
int indexY(const unsigned char &model_id)
Get the vector-index that stores the y-position for a given model-id.
Definition state_index.h:68
bool hasX(const unsigned char &model_id)
Indicates if given model contains an x-position.
int indexZ(const unsigned char &model_id)
Get the vector-index that stores the z-position for a given model-id.
Definition state_index.h:91
int indexPitch(const unsigned char &model_id)
Get the vector-index that stores the pitch for a given model-id.
int indexX(const unsigned char &model_id)
Get the vector-index that stores the x-position for a given model-id.
Definition state_index.h:45
int indexYaw(const unsigned char &model_id)
Get the vector-index that stores the yaw for a given model-id.

◆ getPoseCovariance() [2/2]

template<typename T >
std::vector< double > perception_msgs::object_access::getPoseCovariance ( const T &  obj)
inline

Get the pose covariance of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
std::vector<double>

Definition at line 337 of file convenience_state_getters.h.

337 {
338 return getPoseCovariance(obj.state);
339}
std::vector< double > getPoseCovariance(const ObjectState &state)
Get the pose covariance of a given object state.

◆ getPoseWithCovariance() [1/2]

gm::PoseWithCovariance perception_msgs::object_access::getPoseWithCovariance ( const ObjectState &  state)
inline

Get the pose with covariance of a given object state.

Parameters
state
Returns
gm::PoseWithCovariance

Definition at line 348 of file convenience_state_getters.h.

348 {
349 gm::PoseWithCovariance pose_with_covariance;
350 pose_with_covariance.pose = getPose(state);
351 std::vector<double> covariance_vector = getPoseCovariance(state);
352 gm::PoseWithCovariance::_covariance_type covariance;
353 std::copy(covariance_vector.begin(), covariance_vector.end(), covariance.begin());
354 pose_with_covariance.covariance = covariance;
355 return pose_with_covariance;
356}

◆ getPoseWithCovariance() [2/2]

template<typename T >
gm::PoseWithCovariance perception_msgs::object_access::getPoseWithCovariance ( const T &  obj)
inline

Get the pose with covariance of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::PoseWithCovariance

Definition at line 366 of file convenience_state_getters.h.

366 {
367 return getPoseWithCovariance(obj.state);
368}
gm::PoseWithCovariance getPoseWithCovariance(const ObjectState &state)
Get the pose with covariance of a given object state.

◆ getPosition() [1/2]

gm::Point perception_msgs::object_access::getPosition ( const ObjectState &  state)
inline

Get the position of a given object state.

Parameters
state
Returns
gm::Point

Definition at line 175 of file convenience_state_getters.h.

175 {
176 gm::Point position;
177 position.x = getX(state);
178 position.y = getY(state);
179 position.z = getZ(state);
180 return position;
181}
double getZ(const ObjectState &state)
Get the z-position for a given object state.
double getY(const ObjectState &state)
Get the y-position for a given object state.
double getX(const ObjectState &state)
Get the x-position for a given object state.

◆ getPosition() [2/2]

template<typename T >
gm::Point perception_msgs::object_access::getPosition ( const T &  obj)
inline

Get the position of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::Point

Definition at line 191 of file convenience_state_getters.h.

191 {
192 return getPosition(obj.state);
193}

◆ getRollInDeg() [1/2]

double perception_msgs::object_access::getRollInDeg ( const ObjectState &  state)
inline

Get the roll in degree of a given object state.

Parameters
state
Returns
double

Definition at line 477 of file convenience_state_getters.h.

477{ return getRoll(state) * 180.0 / M_PI; }

◆ getRollInDeg() [2/2]

template<typename T >
double perception_msgs::object_access::getRollInDeg ( const T &  obj)
inline

Get the roll in degree of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 487 of file convenience_state_getters.h.

487 {
488 return getRollInDeg(obj.state);
489}
double getRollInDeg(const ObjectState &state)
Get the roll in degree of a given object state.

◆ getVelocity() [1/2]

gm::Vector3 perception_msgs::object_access::getVelocity ( const ObjectState &  state)
inline

Get the velocity of a given object state.

Parameters
state
Returns
gm::Vector3

Definition at line 376 of file convenience_state_getters.h.

376 {
377 gm::Vector3 velocity;
378 velocity.x = getVelLon(state);
379 velocity.y = getVelLat(state);
380 velocity.z = 0.0;
381 return velocity;
382}
double getVelLon(const ObjectState &state)
Get the longitudinal velocity for a given object state.
double getVelLat(const ObjectState &state)
Get the longitudinal velocity for a given object state.

◆ getVelocity() [2/2]

template<typename T >
gm::Vector3 perception_msgs::object_access::getVelocity ( const T &  obj)
inline

Get the velocity of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::Vector3

Definition at line 392 of file convenience_state_getters.h.

392 {
393 return getVelocity(obj.state);
394}
gm::Vector3 getVelocity(const ObjectState &state)
Get the velocity of a given object state.

◆ getVelocityMagnitude() [1/2]

double perception_msgs::object_access::getVelocityMagnitude ( const ObjectState &  state)
inline

Get the velocity magnitude of a given object state.

Parameters
state
Returns
double

Definition at line 402 of file convenience_state_getters.h.

402 {
403 gm::Vector3 vel = getVelocity(state);
404 using namespace std;
405 return sqrt(pow(vel.x, 2) + pow(vel.y, 2) + pow(vel.z, 2));
406}

◆ getVelocityMagnitude() [2/2]

template<typename T >
double perception_msgs::object_access::getVelocityMagnitude ( const T &  obj)
inline

Get the velocity magnitude of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 416 of file convenience_state_getters.h.

416 {
417 return getVelocityMagnitude(obj.state);
418}
double getVelocityMagnitude(const ObjectState &state)
Get the velocity magnitude of a given object state.

◆ getVelocityXYZ() [1/2]

gm::Vector3 perception_msgs::object_access::getVelocityXYZ ( const ObjectState &  state)
inline

Get the velocity XYZ of a given object state.

Parameters
state
Returns
gm::Vector3

Definition at line 600 of file convenience_state_getters.h.

600 {
601 gm::Vector3 vel_lon_lat, vel_xyz;
602 vel_lon_lat = getVelocity(state);
603 tf2::Quaternion q;
604 q.setRPY(0.0, 0.0, getYaw(state));
605 gm::TransformStamped tf;
606 tf.transform.rotation = tf2::toMsg(q);
607 tf2::doTransform(vel_lon_lat, vel_xyz, tf);
608 return vel_xyz;
609}

◆ getVelocityXYZ() [2/2]

template<typename T >
gm::Vector3 perception_msgs::object_access::getVelocityXYZ ( const T &  obj)
inline

Get the velocity XYZ of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::Vector3

Definition at line 619 of file convenience_state_getters.h.

619 {
620 return getVelocityXYZ(obj.state);
621}
gm::Vector3 getVelocityXYZ(const ObjectState &state)
Get the velocity XYZ of a given object state.

◆ getVelocityXYZWithCovariance() [1/2]

gm::PoseWithCovariance perception_msgs::object_access::getVelocityXYZWithCovariance ( const ObjectState &  state)
inline

Get the velocity XYZ with covariance of a object state.

Parameters
state
Returns
gm::PoseWithCovariance

Definition at line 537 of file convenience_state_getters.h.

537 {
538 gm::PoseWithCovariance vel_lon_lat, vel_xyz;
539 vel_lon_lat.pose.position.x = getVelLon(state);
540 vel_lon_lat.pose.position.y = getVelLat(state);
541 vel_lon_lat.pose.position.z = 0.0;
542
543 int ix, jx, n = 2;
544 auto model_id = state.model_id;
545 for (int i = 0; i < n; i++) {
546 for (int j = 0; j < n; j++) {
547 if (i == 0 && hasVelLon(model_id))
548 ix = indexVelLon(model_id);
549 else if (i == 1 && hasVelLat(model_id))
550 ix = indexVelLat(model_id);
551 else
552 continue;
553
554 if (j == 0 && hasVelLon(model_id))
555 jx = indexVelLon(model_id);
556 else if (j == 1 && hasVelLat(model_id))
557 jx = indexVelLat(model_id);
558 else
559 continue;
560
561 vel_lon_lat.covariance.at(6 * i + j) = getContinuousStateCovarianceAt(state, ix, jx);
562 }
563 }
564
565 tf2::Quaternion q;
566 q.setRPY(0.0, 0.0, getYaw(state));
567 gm::TransformStamped tf;
568 tf.transform.rotation = tf2::toMsg(q);
569
570#ifdef ROS1
571 gm::PoseWithCovarianceStamped vel_lon_lat_stamped, vel_xyz_stamped;
572 vel_lon_lat_stamped.pose = vel_lon_lat;
573 tf2::doTransform(vel_lon_lat_stamped, vel_xyz_stamped, tf);
574 vel_xyz = vel_xyz_stamped.pose;
575#else
576 tf2::doTransform(vel_lon_lat, vel_xyz, tf);
577#endif
578
579 return vel_xyz;
580}
int indexVelLon(const unsigned char &model_id)
Get the vector-index that stores the longitudinal velocity for a given model-id.
bool hasVelLat(const unsigned char &model_id)
Indicates if given model contains a lateral velocity.
int indexVelLat(const unsigned char &model_id)
Get the vector-index that stores the lateral velocity for a given model-id.
bool hasVelLon(const unsigned char &model_id)
Indicates if given model contains a longitudinal velocity.

◆ getVelocityXYZWithCovariance() [2/2]

template<typename T >
gm::PoseWithCovariance perception_msgs::object_access::getVelocityXYZWithCovariance ( const T &  obj)
inline

Get the velocity XYZ with covariance of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
gm::PoseWithCovariance

Definition at line 590 of file convenience_state_getters.h.

590 {
591 return getVelocityXYZWithCovariance(obj.state);
592}
gm::PoseWithCovariance getVelocityXYZWithCovariance(const ObjectState &state)
Get the velocity XYZ with covariance of a object state.

◆ getVelX() [1/2]

double perception_msgs::object_access::getVelX ( const ObjectState &  state)
inline

Get the x-velocity of a given object state.

Parameters
state
Returns
double

Definition at line 629 of file convenience_state_getters.h.

629{ return getVelocityXYZ(state).x; }

◆ getVelX() [2/2]

template<typename T >
double perception_msgs::object_access::getVelX ( const T &  obj)
inline

Get the x-velocity of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 639 of file convenience_state_getters.h.

639 {
640 return getVelX(obj.state);
641}
double getVelX(const ObjectState &state)
Get the x-velocity of a given object state.

◆ getVelY() [1/2]

double perception_msgs::object_access::getVelY ( const ObjectState &  state)
inline

Get the y-velocity of a given object state.

Parameters
state
Returns
double

Definition at line 649 of file convenience_state_getters.h.

649{ return getVelocityXYZ(state).y; }

◆ getVelY() [2/2]

template<typename T >
double perception_msgs::object_access::getVelY ( const T &  obj)
inline

Get the y-velocity of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 659 of file convenience_state_getters.h.

659 {
660 return getVelY(obj.state);
661}
double getVelY(const ObjectState &state)
Get the y-velocity of a given object state.

◆ getYawInDeg() [1/2]

double perception_msgs::object_access::getYawInDeg ( const ObjectState &  state)
inline

Get the yaw in degree of a given object state.

Parameters
state
Returns
double

Definition at line 517 of file convenience_state_getters.h.

517{ return getYaw(state) * 180.0 / M_PI; }

◆ getYawInDeg() [2/2]

template<typename T >
double perception_msgs::object_access::getYawInDeg ( const T &  obj)
inline

Get the yaw in degree of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
Returns
double

Definition at line 527 of file convenience_state_getters.h.

527 {
528 return getYawInDeg(obj.state);
529}
double getYawInDeg(const ObjectState &state)
Get the yaw in degree of a given object state.