perception_interfaces 1.2.0
Loading...
Searching...
No Matches
Functions
convenience_state_setters.hpp File Reference

Convenience setter functions for objects state members. More...

#include <perception_msgs_utils/checks.hpp>
#include <perception_msgs_utils/covariance_transform.hpp>
#include <perception_msgs_utils/state_index.hpp>
#include <perception_msgs_utils/state_setters.hpp>
#include <array>

Go to the source code of this file.

Functions

void perception_msgs::object_access::setContinuousState (ObjectState &state, const std::vector< double > &val)
 Set the continuous state of a given object state.
 
template<typename T >
void perception_msgs::object_access::setContinuousState (T &obj, const std::vector< double > &val)
 Set the continuous state of a given template object that contains an object state.
 
void perception_msgs::object_access::setDiscreteState (ObjectState &state, const std::vector< long int > &val)
 Set the discrete state of a given object state.
 
template<typename T >
void perception_msgs::object_access::setDiscreteState (T &obj, const std::vector< long int > &val)
 Set the discrete state of a given template object that contains an object state.
 
void perception_msgs::object_access::setContinuousStateCovariance (ObjectState &state, const std::vector< double > &val)
 Set the continuous state covariance of a given object state.
 
template<typename T >
void perception_msgs::object_access::setContinuousStateCovariance (T &obj, const std::vector< double > &val)
 Set the continuous state covariance of a given template object that contains an object state.
 
void perception_msgs::object_access::setContinuousStateCovarianceAt (ObjectState &state, const unsigned int i, const unsigned int j, const double val)
 Set the continuous state covariance entry at (i,j) of a given object state.
 
template<typename T >
void perception_msgs::object_access::setContinuousStateCovarianceAt (T &obj, const unsigned int i, const unsigned int j, const double val)
 Set the continuous state covariance at (i,j) of a given template object that contains an object state.
 
void perception_msgs::object_access::setContinuousStateCovarianceDiagonal (ObjectState &state, const std::vector< double > val)
 Set the continuous state covariance diagonal of a given object state.
 
template<typename T >
void perception_msgs::object_access::setContinuousStateCovarianceDiagonal (T &obj, const std::vector< double > val)
 Set the continuous state covariance diagonal of a given template object that contains an object state.
 
void perception_msgs::object_access::setPosition (ObjectState &state, const gm::Point val, const bool reset_covariance=true)
 Set the position of a given object state.
 
template<typename T >
void perception_msgs::object_access::setPosition (T &obj, const gm::Point val, const bool reset_covariance=true)
 Set the position of a given template object that contains an object state.
 
void perception_msgs::object_access::setPosition (ObjectState &state, const std::array< double, 3 > &val, const bool reset_covariance=true)
 Set the position of a given object state.
 
template<typename T >
void perception_msgs::object_access::setPosition (T &obj, const std::array< double, 3 > &val, const bool reset_covariance=true)
 Set the position of a given template object that contains an object state.
 
void perception_msgs::object_access::setOrientation (ObjectState &state, const gm::Quaternion &val, const bool reset_covariance=true)
 Set the orientation of a given object state.
 
template<typename T >
void perception_msgs::object_access::setOrientation (T &obj, const gm::Quaternion &val, const bool reset_covariance=true)
 Set the orientation of a given template object that contains an object state.
 
void perception_msgs::object_access::setOrientation (ObjectState &state, const std::array< double, 3 > &val, const bool reset_covariance=true)
 Set the orientation of a given object state.
 
template<typename T >
void perception_msgs::object_access::setOrientation (T &obj, const std::array< double, 3 > &val, const bool reset_covariance=true)
 Set the orientation of a given template object that contains an object state.
 
void perception_msgs::object_access::setPose (ObjectState &state, const gm::Pose &val, const bool reset_covariance=true)
 Set the pose of a given object state.
 
template<typename T >
void perception_msgs::object_access::setPose (T &obj, const gm::Pose &val, const bool reset_covariance=true)
 Set the pose of a given template object that contains an object state.
 
void perception_msgs::object_access::setPose (ObjectState &state, const std::array< double, 3 > &xyz, const std::array< double, 3 > &rpy, const bool reset_covariance=true)
 Set the pose of a given object state.
 
template<typename T >
void perception_msgs::object_access::setPose (T &obj, const std::array< double, 3 > &xyz, const std::array< double, 3 > &rpy, const bool reset_covariance=true)
 Set the pose of a given template object that contains an object state.
 
void perception_msgs::object_access::setPoseCovariance (ObjectState &state, const gm::PoseWithCovariance::_covariance_type &val)
 Set the pose covariance of a given object state.
 
template<typename T >
void perception_msgs::object_access::setPoseCovariance (T &obj, const gm::PoseWithCovariance::_covariance_type &val)
 Set the pose covariance of a given template object that contains an object state.
 
void perception_msgs::object_access::setPoseWithCovariance (ObjectState &state, const gm::PoseWithCovariance &val)
 Set the pose with covariance of a given object state.
 
template<typename T >
void perception_msgs::object_access::setPoseWithCovariance (T &obj, const gm::PoseWithCovariance &val)
 Set the pose with covariance of a given template object that contains an object state.
 
void perception_msgs::object_access::setVelocity (ObjectState &state, const gm::Vector3 &val, const bool reset_covariance=true)
 Set the velocity of a given object state.
 
