39namespace perception_msgs
42namespace object_access
56 return state.continuous_state;
81 return state.discrete_state;
106 return state.continuous_state_covariance;
131 const ObjectState & state,
const unsigned int i,
const unsigned int j)
135 return covariance[n * i + j];
149 const T & obj,
const unsigned int i,
const unsigned int j)
163 std::vector<double> diagonal(n);
193 position.x =
getX(state);
194 position.y =
getY(state);
195 position.z =
getZ(state);
221 double roll{0}, pitch{0}, yaw{0};
225 q.setRPY(roll, pitch, yaw);
226 return tf2::toMsg(q);
248inline gm::Pose
getPose(
const ObjectState & state)
278 const int model_id = state.model_id;
279 std::vector<double> pose_covariance(n * n, 0.0);
281 for (
int i = 0; i < n; i++) {
282 for (
int j = 0; j < n; j++) {
283 if (i == 0 &&
hasX(model_id))
285 else if (i == 1 &&
hasY(model_id))
287 else if (i == 2 &&
hasZ(model_id))
289 else if (i == 3 &&
hasRoll(model_id))
291 else if (i == 4 &&
hasPitch(model_id))
293 else if (i == 5 &&
hasYaw(model_id))
298 if (j == 0 &&
hasX(model_id))
300 else if (j == 1 &&
hasY(model_id))
302 else if (j == 2 &&
hasZ(model_id))
304 else if (j == 3 &&
hasRoll(model_id))
306 else if (j == 4 &&
hasPitch(model_id))
308 else if (j == 5 &&
hasYaw(model_id))
316 return pose_covariance;
341 gm::PoseWithCovariance pose_with_covariance;
342 pose_with_covariance.pose =
getPose(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;
371 gm::Vector3 velocity;
401 return sqrt(pow(vel.x, 2) + pow(vel.y, 2) + pow(vel.z, 2));
424 gm::Vector3 acceleration;
427 acceleration.z = 0.0;
454 return sqrt(pow(acc.x, 2) + pow(acc.y, 2) + pow(acc.z, 2));
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;
550 auto model_id = state.model_id;
551 for (
int i = 0; i < n; i++) {
552 for (
int j = 0; j < n; j++) {
572 q.setRPY(0.0, 0.0,
getYaw(state));
573 gm::TransformStamped tf;
574 tf.transform.rotation = tf2::toMsg(q);
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;
582 tf2::doTransform(vel_lon_lat, vel_xyz, tf);
609 gm::Vector3 vel_lon_lat, vel_xyz;
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);
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;
688 auto model_id = state.model_id;
689 for (
int i = 0; i < n; i++) {
690 for (
int j = 0; j < n; j++) {
710 q.setRPY(0.0, 0.0,
getYaw(state));
711 gm::TransformStamped tf;
712 tf.transform.rotation = tf2::toMsg(q);
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;
719 tf2::doTransform(acc_lon_lat, acc_xyz, tf);
745 gm::Vector3 acc_lon_lat, acc_xyz;
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);
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;
826 if (highest_prob_class_it == state.classifications.end()) {
827 highest_prob_class.probability = -1.0;
828 highest_prob_class.type = ObjectClassification::UNKNOWN;
830 highest_prob_class = *highest_prob_class_it;
832 return highest_prob_class;
Object state sanity checks.
void sanityCheckContinuousState(const ObjectState &state)
Perform sanity check on continuous state of given object state.
gm::PoseWithCovariance getAccelerationXYZWithCovariance(const ObjectState &state)
Get the acceleration XYZ with covariance of a given object state.
double getAccX(const ObjectState &state)
Get the x-acceleration of a given object state.
ObjectClassification getClassWithHighestProbability(const ObjectState &state)
Get the classification with highest probability of a given object state.
std::vector< double > getContinuousStateCovariance(const ObjectState &state)
Get the continuous state covariance for a given object state.
double getPitchInDeg(const ObjectState &state)
Get the pitch in degree of a given object state.
double getVelocityMagnitude(const ObjectState &state)
Get the velocity magnitude of a given object state.
double getAccelerationMagnitude(const ObjectState &state)
Get the acceleration magnitude of a given object state.
double getAccY(const ObjectState &state)
Get the y-acceleration of a given object state.
std::vector< double > getContinuousState(const ObjectState &state)
Get the continuous state for a given object state.
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.
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.
double getYawInDeg(const ObjectState &state)
Get the yaw in degree of a given object state.
gm::Vector3 getVelocityXYZ(const ObjectState &state)
Get the velocity XYZ of a given object state.
gm::PoseWithCovariance getPoseWithCovariance(const ObjectState &state)
Get the pose with covariance of a given object state.
gm::Vector3 getAcceleration(const ObjectState &state)
Get the acceleration of a given object state.
gm::Pose getPose(const ObjectState &state)
Get the pose of a given object state.
std::vector< double > getPoseCovariance(const ObjectState &state)
Get the pose covariance of a given object state.
gm::PoseWithCovariance getVelocityXYZWithCovariance(const ObjectState &state)
Get the velocity XYZ with covariance of a object state.
gm::Vector3 getVelocity(const ObjectState &state)
Get the velocity of a given object state.
gm::Vector3 getAccelerationXYZ(const ObjectState &state)
Get the acceleration XYZ of a given object state.
double getRollInDeg(const ObjectState &state)
Get the roll in degree of a given object state.
std::vector< double > getContinuousStateCovarianceDiagonal(const ObjectState &state)
Get the continuous state covariance diagonal for a given object state.
double getVelY(const ObjectState &state)
Get the y-velocity of a given object state.
std::vector< long int > getDiscreteState(const ObjectState &state)
Get the discrete state for a given object state.
double getVelX(const ObjectState &state)
Get the x-velocity of a given object state.
Getter functions for objects state members.
double getZ(const ObjectState &state)
Get the z-position for a given object state.
double getRoll(const ObjectState &state)
Get the roll for a given object state.
double getVelLon(const ObjectState &state)
Get the longitudinal velocity for a given object state.
double getAccLon(const ObjectState &state)
Get the longitudinal acceleration for a given object state.
double getPitch(const ObjectState &state)
Get the pitch for a given object state.
double getYaw(const ObjectState &state)
Get the yaw for a given object state.
double getAccLat(const ObjectState &state)
Get the lateral acceleration 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.
double getVelLat(const ObjectState &state)
Get the longitudinal velocity for a given object state.
Object state vector indices based on state model.
bool hasYaw(const unsigned char &model_id)
Indicates if given model contains a yaw.
int indexVelLon(const unsigned char &model_id)
Get the vector-index that stores the longitudinal velocity for a given model-id.
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 hasAccLat(const unsigned char &model_id)
Indicates if given model contains a lateral acceleration.
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 hasY(const unsigned char &model_id)
Indicates if given model contains a y-position.
bool hasRoll(const unsigned char &model_id)
Indicates if given model contains a roll.
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.
bool hasVelLon(const unsigned char &model_id)
Indicates if given model contains a longitudinal velocity.
int indexZ(const unsigned char &model_id)
Get the vector-index that stores the z-position for a given model-id.
int indexAccLon(const unsigned char &model_id)
Get the vector-index that stores the longitudinal acceleration for a given model-id.
bool hasPitch(const unsigned char &model_id)
Indicates if given model contains a pitch.
int indexPitch(const unsigned char &model_id)
Get the vector-index that stores the pitch 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.
int indexX(const unsigned char &model_id)
Get the vector-index that stores the x-position for a given model-id.
bool hasAccLon(const unsigned char &model_id)
Indicates if given model contains a longitudinal acceleration.
int indexYaw(const unsigned char &model_id)
Get the vector-index that stores the yaw for a given model-id.
int getContinuousStateSize(const ObjectState &state)
Get the continuous state size for a given object state.