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

423{
424 gm::Vector3 acceleration;
425 acceleration.x = getAccLon(state);
426 acceleration.y = getAccLat(state);
427 acceleration.z = 0.0;
428 return acceleration;
429}
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 439 of file convenience_state_getters.h.

440{
441 return getAcceleration(obj.state);
442}
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 450 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.

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

744{
745 gm::Vector3 acc_lon_lat, acc_xyz;
746 acc_lon_lat = getAcceleration(state);
747 tf2::Quaternion q;
748 q.setRPY(0.0, 0.0, getYaw(state));
749 gm::TransformStamped tf;
750 tf.transform.rotation = tf2::toMsg(q);
751 tf2::doTransform(acc_lon_lat, acc_xyz, tf);
752 return acc_xyz;
753}
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 763 of file convenience_state_getters.h.

764{
765 return getAccelerationXYZ(obj.state);
766}
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 680 of file convenience_state_getters.h.

681{
682 gm::PoseWithCovariance acc_lon_lat, acc_xyz;
683 acc_lon_lat.pose.position.x = getAccLon(state);
684 acc_lon_lat.pose.position.y = getAccLat(state);
685 acc_lon_lat.pose.position.z = 0.0;
686
687 int ix, jx, n = 2;
688 auto model_id = state.model_id;
689 for (int i = 0; i < n; i++) {
690 for (int j = 0; j < n; j++) {
691 if (i == 0 && hasAccLon(model_id))
692 ix = indexAccLon(model_id);
693 else if (i == 1 && hasAccLat(model_id))
694 ix = indexAccLat(model_id);
695 else
696 continue;
697
698 if (j == 0 && hasAccLon(model_id))
699 jx = indexAccLon(model_id);
700 else if (j == 1 && hasAccLat(model_id))
701 jx = indexAccLat(model_id);
702 else
703 continue;
704
705 acc_lon_lat.covariance.at(6 * i + j) = getContinuousStateCovarianceAt(state, ix, jx);
706 }
707 }
708
709 tf2::Quaternion q;
710 q.setRPY(0.0, 0.0, getYaw(state));
711 gm::TransformStamped tf;
712 tf.transform.rotation = tf2::toMsg(q);
713#ifdef ROS1
714 gm::PoseWithCovarianceStamped acc_lon_lat_stamped, acc_xyz_stamped;
715 acc_lon_lat_stamped.pose = acc_lon_lat;
716 tf2::doTransform(acc_lon_lat_stamped, acc_xyz_stamped, tf);
717 acc_xyz = acc_xyz_stamped.pose;
718#else
719 tf2::doTransform(acc_lon_lat, acc_xyz, tf);
720#endif
721 return acc_xyz;
722}
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 732 of file convenience_state_getters.h.

733{
734 return getAccelerationXYZWithCovariance(obj.state);
735}
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 774 of file convenience_state_getters.h.