template<typename T >
void perception_msgs::object_access::setVelocity (T &obj, const gm::Vector3 &val, const bool reset_covariance=true)
 Set the velocity of a given template object that contains an object state.
 
void perception_msgs::object_access::setVelocity (ObjectState &state, const std::array< double, 2 > &val, const bool reset_covariance=true)
 Set the velocity of a given object state.
 
template<typename T >
void perception_msgs::object_access::setVelocity (T &obj, const std::array< double, 2 > &val, const bool reset_covariance=true)
 Set the velocity of a given template object that contains an object state.
 
void perception_msgs::object_access::setAcceleration (ObjectState &state, const gm::Vector3 &val, const bool reset_covariance=true)
 Set the acceleration of a given object state.
 
template<typename T >
void perception_msgs::object_access::setAcceleration (T &obj, const gm::Vector3 &val, const bool reset_covariance=true)
 Set the acceleration of a given template object that contains an object state.
 
void perception_msgs::object_access::setAcceleration (ObjectState &state, const std::array< double, 2 > &val, const bool reset_covariance=true)
 Set the acceleration of a given object state.
 
template<typename T >
void perception_msgs::object_access::setAcceleration (T &obj, const std::array< double, 2 > &val, const bool reset_covariance=true)
 Set the acceleration of a given template object that contains an object state.
 
void perception_msgs::object_access::setRollInDeg (ObjectState &state, const double val, const bool reset_covariance=true)
 Set the roll in degree of a given object state.
 
template<typename T >
void perception_msgs::object_access::setRollInDeg (T &obj, const double val, const bool reset_covariance=true)
 Set the roll in deg of a given template object that contains an object state.
 
void perception_msgs::object_access::setPitchInDeg (ObjectState &state, const double val, const bool reset_covariance=true)
 Set the pitch in degree of a given object state.
 
template<typename T >
void perception_msgs::object_access::setPitchInDeg (T &obj, const double val, const bool reset_covariance=true)
 Set the pitch in degree of a given template object that contains an object state.
 
void perception_msgs::object_access::setYawInDeg (ObjectState &state, const double val, const bool reset_covariance=true)
 Set the yaw in degree of a given object state.
 
template<typename T >
void perception_msgs::object_access::setYawInDeg (T &obj, const double val, const bool reset_covariance=true)
 Set the yaw in degree of a given template object that contains an object state.
 
void perception_msgs::object_access::setVelocityXYZYawWithCovariance (ObjectState &state, const gm::Vector3 &vel_xyz_in, const double yaw, const double var_vel_x, const double var_vel_y, const double cov_vel_xy)
 Set the velocity XYZ and yaw with covariance of a given object state.
 
template<typename T >
void perception_msgs::object_access::setVelocityXYZYawWithCovariance (T &obj, const gm::Vector3 &vel_xyz_in, const double yaw, const double var_vel_x, const double var_vel_y, const double cov_vel_xy)
 Set the velocity XYZ and yaw with covariance of a given template object that contains an object state.
 
void perception_msgs::object_access::setVelocityXYZYaw (ObjectState &state, const gm::Vector3 &vel_xyz, const double yaw, const bool reset_covariance=true)
 Set the velocity XYZ and yaw of a given object state.
 
template<typename T >
void perception_msgs::object_access::setVelocityXYZYaw (T &obj, const gm::Vector3 &vel_xyz, const double yaw, const bool reset_covariance=true)
 Set the velocity XYZ and yaw of a given template object that contains an object state.
 
void perception_msgs::object_access::setAccelerationXYZYawWithCovariance (ObjectState &state, const gm::Vector3 &acc_xyz_in, const double yaw, const double var_acc_x, const double var_acc_y, const double cov_acc_xy)
 Set the acceleration XYZ and yaw with covariance of a given object state.
 
template<typename T >
void perception_msgs::object_access::setAccelerationXYZYawWithCovariance (T &obj, const gm::Vector3 &acc_xyz_in, const double yaw, const double var_acc_x, const double var_acc_y, const double cov_acc_xy)
 Set the acceleration XYZ and yaw with covariance of a given template object that contains an object state.
 
void perception_msgs::object_access::setAccelerationXYZYaw (ObjectState &state, const gm::Vector3 &acc_xyz, const double yaw, const bool reset_covariance=true)
 Set the acceleration XYZ and yaw of a given template object that contains an object state.
 
template<typename T >
void perception_msgs::object_access::setAccelerationXYZYaw (T &obj, const gm::Vector3 &acc_xyz, const double yaw, const bool reset_covariance=true)
 Set the acceleration XYZ and yaw of a given template object that contains an object state.
 

Detailed Description

Convenience setter functions for objects state members.

Definition in file convenience_state_setters.hpp.

Function Documentation

◆ setAcceleration() [1/4]

void perception_msgs::object_access::setAcceleration ( ObjectState &  state,
const gm::Vector3 &  val,
const bool  reset_covariance = true 
)
inline

Set the acceleration of a given object state.

Parameters
state
val
reset_covariance

Definition at line 479 of file convenience_state_setters.hpp.

