perception_interfaces 1.1.2
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.

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 404 of file convenience_state_getters.h.

404 {
405 gm::Vector3 acceleration;
406 acceleration.x = getAccLon(state);
407 acceleration.y = getAccLat(state);
408 acceleration.z = 0.0;
409 return acceleration;
410}
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 420 of file convenience_state_getters.h.

420 {
421 return getAcceleration(obj.state);
422}
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 430 of file convenience_state_getters.h.

430 {
431 gm::Vector3 acc = getAcceleration(state);
432 using namespace std;
433 return sqrt(pow(acc.x, 2) + pow(acc.y, 2) + pow(acc.z, 2));
434}

◆ 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 444 of file convenience_state_getters.h.

444 {
445 return getAccelerationMagnitude(obj.state);
446}
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 709 of file convenience_state_getters.h.

709 {
710 gm::Vector3 acc_lon_lat, acc_xyz;
711 acc_lon_lat = getAcceleration(state);
712 tf2::Quaternion q;
713 q.setRPY(0.0, 0.0, getYaw(state));
714 gm::TransformStamped tf;
715 tf.transform.rotation = tf2::toMsg(q);
716 tf2::doTransform(acc_lon_lat, acc_xyz, tf);
717 return acc_xyz;
718}
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 728 of file convenience_state_getters.h.

728 {
729 return getAccelerationXYZ(obj.state);
730}
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 648 of file convenience_state_getters.h.

648 {
649 gm::PoseWithCovariance acc_lon_lat, acc_xyz;
650 acc_lon_lat.pose.position.x = getAccLon(state);
651 acc_lon_lat.pose.position.y = getAccLat(state);
652 acc_lon_lat.pose.position.z = 0.0;
653
654 int ix, jx, n = 2;
655 auto model_id = state.model_id;
656 for (int i = 0; i < n; i++) {
657 for (int j = 0; j < n; j++) {
658 if (i == 0 && hasAccLon(model_id))
659 ix = indexAccLon(model_id);
660 else if (i == 1 && hasAccLat(model_id))
661 ix = indexAccLat(model_id);
662 else
663 continue;
664
665 if (j == 0 && hasAccLon(model_id))
666 jx = indexAccLon(model_id);
667 else if (j == 1 && hasAccLat(model_id))
668 jx = indexAccLat(model_id);
669 else
670 continue;
671
672 acc_lon_lat.covariance.at(6 * i + j) = getContinuousStateCovarianceAt(state, ix, jx);
673 }
674 }
675
676 tf2::Quaternion q;
677 q.setRPY(0.0, 0.0, getYaw(state));
678 gm::TransformStamped tf;
679 tf.transform.rotation = tf2::toMsg(q);
680#ifdef ROS1
681 gm::PoseWithCovarianceStamped acc_lon_lat_stamped, acc_xyz_stamped;
682 acc_lon_lat_stamped.pose = acc_lon_lat;
683 tf2::doTransform(acc_lon_lat_stamped, acc_xyz_stamped, tf);
684 acc_xyz = acc_xyz_stamped.pose;
685#else
686 tf2::doTransform(acc_lon_lat, acc_xyz, tf);
687#endif
688 return acc_xyz;
689}
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 699 of file convenience_state_getters.h.

699 {
700 return getAccelerationXYZWithCovariance(obj.state);
701}
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 738 of file convenience_state_getters.h.