774{ 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 784 of file convenience_state_getters.h.

785{
786 return getAccX(obj.state);
787}
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 795 of file convenience_state_getters.h.

795{ 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 805 of file convenience_state_getters.h.

806{
807 return getAccY(obj.state);
808}
double getAccY(const ObjectState &state)
Get the y-acceleration of a given object state.

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

819{
820 ObjectClassification highest_prob_class;
821 auto highest_prob_class_it = std::max_element(
822 state.classifications.begin(), state.classifications.end(),
823 [](const ObjectClassification & c1, const ObjectClassification & c2) {
824 return c1.probability < c2.probability;
825 });
826 if (highest_prob_class_it == state.classifications.end()) {
827 highest_prob_class.probability = -1.0;
828 highest_prob_class.type = ObjectClassification::UNKNOWN;
829 } else {
830 highest_prob_class = *highest_prob_class_it;
831 }
832 return highest_prob_class;
833}

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

844{
845 return getClassWithHighestProbability(obj.state);
846}
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 53 of file convenience_state_getters.h.

54{
56 return state.continuous_state;
57}
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 67 of file convenience_state_getters.h.

68{
69 return getContinuousState(obj.state);
70}
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 103 of file convenience_state_getters.h.

104{
106 return state.continuous_state_covariance;
107}

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

118{
119 return getContinuousStateCovariance(obj.state);
120}
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 130 of file convenience_state_getters.h.

132{
133 const int n = getContinuousStateSize(state);
134 const std::vector<double> covariance = getContinuousStateCovariance(state);
135 return covariance[n * i + j];
136}
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 148 of file convenience_state_getters.h.

150{
151 return getContinuousStateCovarianceAt(obj.state, i, j);
152}

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

161{
162 const int n = getContinuousStateSize(state);
163 std::vector<double> diagonal(n);
164 for (int i = 0; i < n; i++) diagonal[i] = getContinuousStateCovarianceAt(state, i, i);
165 return diagonal;
166}

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

177{
178 return getContinuousStateCovarianceDiagonal(obj.state);
179}
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 78 of file convenience_state_getters.h.

79{
81 return state.discrete_state;
82}

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

93{
94 return getDiscreteState(obj.state);
95}
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 218 of file convenience_state_getters.h.

219{
220 tf2::Quaternion q;
221 double roll{0}, pitch{0}, yaw{0};
222 if (hasRoll(state.model_id)) roll = getRoll(state);
223 if (hasPitch(state.model_id)) pitch = getPitch(state);
224 if (hasYaw(state.model_id)) yaw = getYaw(state);
225 q.setRPY(roll, pitch, yaw);
226 return tf2::toMsg(q);
227}
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 237 of file convenience_state_getters.h.

238{
239 return getOrientation(obj.state);
240}
gm::Quaternion getOrientation(const ObjectState &state)
Get the orientation of a given object state.

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

500{ 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 510 of file convenience_state_getters.h.

511{
512 return getPitchInDeg(obj.state);
513}
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 248 of file convenience_state_getters.h.

249{
250 gm::Pose pose;
251 pose.position = getPosition(state);
252 pose.orientation = getOrientation(state);
253 return pose;
254}
gm::Point getPosition(const ObjectState &state)
Get the position of a given object state.

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

265{
266 return getPose(obj.state);
267}
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 275 of file convenience_state_getters.h.

276{
277 const int n = 6;
278 const int model_id = state.model_id;
279 std::vector<double> pose_covariance(n * n, 0.0);
280 int ix, jx;
281 for (int i = 0; i < n; i++) {
282 for (int j = 0; j < n; j++) {
283 if (i == 0 && hasX(model_id))
284 ix = indexX(model_id);
285 else if (i == 1 && hasY(model_id))
286 ix = indexY(model_id);
287 else if (i == 2 && hasZ(model_id))
288 ix = indexZ(model_id);
289 else if (i == 3 && hasRoll(model_id))
290 ix = indexRoll(model_id);
291 else if (i == 4 && hasPitch(model_id))
292 ix = indexPitch(model_id);
293 else if (i == 5 && hasYaw(model_id))
294 ix = indexYaw(model_id);
295 else
296 continue;
297
298 if (j == 0 && hasX(model_id))
299 jx = indexX(model_id);
300 else if (j == 1 && hasY(model_id))
301 jx = indexY(model_id);
302 else if (j == 2 && hasZ(model_id))
303 jx = indexZ(model_id);
304 else if (j == 3 && hasRoll(model_id))
305 jx = indexRoll(model_id);
306 else if (j == 4 && hasPitch(model_id))
307 jx = indexPitch(model_id);
308 else if (j == 5 && hasYaw(model_id))
309 jx = indexYaw(model_id);
310 else
311 continue;
312
313 pose_covariance[n * i + j] = getContinuousStateCovarianceAt(state, ix, jx);
314 }
315 }
316 return pose_covariance;
317}
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 327 of file convenience_state_getters.h.

328{
329 return getPoseCovariance(obj.state);
330}
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 339 of file convenience_state_getters.h.

340{
341 gm::PoseWithCovariance pose_with_covariance;
342 pose_with_covariance.pose = getPose(state);
343 std::vector<double> covariance_vector = getPoseCovariance(state);
344 gm::PoseWithCovariance::_covariance_type covariance;
345 std::copy(covariance_vector.begin(), covariance_vector.end(), covariance.begin());
346 pose_with_covariance.covariance = covariance;
347 return pose_with_covariance;
348}

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

359{
360 return getPoseWithCovariance(obj.state);
361}
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 190 of file convenience_state_getters.h.

191{
192 gm::Point position;
193 position.x = getX(state);
194 position.y = getY(state);
195 position.z = getZ(state);
196 return position;
197}
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 207 of file convenience_state_getters.h.

208{
209 return getPosition(obj.state);
210}

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

479{ 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 489 of file convenience_state_getters.h.

490{
491 return getRollInDeg(obj.state);
492}
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 369 of file convenience_state_getters.h.

370{
371 gm::Vector3 velocity;
372 velocity.x = getVelLon(state);
373 velocity.y = getVelLat(state);
374 velocity.z = 0.0;
375 return velocity;
376}
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 386 of file convenience_state_getters.h.

387{
388 return getVelocity(obj.state);
389}
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 397 of file convenience_state_getters.h.

398{
399 gm::Vector3 vel = getVelocity(state);
400 using namespace std;
401 return sqrt(pow(vel.x, 2) + pow(vel.y, 2) + pow(vel.z, 2));
402}

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

413{
414 return getVelocityMagnitude(obj.state);
415}
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 607 of file convenience_state_getters.h.

608{
609 gm::Vector3 vel_lon_lat, vel_xyz;
610 vel_lon_lat = getVelocity(state);
611 tf2::Quaternion q;
612 q.setRPY(0.0, 0.0, getYaw(state));
613 gm::TransformStamped tf;
614 tf.transform.rotation = tf2::toMsg(q);
615 tf2::doTransform(vel_lon_lat, vel_xyz, tf);
616 return vel_xyz;
617}

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

628{
629 return getVelocityXYZ(obj.state);
630}
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 542 of file convenience_state_getters.h.

543{
544 gm::PoseWithCovariance vel_lon_lat, vel_xyz;
545 vel_lon_lat.pose.position.x = getVelLon(state);
546 vel_lon_lat.pose.position.y = getVelLat(state);
547 vel_lon_lat.pose.position.z = 0.0;
548
549 int ix, jx, n = 2;
550 auto model_id = state.model_id;
551 for (int i = 0; i < n; i++) {
552 for (int j = 0; j < n; j++) {
553 if (i == 0 && hasVelLon(model_id))
554 ix = indexVelLon(model_id);
555 else if (i == 1 && hasVelLat(model_id))
556 ix = indexVelLat(model_id);
557 else
558 continue;
559
560 if (j == 0 && hasVelLon(model_id))
561 jx = indexVelLon(model_id);
562 else if (j == 1 && hasVelLat(model_id))
563 jx = indexVelLat(model_id);
564 else
565 continue;
566
567 vel_lon_lat.covariance.at(6 * i + j) = getContinuousStateCovarianceAt(state, ix, jx);
568 }
569 }
570
571 tf2::Quaternion q;
572 q.setRPY(0.0, 0.0, getYaw(state));
573 gm::TransformStamped tf;
574 tf.transform.rotation = tf2::toMsg(q);
575
576#ifdef ROS1
577 gm::PoseWithCovarianceStamped vel_lon_lat_stamped, vel_xyz_stamped;
578 vel_lon_lat_stamped.pose = vel_lon_lat;
579 tf2::doTransform(vel_lon_lat_stamped, vel_xyz_stamped, tf);
580 vel_xyz = vel_xyz_stamped.pose;
581#else
582 tf2::doTransform(vel_lon_lat, vel_xyz, tf);
583#endif
584
585 return vel_xyz;
586}
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 596 of file convenience_state_getters.h.

597{
598 return getVelocityXYZWithCovariance(obj.state);
599}
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 638 of file convenience_state_getters.h.

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

649{
650 return getVelX(obj.state);
651}
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 659 of file convenience_state_getters.h.

659{ 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 669 of file convenience_state_getters.h.

670{
671 return getVelY(obj.state);
672}
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 521 of file convenience_state_getters.h.

521{ 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 531 of file convenience_state_getters.h.

532{
533 return getYawInDeg(obj.state);
534}
double getYawInDeg(const ObjectState &state)
Get the yaw in degree of a given object state.