480{
481 setAccLon(state, val.x, reset_covariance);
482 setAccLat(state, val.y, reset_covariance);
483}
void setAccLat(ObjectState &state, const double val, const bool reset_covariance=true)
Set the lateral acceleration for a given object state.
void setAccLon(ObjectState &state, const double val, const bool reset_covariance=true)
Set the longitudinal acceleration for a given object state.

◆ setAcceleration() [2/4]

void perception_msgs::object_access::setAcceleration ( ObjectState &  state,
const std::array< double, 2 > &  val,
const bool  reset_covariance = true 
)
inline

Set the acceleration of a given object state.

Parameters
state
val
reset_covariance

Definition at line 506 of file convenience_state_setters.hpp.

507{
508 setAccLon(state, val[0], reset_covariance);
509 setAccLat(state, val[1], reset_covariance);
510}

◆ setAcceleration() [3/4]

template<typename T >
void perception_msgs::object_access::setAcceleration ( T &  obj,
const gm::Vector3 &  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 494 of file convenience_state_setters.hpp.

495{
496 setAcceleration(obj.state, val, reset_covariance);
497}
void setAcceleration(ObjectState &state, const gm::Vector3 &val, const bool reset_covariance=true)
Set the acceleration of a given object state.

◆ setAcceleration() [4/4]

template<typename T >
void perception_msgs::object_access::setAcceleration ( T &  obj,
const std::array< double, 2 > &  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 521 of file convenience_state_setters.hpp.

522{
523 setAcceleration(obj.state, val, reset_covariance);
524}

◆ setAccelerationXYZYaw() [1/2]

void perception_msgs::object_access::setAccelerationXYZYaw ( ObjectState &  state,
const gm::Vector3 &  acc_xyz,
const double  yaw,
const bool  reset_covariance = true 
)
inline

Set the acceleration XYZ and yaw of a given template object that contains an object state.

Parameters
state
acc_xyz
yaw
reset_covariance

Definition at line 808 of file convenience_state_setters.hpp.

810{
811 gm::Vector3 acc_lon_lat, acc_xyz_in;
812 acc_xyz_in = acc_xyz;
813 tf2::Quaternion q;
814 q.setRPY(0.0, 0.0, -yaw);
815 gm::TransformStamped tf;
816 tf.transform.rotation = tf2::toMsg(q);
817 tf2::doTransform(acc_xyz_in, acc_lon_lat, tf);
818 setAcceleration(state, acc_lon_lat, reset_covariance);
819 setYaw(state, yaw, reset_covariance);
820}
void setYaw(ObjectState &state, const double val, const bool reset_covariance=true)
Set the yaw for a given object state.

◆ setAccelerationXYZYaw() [2/2]

template<typename T >
void perception_msgs::object_access::setAccelerationXYZYaw ( T &  obj,
const gm::Vector3 &  acc_xyz,
const double  yaw,
const bool  reset_covariance = true 
)
inline

Set the acceleration XYZ and yaw of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
acc_xyz
yaw
reset_covariance

Definition at line 832 of file convenience_state_setters.hpp.

833{
834 setAccelerationXYZYaw(obj.state, acc_xyz, yaw, reset_covariance);
835}
void setAccelerationXYZYaw(ObjectState &state, const gm::Vector3 &acc_xyz, const double yaw, const bool reset_covariance=true)
Set the acceleration XYZ and yaw of a given template object that contains an object state.

◆ setAccelerationXYZYawWithCovariance() [1/2]

void perception_msgs::object_access::setAccelerationXYZYawWithCovariance ( ObjectState &  state,
const gm::Vector3 &  acc_xyz_in,
const double  yaw,
const double  var_acc_x,
const double  var_acc_y,
const double  cov_acc_xy 
)
inline

Set the acceleration XYZ and yaw with covariance of a given object state.

Parameters
state
acc_xyz_in
yaw
var_acc_x
var_acc_y
cov_acc_xy

Definition at line 731 of file convenience_state_setters.hpp.

734{
735 gm::PoseWithCovariance acc_lon_lat, acc_xyz;
736 acc_xyz.pose.position.x = acc_xyz_in.x;
737 acc_xyz.pose.position.y = acc_xyz_in.y;
738 acc_xyz.pose.position.z = 0.0;
739
740 acc_xyz.covariance.at(0) = var_acc_x;
741 acc_xyz.covariance.at(1) = cov_acc_xy;
742 acc_xyz.covariance.at(6) = cov_acc_xy;
743 acc_xyz.covariance.at(7) = var_acc_y;
744
745 tf2::Quaternion q;
746 q.setRPY(0.0, 0.0, -yaw);
747 gm::TransformStamped tf;
748 tf.transform.rotation = tf2::toMsg(q);
749
750 gm::PoseWithCovarianceStamped acc_lon_lat_stamped, acc_xyz_stamped;
751 acc_xyz_stamped.pose = acc_xyz;
752 transformPoseWithCovariance(acc_xyz_stamped, acc_lon_lat_stamped, tf);
753 acc_lon_lat = acc_lon_lat_stamped.pose;
754
755 setAcceleration(state, {acc_lon_lat.pose.position.x, acc_lon_lat.pose.position.y}, false);
756 setYaw(state, yaw, false);
757
758 int ix, jx, n = 2;
759 auto model_id = state.model_id;
760 for (int i = 0; i < n; i++) {
761 for (int j = 0; j < n; j++) {
762 if (i == 0 && hasAccLon(model_id))
763 ix = indexAccLon(model_id);
764 else if (i == 1 && hasAccLat(model_id))
765 ix = indexAccLat(model_id);
766 else
767 continue;
768
769 if (j == 0 && hasAccLon(model_id))
770 jx = indexAccLon(model_id);
771 else if (j == 1 && hasAccLat(model_id))
772 jx = indexAccLat(model_id);
773 else
774 continue;
775
776 setContinuousStateCovarianceAt(state, ix, jx, acc_lon_lat.covariance.at(6 * i + j));
777 }
778 }
779}
void setContinuousStateCovarianceAt(ObjectState &state, const unsigned int i, const unsigned int j, const double val)
Set the continuous state covariance entry at (i,j) of 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.

◆ setAccelerationXYZYawWithCovariance() [2/2]

template<typename T >
void perception_msgs::object_access::setAccelerationXYZYawWithCovariance ( T &  obj,
const gm::Vector3 &  acc_xyz_in,
const double  yaw,
const double  var_acc_x,
const double  var_acc_y,
const double  cov_acc_xy 
)
inline

Set the acceleration XYZ and yaw with covariance of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
acc_xyz_in
yaw
var_acc_x
var_acc_y
cov_acc_xy

Definition at line 793 of file convenience_state_setters.hpp.

796{
797 return setAccelerationXYZYawWithCovariance(obj.state, acc_xyz_in, yaw, var_acc_x, var_acc_y, cov_acc_xy);
798}
void setAccelerationXYZYawWithCovariance(ObjectState &state, const gm::Vector3 &acc_xyz_in, const double yaw, const double var_acc_x, const double var_acc_y, const double cov_acc_xy)
Set the acceleration XYZ and yaw with covariance of a given object state.

◆ setContinuousState() [1/2]

void perception_msgs::object_access::setContinuousState ( ObjectState &  state,
const std::vector< double > &  val 
)
inline

Set the continuous state of a given object state.

Parameters
state
val

Definition at line 32 of file convenience_state_setters.hpp.

33{
34 state.continuous_state = val;
36}
void sanityCheckContinuousState(const ObjectState &state)
Perform sanity check on continuous state of given object state.
Definition checks.hpp:63

◆ setContinuousState() [2/2]

template<typename T >
void perception_msgs::object_access::setContinuousState ( T &  obj,
const std::vector< double > &  val 
)
inline

Set the continuous state of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
val

Definition at line 46 of file convenience_state_setters.hpp.

47{
48 setContinuousState(obj.state, val);
49}
void setContinuousState(ObjectState &state, const std::vector< double > &val)
Set the continuous state of a given object state.

◆ setContinuousStateCovariance() [1/2]

void perception_msgs::object_access::setContinuousStateCovariance ( ObjectState &  state,
const std::vector< double > &  val 
)
inline

Set the continuous state covariance of a given object state.

Parameters
state
val

Definition at line 82 of file convenience_state_setters.hpp.

83{
84 state.continuous_state_covariance = val;
86}
void sanityCheckContinuousStateCovariance(const ObjectState &state)
Perform sanity check on continuous state covariance of given object state.
Definition checks.hpp:103

◆ setContinuousStateCovariance() [2/2]

template<typename T >
void perception_msgs::object_access::setContinuousStateCovariance ( T &  obj,
const std::vector< double > &  val 
)
inline

Set the continuous state covariance of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
val

Definition at line 96 of file convenience_state_setters.hpp.

97{
98 setContinuousStateCovariance(obj.state, val);
99}
void setContinuousStateCovariance(ObjectState &state, const std::vector< double > &val)
Set the continuous state covariance of a given object state.

◆ setContinuousStateCovarianceAt() [1/2]

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

Set the continuous state covariance entry at (i,j) of a given object state.

Parameters
state
i
j
val

Definition at line 109 of file convenience_state_setters.hpp.

111{
113 const int n = getContinuousStateSize(state);
114 if (i >= static_cast<unsigned int>(n) || j >= static_cast<unsigned int>(n))
115 throw std::out_of_range("Covariance coordinates out of range");
116 if (state.continuous_state_covariance.empty()) {
117 setContinuousStateCovariance(state, std::vector<double>(n * n, CONTINUOUS_STATE_COVARIANCE_INIT));
118 for (int k = 0; k < n; ++k)
119 state.continuous_state_covariance[n * k + k] = CONTINUOUS_STATE_COVARIANCE_INVALID;
120 }
121 state.continuous_state_covariance.at(n * i + j) = val;
122}
int getContinuousStateSize(const ObjectState &state)
Get the continuous state size for a given object state.
Definition utils.hpp:30

◆ setContinuousStateCovarianceAt() [2/2]

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

Set the continuous state covariance at (i,j) of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
i
j
val

Definition at line 134 of file convenience_state_setters.hpp.

136{
137 setContinuousStateCovarianceAt(obj.state, i, j, val);
138}

◆ setContinuousStateCovarianceDiagonal() [1/2]

void perception_msgs::object_access::setContinuousStateCovarianceDiagonal ( ObjectState &  state,
const std::vector< double >  val 
)
inline

Set the continuous state covariance diagonal of a given object state.

Parameters
state
val

Definition at line 146 of file convenience_state_setters.hpp.

147{
148 const int n = getContinuousStateSize(state);
149 for (int i = 0; i < n; i++) setContinuousStateCovarianceAt(state, i, i, val[i]);
150}

◆ setContinuousStateCovarianceDiagonal() [2/2]

template<typename T >
void perception_msgs::object_access::setContinuousStateCovarianceDiagonal ( T &  obj,
const std::vector< double >  val 
)
inline

Set the continuous state covariance diagonal of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
val

Definition at line 160 of file convenience_state_setters.hpp.

161{
163}
void setContinuousStateCovarianceDiagonal(ObjectState &state, const std::vector< double > val)
Set the continuous state covariance diagonal of a given object state.

◆ setDiscreteState() [1/2]

void perception_msgs::object_access::setDiscreteState ( ObjectState &  state,
const std::vector< long int > &  val 
)
inline

Set the discrete state of a given object state.

Parameters
state
val

Definition at line 57 of file convenience_state_setters.hpp.

58{
59 state.discrete_state = val;
61}
void sanityCheckDiscreteState(const ObjectState &state)
Perform sanity check on discrete state of given object state.
Definition checks.hpp:83

◆ setDiscreteState() [2/2]

template<typename T >
void perception_msgs::object_access::setDiscreteState ( T &  obj,
const std::vector< long int > &  val 
)
inline

Set the discrete state of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
val

Definition at line 71 of file convenience_state_setters.hpp.

72{
73 setDiscreteState(obj.state, val);
74}
void setDiscreteState(ObjectState &state, const std::vector< long int > &val)
Set the discrete state of a given object state.

◆ setOrientation() [1/4]

void perception_msgs::object_access::setOrientation ( ObjectState &  state,
const gm::Quaternion &  val,
const bool  reset_covariance = true 
)
inline

Set the orientation of a given object state.

Parameters
state
val
reset_covariance

Definition at line 230 of file convenience_state_setters.hpp.

231{
232 tf2::Quaternion q;
233 tf2::fromMsg(val, q);
234 double roll, pitch, yaw;
235 tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);
236 if (hasRoll(state.model_id)) setRoll(state, roll, reset_covariance);
237 if (hasPitch(state.model_id)) setPitch(state, pitch, reset_covariance);
238 if (hasYaw(state.model_id)) setYaw(state, yaw, reset_covariance);
239}
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.
void setRoll(ObjectState &state, const double val, const bool reset_covariance=true)
Set the roll for a given object state.
void setPitch(ObjectState &state, const double val, const bool reset_covariance=true)
Set the pitch for a given object state.

◆ setOrientation() [2/4]

void perception_msgs::object_access::setOrientation ( ObjectState &  state,
const std::array< double, 3 > &  val,
const bool  reset_covariance = true 
)
inline

Set the orientation of a given object state.

Parameters
state
val
reset_covariance

Definition at line 262 of file convenience_state_setters.hpp.

263{
264 if (hasRoll(state.model_id)) setRoll(state, val[0], reset_covariance);
265 if (hasPitch(state.model_id)) setPitch(state, val[1], reset_covariance);
266 if (hasYaw(state.model_id)) setYaw(state, val[2], reset_covariance);
267}

◆ setOrientation() [3/4]

template<typename T >
void perception_msgs::object_access::setOrientation ( T &  obj,
const gm::Quaternion &  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 250 of file convenience_state_setters.hpp.

251{
252 setOrientation(obj.state, val, reset_covariance);
253}
void setOrientation(ObjectState &state, const gm::Quaternion &val, const bool reset_covariance=true)
Set the orientation of a given object state.

◆ setOrientation() [4/4]

template<typename T >
void perception_msgs::object_access::setOrientation ( T &  obj,
const std::array< double, 3 > &  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 278 of file convenience_state_setters.hpp.

279{
280 setOrientation(obj.state, val, reset_covariance);
281}

◆ setPitchInDeg() [1/2]

void perception_msgs::object_access::setPitchInDeg ( ObjectState &  state,
const double  val,
const bool  reset_covariance = true 
)
inline

Set the pitch in degree of a given object state.

Parameters
state
val
reset_covariance

Definition at line 561 of file convenience_state_setters.hpp.

562{
563 setPitch(state, val * M_PI / 180.0, reset_covariance);
564}

◆ setPitchInDeg() [2/2]

template<typename T >
void perception_msgs::object_access::setPitchInDeg ( T &  obj,
const double  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 575 of file convenience_state_setters.hpp.

576{
577 setPitchInDeg(obj.state, val, reset_covariance);
578}
void setPitchInDeg(ObjectState &state, const double val, const bool reset_covariance=true)
Set the pitch in degree of a given object state.

◆ setPose() [1/4]

void perception_msgs::object_access::setPose ( ObjectState &  state,
const gm::Pose &  val,
const bool  reset_covariance = true 
)
inline

Set the pose of a given object state.

Parameters
state
val
reset_covariance

Definition at line 290 of file convenience_state_setters.hpp.

291{
292 setPosition(state, val.position, reset_covariance);
293 setOrientation(state, val.orientation, reset_covariance);
294}
void setPosition(ObjectState &state, const gm::Point val, const bool reset_covariance=true)
Set the position of a given object state.

◆ setPose() [2/4]

void perception_msgs::object_access::setPose ( ObjectState &  state,
const std::array< double, 3 > &  xyz,
const std::array< double, 3 > &  rpy,
const bool  reset_covariance = true 
)
inline

Set the pose of a given object state.

Parameters
state
xyz
rpy
reset_covariance

Definition at line 318 of file convenience_state_setters.hpp.

320{
321 setPosition(state, xyz, reset_covariance);
322 setOrientation(state, rpy, reset_covariance);
323}

◆ setPose() [3/4]

template<typename T >
void perception_msgs::object_access::setPose ( T &  obj,
const gm::Pose &  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 305 of file convenience_state_setters.hpp.

306{
307 setPose(obj.state, val, reset_covariance);
308}
void setPose(ObjectState &state, const gm::Pose &val, const bool reset_covariance=true)
Set the pose of a given object state.

◆ setPose() [4/4]

template<typename T >
void perception_msgs::object_access::setPose ( T &  obj,
const std::array< double, 3 > &  xyz,
const std::array< double, 3 > &  rpy,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
xyz
rpy
reset_covariance

Definition at line 335 of file convenience_state_setters.hpp.

336{
337 setPose(obj.state, xyz, rpy, reset_covariance);
338}

◆ setPoseCovariance() [1/2]

void perception_msgs::object_access::setPoseCovariance ( ObjectState &  state,
const gm::PoseWithCovariance::_covariance_type &  val 
)
inline

Set the pose covariance of a given object state.

Parameters
state
val

Definition at line 346 of file convenience_state_setters.hpp.

348{
349 const int n = 6;
350 const int model_id = state.model_id;
351
352 int ix, jx;
353 for (int i = 0; i < n; i++) {
354 bool i_valid = true;
355 switch (i) {
356 case 0: i_valid = hasX(model_id); ix = i_valid ? indexX(model_id) : 0; break;
357 case 1: i_valid = hasY(model_id); ix = i_valid ? indexY(model_id) : 0; break;
358 case 2: i_valid = hasZ(model_id); ix = i_valid ? indexZ(model_id) : 0; break;
359 case 3: i_valid = hasRoll(model_id); ix = i_valid ? indexRoll(model_id) : 0; break;
360 case 4: i_valid = hasPitch(model_id); ix = i_valid ? indexPitch(model_id) : 0; break;
361 case 5: i_valid = hasYaw(model_id); ix = i_valid ? indexYaw(model_id) : 0; break;
362 }
363 if (!i_valid) continue;
364
365 for (int j = 0; j < n; j++) {
366 bool j_valid = true;
367 switch (j) {
368 case 0: j_valid = hasX(model_id); jx = j_valid ? indexX(model_id) : 0; break;
369 case 1: j_valid = hasY(model_id); jx = j_valid ? indexY(model_id) : 0; break;
370 case 2: j_valid = hasZ(model_id); jx = j_valid ? indexZ(model_id) : 0; break;
371 case 3: j_valid = hasRoll(model_id); jx = j_valid ? indexRoll(model_id) : 0; break;
372 case 4: j_valid = hasPitch(model_id); jx = j_valid ? indexPitch(model_id) : 0; break;
373 case 5: j_valid = hasYaw(model_id); jx = j_valid ? indexYaw(model_id) : 0; break;
374 }
375 if (!j_valid) continue;
376
377 setContinuousStateCovarianceAt(state, ix, jx, val[n * i + j]);
378 }
379 }
380}
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.
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.
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.
int indexYaw(const unsigned char &model_id)
Get the vector-index that stores the yaw for a given model-id.

◆ setPoseCovariance() [2/2]

template<typename T >
void perception_msgs::object_access::setPoseCovariance ( T &  obj,
const gm::PoseWithCovariance::_covariance_type &  val 
)
inline

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

Template Parameters
T
Parameters
obj
val

Definition at line 389 of file convenience_state_setters.hpp.

390{
391 setPoseCovariance(obj.state, val);
392}
void setPoseCovariance(ObjectState &state, const gm::PoseWithCovariance::_covariance_type &val)
Set the pose covariance of a given object state.

◆ setPoseWithCovariance() [1/2]

void perception_msgs::object_access::setPoseWithCovariance ( ObjectState &  state,
const gm::PoseWithCovariance &  val 
)
inline

Set the pose with covariance of a given object state.

Parameters
state
val

Definition at line 400 of file convenience_state_setters.hpp.

401{
402 setPose(state, val.pose, false);
403 setPoseCovariance(state, val.covariance);
404}

◆ setPoseWithCovariance() [2/2]

template<typename T >
void perception_msgs::object_access::setPoseWithCovariance ( T &  obj,
const gm::PoseWithCovariance &  val 
)
inline

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

Template Parameters
T
Parameters
obj
val

Definition at line 414 of file convenience_state_setters.hpp.

415{
416 setPoseWithCovariance(obj.state, val);
417}
void setPoseWithCovariance(ObjectState &state, const gm::PoseWithCovariance &val)
Set the pose with covariance of a given object state.

◆ setPosition() [1/4]

void perception_msgs::object_access::setPosition ( ObjectState &  state,
const gm::Point  val,
const bool  reset_covariance = true 
)
inline

Set the position of a given object state.

Parameters
state
val
reset_covariance

Definition at line 174 of file convenience_state_setters.hpp.

175{
176 setX(state, val.x, reset_covariance);
177 setY(state, val.y, reset_covariance);
178 setZ(state, val.z, reset_covariance);
179}
void setX(ObjectState &state, const double val, const bool reset_covariance=true)
Set the x-position for a given object state.
void setY(ObjectState &state, const double val, const bool reset_covariance=true)
Set the y-position for a given object state.
void setZ(ObjectState &state, const double val, const bool reset_covariance=true)
Set the z-position for a given object state.

◆ setPosition() [2/4]

void perception_msgs::object_access::setPosition ( ObjectState &  state,
const std::array< double, 3 > &  val,
const bool  reset_covariance = true 
)
inline

Set the position of a given object state.

Parameters
state
val
reset_covariance

Definition at line 202 of file convenience_state_setters.hpp.

203{
204 setX(state, val[0], reset_covariance);
205 setY(state, val[1], reset_covariance);
206 setZ(state, val[2], reset_covariance);
207}

◆ setPosition() [3/4]

template<typename T >
void perception_msgs::object_access::setPosition ( T &  obj,
const gm::Point  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 190 of file convenience_state_setters.hpp.

191{
192 setPosition(obj.state, val, reset_covariance);
193}

◆ setPosition() [4/4]

template<typename T >
void perception_msgs::object_access::setPosition ( T &  obj,
const std::array< double, 3 > &  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 218 of file convenience_state_setters.hpp.

219{
220 setPosition(obj.state, val, reset_covariance);
221}

◆ setRollInDeg() [1/2]

void perception_msgs::object_access::setRollInDeg ( ObjectState &  state,
const double  val,
const bool  reset_covariance = true 
)
inline

Set the roll in degree of a given object state.

Parameters
state
val
reset_covariance

Definition at line 535 of file convenience_state_setters.hpp.

536{
537 setRoll(state, val * M_PI / 180.0, reset_covariance);
538}

◆ setRollInDeg() [2/2]

template<typename T >
void perception_msgs::object_access::setRollInDeg ( T &  obj,
const double  val,
const bool  reset_covariance = true 
)
inline

Set the roll in deg of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 549 of file convenience_state_setters.hpp.

550{
551 setRollInDeg(obj.state, val, reset_covariance);
552}
void setRollInDeg(ObjectState &state, const double val, const bool reset_covariance=true)
Set the roll in degree of a given object state.

◆ setVelocity() [1/4]

void perception_msgs::object_access::setVelocity ( ObjectState &  state,
const gm::Vector3 &  val,
const bool  reset_covariance = true 
)
inline

Set the velocity of a given object state.

Parameters
state
val
reset_covariance

Definition at line 426 of file convenience_state_setters.hpp.

427{
428 setVelLon(state, val.x, reset_covariance);
429 setVelLat(state, val.y, reset_covariance);
430}
void setVelLon(ObjectState &state, const double val, const bool reset_covariance=true)
Set the longitdunial velocity for a given object state.
void setVelLat(ObjectState &state, const double val, const bool reset_covariance=true)
Set the lateral velocity for a given object state.

◆ setVelocity() [2/4]

void perception_msgs::object_access::setVelocity ( ObjectState &  state,
const std::array< double, 2 > &  val,
const bool  reset_covariance = true 
)
inline

Set the velocity of a given object state.

Parameters
state
val
reset_covariance

Definition at line 452 of file convenience_state_setters.hpp.

453{
454 setVelLon(state, val[0], reset_covariance);
455 setVelLat(state, val[1], reset_covariance);
456}

◆ setVelocity() [3/4]

template<typename T >
void perception_msgs::object_access::setVelocity ( T &  obj,
const gm::Vector3 &  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 440 of file convenience_state_setters.hpp.

441{
442 setVelocity(obj.state, val, reset_covariance);
443}
void setVelocity(ObjectState &state, const gm::Vector3 &val, const bool reset_covariance=true)
Set the velocity of a given object state.

◆ setVelocity() [4/4]

template<typename T >
void perception_msgs::object_access::setVelocity ( T &  obj,
const std::array< double, 2 > &  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 467 of file convenience_state_setters.hpp.

468{
469 setVelocity(obj.state, val, reset_covariance);
470}

◆ setVelocityXYZYaw() [1/2]

void perception_msgs::object_access::setVelocityXYZYaw ( ObjectState &  state,
const gm::Vector3 &  vel_xyz,
const double  yaw,
const bool  reset_covariance = true 
)
inline

Set the velocity XYZ and yaw of a given object state.

Parameters
state
vel_xyz
yaw
reset_covariance

Definition at line 693 of file convenience_state_setters.hpp.

694{
695 gm::Vector3 vel_lon_lat, vel_xyz_in;
696 vel_xyz_in = vel_xyz;
697 tf2::Quaternion q;
698 q.setRPY(0.0, 0.0, -yaw);
699 gm::TransformStamped tf;
700 tf.transform.rotation = tf2::toMsg(q);
701 tf2::doTransform(vel_xyz_in, vel_lon_lat, tf);
702 setVelocity(state, vel_lon_lat, reset_covariance);
703 setYaw(state, yaw, reset_covariance);
704}

◆ setVelocityXYZYaw() [2/2]

template<typename T >
void perception_msgs::object_access::setVelocityXYZYaw ( T &  obj,
const gm::Vector3 &  vel_xyz,
const double  yaw,
const bool  reset_covariance = true 
)
inline

Set the velocity XYZ and yaw of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
vel_xyz
yaw
reset_covariance

Definition at line 716 of file convenience_state_setters.hpp.

717{
718 setVelocityXYZYaw(obj.state, vel_xyz, yaw, reset_covariance);
719}
void setVelocityXYZYaw(ObjectState &state, const gm::Vector3 &vel_xyz, const double yaw, const bool reset_covariance=true)
Set the velocity XYZ and yaw of a given object state.

◆ setVelocityXYZYawWithCovariance() [1/2]

void perception_msgs::object_access::setVelocityXYZYawWithCovariance ( ObjectState &  state,
const gm::Vector3 &  vel_xyz_in,
const double  yaw,
const double  var_vel_x,
const double  var_vel_y,
const double  cov_vel_xy 
)
inline

Set the velocity XYZ and yaw with covariance of a given object state.

Parameters
state
vel_xyz_in
yaw
var_vel_x
var_vel_y
cov_vel_xy

Definition at line 616 of file convenience_state_setters.hpp.

619{
620 gm::PoseWithCovariance vel_lon_lat, vel_xyz;
621 vel_xyz.pose.position.x = vel_xyz_in.x;
622 vel_xyz.pose.position.y = vel_xyz_in.y;
623 vel_xyz.pose.position.z = 0.0;
624
625 vel_xyz.covariance.at(0) = var_vel_x;
626 vel_xyz.covariance.at(1) = cov_vel_xy;
627 vel_xyz.covariance.at(6) = cov_vel_xy;
628 vel_xyz.covariance.at(7) = var_vel_y;
629
630 tf2::Quaternion q;
631 q.setRPY(0.0, 0.0, -yaw);
632 gm::TransformStamped tf;
633 tf.transform.rotation = tf2::toMsg(q);
634
635 gm::PoseWithCovarianceStamped vel_lon_lat_stamped, vel_xyz_stamped;
636 vel_xyz_stamped.pose = vel_xyz;
637 transformPoseWithCovariance(vel_xyz_stamped, vel_lon_lat_stamped, tf);
638 vel_lon_lat = vel_lon_lat_stamped.pose;
639
640 setVelocity(state, {vel_lon_lat.pose.position.x, vel_lon_lat.pose.position.y}, false);
641 setYaw(state, yaw, false);
642
643 int ix, jx, n = 2;
644 auto model_id = state.model_id;
645 for (int i = 0; i < n; i++) {
646 for (int j = 0; j < n; j++) {
647 if (i == 0 && hasVelLon(model_id))
648 ix = indexVelLon(model_id);
649 else if (i == 1 && hasVelLat(model_id))
650 ix = indexVelLat(model_id);
651 else
652 continue;
653
654 if (j == 0 && hasVelLon(model_id))
655 jx = indexVelLon(model_id);
656 else if (j == 1 && hasVelLat(model_id))
657 jx = indexVelLat(model_id);
658 else
659 continue;
660
661 setContinuousStateCovarianceAt(state, ix, jx, vel_lon_lat.covariance.at(6 * i + j));
662 }
663 }
664}
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.

◆ setVelocityXYZYawWithCovariance() [2/2]

template<typename T >
void perception_msgs::object_access::setVelocityXYZYawWithCovariance ( T &  obj,
const gm::Vector3 &  vel_xyz_in,
const double  yaw,
const double  var_vel_x,
const double  var_vel_y,
const double  cov_vel_xy 
)
inline

Set the velocity XYZ and yaw with covariance of a given template object that contains an object state.

Template Parameters
T
Parameters
obj
vel_xyz_in
yaw
var_vel_x
var_vel_y
cov_vel_xy

Definition at line 678 of file convenience_state_setters.hpp.

681{
682 return setVelocityXYZYawWithCovariance(obj.state, vel_xyz_in, yaw, var_vel_x, var_vel_y, cov_vel_xy);
683}
void setVelocityXYZYawWithCovariance(ObjectState &state, const gm::Vector3 &vel_xyz_in, const double yaw, const double var_vel_x, const double var_vel_y, const double cov_vel_xy)
Set the velocity XYZ and yaw with covariance of a given object state.

◆ setYawInDeg() [1/2]

void perception_msgs::object_access::setYawInDeg ( ObjectState &  state,
const double  val,
const bool  reset_covariance = true 
)
inline

Set the yaw in degree of a given object state.

Parameters
state
val
reset_covariance

Definition at line 587 of file convenience_state_setters.hpp.

588{
589 setYaw(state, val * M_PI / 180.0, reset_covariance);
590}

◆ setYawInDeg() [2/2]

template<typename T >
void perception_msgs::object_access::setYawInDeg ( T &  obj,
const double  val,
const bool  reset_covariance = true 
)
inline

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

Template Parameters
T
Parameters
obj
val
reset_covariance

Definition at line 601 of file convenience_state_setters.hpp.

602{
603 setYawInDeg(obj.state, val, reset_covariance);
604}
void setYawInDeg(ObjectState &state, const double val, const bool reset_covariance=true)
Set the yaw in degree of a given object state.