738{ 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 748 of file convenience_state_getters.h.

748 {
749 return getAccX(obj.state);
750}
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 758 of file convenience_state_getters.h.

758{ 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 768 of file convenience_state_getters.h.

768 {
769 return getAccY(obj.state);
770}
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 221 of file convenience_state_getters.h.

221 {
222 gm::Point position = getPosition(state);
223 const auto orientation = getOrientation(state);
224 const gm::Vector3 offset_to_center = state.reference_point.translation_to_geometric_center;
225 tf2::Quaternion q;
226 tf2::fromMsg(orientation, q);
227 const tf2::Vector3 offset_to_center_tf2(offset_to_center.x, offset_to_center.y, offset_to_center.z);
228 const tf2::Vector3 rotated_offset_to_center = tf2::quatRotate(q, offset_to_center_tf2);
229 position.x += rotated_offset_to_center.x();
230 position.y += rotated_offset_to_center.y();
231 position.z += rotated_offset_to_center.z();
232 return position;
233}
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 243 of file convenience_state_getters.h.

243 {
244 return getCenterPosition(object.state);
245}
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 780 of file convenience_state_getters.h.

780 {
781 ObjectClassification highest_prob_class;
782 auto highest_prob_class_it = std::max_element(
783 state.classifications.begin(), state.classifications.end(),
784 [](const ObjectClassification& c1, const ObjectClassification& c2) { return c1.probability < c2.probability; });
785 if (highest_prob_class_it == state.classifications.end()) {
786 highest_prob_class.probability = -1.0;
787 highest_prob_class.type = ObjectClassification::UNKNOWN;
788 } else {
789 highest_prob_class = *highest_prob_class_it;
790 }
791 return highest_prob_class;
792}

◆ 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 802 of file convenience_state_getters.h.

802 {
803 return getClassWithHighestProbability(obj.state);
804}
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 30 of file convenience_state_getters.h.

30 {
32 return state.continuous_state;
33}
void sanityCheckContinuousState(const ObjectState &state)
Perform sanity check on continuous state of given object state.
Definition checks.h:63

◆ 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 43 of file convenience_state_getters.h.

43 {
44 return getContinuousState(obj.state);
45}
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 76 of file convenience_state_getters.h.

76 {
78 return state.continuous_state_covariance;
79}

◆ 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 89 of file convenience_state_getters.h.

89 {
90 return getContinuousStateCovariance(obj.state);
91}
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 101 of file convenience_state_getters.h.

101 {
102 const int n = getContinuousStateSize(state);
103 const std::vector<double> covariance = getContinuousStateCovariance(state);
104 return covariance[n * i + j];
105}
int getContinuousStateSize(const ObjectState &state)
Get the continuous state size for a given object state.
Definition utils.h:30

◆ 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 117 of file convenience_state_getters.h.

117 {
118 return getContinuousStateCovarianceAt(obj.state, i, j);
119}

◆ 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 127 of file convenience_state_getters.h.

127 {
128 const int n = getContinuousStateSize(state);
129 std::vector<double> diagonal(n);
130 for (int i = 0; i < n; i++) diagonal[i] = getContinuousStateCovarianceAt(state, i, i);
131 return diagonal;
132}

◆ 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 142 of file convenience_state_getters.h.

142 {
143 return getContinuousStateCovarianceDiagonal(obj.state);
144}
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 53 of file convenience_state_getters.h.

53 {
55 return state.discrete_state;
56}

◆ 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 66 of file convenience_state_getters.h.

66 {
67 return getDiscreteState(obj.state);
68}
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 180 of file convenience_state_getters.h.

180 {
181 tf2::Quaternion q;
182 double roll{0}, pitch{0}, yaw{0};
183 if (hasRoll(state.model_id)) roll = getRoll(state);
184 if (hasPitch(state.model_id)) pitch = getPitch(state);
185 if (hasYaw(state.model_id)) yaw = getYaw(state);
186 q.setRPY(roll, pitch, yaw);
187 return tf2::toMsg(q);
188}
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 198 of file convenience_state_getters.h.

198 {
199 return getOrientation(obj.state);
200}

◆ 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 476 of file convenience_state_getters.h.

476{ 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 486 of file convenience_state_getters.h.

486 {
487 return getPitchInDeg(obj.state);
488}
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 208 of file convenience_state_getters.h.

208 {
209 gm::Pose pose;
210 pose.position = getPosition(state);
211 pose.orientation = getOrientation(state);
212 return pose;
213}

◆ 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 255 of file convenience_state_getters.h.

255 {
256 return getPose(obj.state);
257}
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 265 of file convenience_state_getters.h.

265 {
266 const int n = 6;
267 const int model_id = state.model_id;
268 std::vector<double> pose_covariance(n * n, 0.0);
269 int ix, jx;
270 for (int i = 0; i < n; i++) {
271 for (int j = 0; j < n; j++) {
272 if (i == 0 && hasX(model_id))
273 ix = indexX(model_id);
274 else if (i == 1 && hasY(model_id))
275 ix = indexY(model_id);
276 else if (i == 2 && hasZ(model_id))
277 ix = indexZ(model_id);
278 else if (i == 3 && hasRoll(model_id))
279 ix = indexRoll(model_id);
280 else if (i == 4 && hasPitch(model_id))
281 ix = indexPitch(model_id);
282 else if (i == 5 && hasYaw(model_id))
283 ix = indexYaw(model_id);
284 else
285 continue;
286
287 if (j == 0 && hasX(model_id))
288 jx = indexX(model_id);
289 else if (j == 1 && hasY(model_id))
290 jx = indexY(model_id);
291 else if (j == 2 && hasZ(model_id))
292 jx = indexZ(model_id);
293 else if (j == 3 && hasRoll(model_id))
294 jx = indexRoll(model_id);
295 else if (j == 4 && hasPitch(model_id))
296 jx = indexPitch(model_id);
297 else if (j == 5 && hasYaw(model_id))
298 jx = indexYaw(model_id);
299 else
300 continue;
301
302 pose_covariance[n * i + j] = getContinuousStateCovarianceAt(state, ix, jx);
303 }
304 }
305 return pose_covariance;
306}
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:47
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:70
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:24
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 316 of file convenience_state_getters.h.

316 {
317 return getPoseCovariance(obj.state);
318}
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 327 of file convenience_state_getters.h.

327 {
328 gm::PoseWithCovariance pose_with_covariance;
329 pose_with_covariance.pose = getPose(state);
330 std::vector<double> covariance_vector = getPoseCovariance(state);
331 gm::PoseWithCovariance::_covariance_type covariance;
332 std::copy(covariance_vector.begin(), covariance_vector.end(), covariance.begin());
333 pose_with_covariance.covariance = covariance;
334 return pose_with_covariance;
335}

◆ 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 345 of file convenience_state_getters.h.

345 {
346 return getPoseWithCovariance(obj.state);
347}
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 154 of file convenience_state_getters.h.

154 {
155 gm::Point position;
156 position.x = getX(state);
157 position.y = getY(state);
158 position.z = getZ(state);
159 return position;
160}
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 170 of file convenience_state_getters.h.

170 {
171 return getPosition(obj.state);
172}

◆ 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 456 of file convenience_state_getters.h.

456{ 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 466 of file convenience_state_getters.h.

466 {
467 return getRollInDeg(obj.state);
468}
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 355 of file convenience_state_getters.h.

355 {
356 gm::Vector3 velocity;
357 velocity.x = getVelLon(state);
358 velocity.y = getVelLat(state);
359 velocity.z = 0.0;
360 return velocity;
361}
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 371 of file convenience_state_getters.h.

371 {
372 return getVelocity(obj.state);
373}
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 381 of file convenience_state_getters.h.

381 {
382 gm::Vector3 vel = getVelocity(state);
383 using namespace std;
384 return sqrt(pow(vel.x, 2) + pow(vel.y, 2) + pow(vel.z, 2));
385}

◆ 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 395 of file convenience_state_getters.h.

395 {
396 return getVelocityMagnitude(obj.state);
397}
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 579 of file convenience_state_getters.h.

579 {
580 gm::Vector3 vel_lon_lat, vel_xyz;
581 vel_lon_lat = getVelocity(state);
582 tf2::Quaternion q;
583 q.setRPY(0.0, 0.0, getYaw(state));
584 gm::TransformStamped tf;
585 tf.transform.rotation = tf2::toMsg(q);
586 tf2::doTransform(vel_lon_lat, vel_xyz, tf);
587 return vel_xyz;
588}

◆ 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 598 of file convenience_state_getters.h.

598 {
599 return getVelocityXYZ(obj.state);
600}
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 516 of file convenience_state_getters.h.

516 {
517 gm::PoseWithCovariance vel_lon_lat, vel_xyz;
518 vel_lon_lat.pose.position.x = getVelLon(state);
519 vel_lon_lat.pose.position.y = getVelLat(state);
520 vel_lon_lat.pose.position.z = 0.0;
521
522 int ix, jx, n = 2;
523 auto model_id = state.model_id;
524 for (int i = 0; i < n; i++) {
525 for (int j = 0; j < n; j++) {
526 if (i == 0 && hasVelLon(model_id))
527 ix = indexVelLon(model_id);
528 else if (i == 1 && hasVelLat(model_id))
529 ix = indexVelLat(model_id);
530 else
531 continue;
532
533 if (j == 0 && hasVelLon(model_id))
534 jx = indexVelLon(model_id);
535 else if (j == 1 && hasVelLat(model_id))
536 jx = indexVelLat(model_id);
537 else
538 continue;
539
540 vel_lon_lat.covariance.at(6 * i + j) = getContinuousStateCovarianceAt(state, ix, jx);
541 }
542 }
543
544 tf2::Quaternion q;
545 q.setRPY(0.0, 0.0, getYaw(state));
546 gm::TransformStamped tf;
547 tf.transform.rotation = tf2::toMsg(q);
548
549#ifdef ROS1
550 gm::PoseWithCovarianceStamped vel_lon_lat_stamped, vel_xyz_stamped;
551 vel_lon_lat_stamped.pose = vel_lon_lat;
552 tf2::doTransform(vel_lon_lat_stamped, vel_xyz_stamped, tf);
553 vel_xyz = vel_xyz_stamped.pose;
554#else
555 tf2::doTransform(vel_lon_lat, vel_xyz, tf);
556#endif
557
558 return vel_xyz;
559}
int indexVelLon(const unsigned char &model_id)
Get the vector-index that stores the longitudinal velocity for a given model-id.
Definition state_index.h:93
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 569 of file convenience_state_getters.h.

569 {
570 return getVelocityXYZWithCovariance(obj.state);
571}
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 608 of file convenience_state_getters.h.

608{ 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 618 of file convenience_state_getters.h.

618 {
619 return getVelX(obj.state);
620}
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 628 of file convenience_state_getters.h.

628{ 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 638 of file convenience_state_getters.h.

638 {
639 return getVelY(obj.state);
640}
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 496 of file convenience_state_getters.h.

496{ 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 506 of file convenience_state_getters.h.

506 {
507 return getYawInDeg(obj.state);
508}
double getYawInDeg(const ObjectState &state)
Get the yaw in degree of a given object state.