23 #include <geometry_msgs/Pose.h> 24 #include <geometry_msgs/PoseWithCovariance.h> 25 #include <geometry_msgs/Quaternion.h> 36 #include <tf2/LinearMath/Matrix3x3.h> 44 for (
int r = 0; r < 3; r++)
45 for (
int c = 0; c < 3; c++) des[r][c] = src(r, c);
66 geometry_msgs::Pose des;
68 des.position.x = src.
x;
69 des.position.y = src.
y;
72 const double yaw = src.
phi;
73 if (std::abs(yaw) < 1e-10)
75 des.orientation.x = 0.;
76 des.orientation.y = 0.;
77 des.orientation.z = .5 * yaw;
78 des.orientation.w = 1.;
82 const double s = ::sin(yaw * .5);
83 const double c = ::cos(yaw * .5);
84 des.orientation.x = 0.;
85 des.orientation.y = 0.;
86 des.orientation.z = s;
87 des.orientation.w = c;
97 des.setOrigin(tf2::Vector3(src.
x(), src.
y(), src.z()));
103 geometry_msgs::Pose des;
104 des.position.x = src.
x();
105 des.position.y = src.
y();
106 des.position.z = src.z();
111 des.orientation.x = q.
x();
112 des.orientation.y = q.
y();
113 des.orientation.z = q.
z();
114 des.orientation.w = q.
r();
132 geometry_msgs::PoseWithCovariance des;
147 const unsigned int indxs_map[6] = {0, 1, 2, 5, 4, 3};
148 for (
int i = 0; i < 6; i++)
149 for (
int j = 0; j < 6; j++)
150 des.covariance[indxs_map[i] * 6 + indxs_map[j]] = src.
cov(i, j);
154 geometry_msgs::PoseWithCovariance
toROS(
162 geometry_msgs::PoseWithCovariance
toROS(
165 geometry_msgs::PoseWithCovariance des;
184 des.covariance[0] = src.
cov(0, 0);
185 des.covariance[1] = src.
cov(0, 1);
186 des.covariance[5] = src.
cov(0, 2);
187 des.covariance[6] = src.
cov(1, 0);
188 des.covariance[7] = src.
cov(1, 1);
189 des.covariance[11] = src.
cov(1, 2);
190 des.covariance[30] = src.
cov(2, 0);
191 des.covariance[31] = src.
cov(2, 1);
192 des.covariance[35] = src.
cov(2, 2);
197 geometry_msgs::PoseWithCovariance
toROS(
208 geometry_msgs::Quaternion des;
224 const tf2::Vector3& t = src.getOrigin();
234 for (
int r = 0; r < 3; r++)
235 for (
int c = 0; c < 3; c++) des(r, c) = src[r][c];
242 src.orientation.w, src.orientation.x, src.orientation.y,
245 q, src.position.
x, src.position.y, src.position.z);
249 const geometry_msgs::PoseWithCovariance& src)
255 const unsigned int indxs_map[6] = {0, 1, 2, 5, 4, 3};
257 for (
int i = 0; i < 6; i++)
258 for (
int j = 0; j < 6; j++)
259 des.
cov(i, j) = src.covariance[indxs_map[i] * 6 + indxs_map[j]];
void copyFrom(const CPosePDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
CPose2D mean
The mean value.
CPose3D mean
The mean value.
void copyFrom(const CPose3DPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
T y() const
Return y coordinate of the quaternion.
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
void setRotationMatrix(const mrpt::math::CMatrixDouble33 &ROT)
Sets the 3x3 rotation matrix.
void getAsQuaternion(mrpt::math::CQuaternionDouble &q, mrpt::optional_ref< mrpt::math::CMatrixDouble43 > out_dq_dr=std::nullopt) const
Returns the quaternion associated to the rotation of this object (NOTE: XYZ translation is ignored) ...
T r() const
Return r (real part) coordinate of the quaternion.
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
double x() const
Common members of all points & poses classes.
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
bool toROS(const mrpt::obs::CObservationGPS &obj, const std_msgs::Header &msg_header, sensor_msgs::NavSatFix &msg)
Convert mrpt::obs::CObservationGPS -> sensor_msgs/NavSatFix The user must supply the "msg_header" fie...
A Probability Density function (PDF) of a 2D pose as a Gaussian with a mean and the inverse of the c...
T x() const
Return x coordinate of the quaternion.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
ROS message: http://docs.ros.org/api/sensor_msgs/html/msg/NavSatFix.html MRPT message: https://github...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
bool fromROS(const sensor_msgs::NavSatFix &msg, mrpt::obs::CObservationGPS &obj)
Convert sensor_msgs/NavSatFix -> mrpt::obs::CObservationGPS.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Declares a class that represents a Probability Density function (PDF) of a 3D pose as a Gaussian des...
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
tf2::Transform toROS_tfTransform(const mrpt::poses::CPose2D &src)
geometry_msgs::Pose toROS_Pose(const mrpt::poses::CPose2D &src)
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
T z() const
Return z coordinate of the quaternion.
double phi
Orientation (rads)