PoseManifoldGaussian.cpp
Go to the documentation of this file.
2
3#include <SimoxUtility/math/pose/invert.h>
4#include <SimoxUtility/math/pose/pose.h>
5
6namespace armarx::objpose
7{
8
11 {
12 const float minSize = 0.005;
13
14 const Eigen::Matrix3f covarianceTranslation = this->covariance.block<3, 3>(0, 0);
15
16 const Eigen::EigenSolver<Eigen::Matrix3f> eigen(covarianceTranslation);
17 const Eigen::Vector3f eval = eigen.eigenvalues().real();
18 const Eigen::Matrix3f evec = eigen.eigenvectors().real();
19
20 Ellipsoid result;
21 result.center = simox::math::position(this->mean);
22
23 /* Eigen values are local x, y, and z of ellipsoid:
24 * ( )
25 * ( x y z ) = u
26 * ( )
27 *
28 * Eigen vectors are sorted by the singular values:
29 * ( e_x )
30 * ( e_y ) = ev, (e_x >= e_y >= e_z)
31 * ( e_z )
32 */
33 result.orientation = evec.determinant() > 0 ? evec : -evec;
34
35 result.size = eval;
36
37 // Handle very small values.
38 result.size = result.size.cwiseMax(Eigen::Vector3f::Constant(minSize));
39
40 return result;
41 }
42
43 Eigen::AngleAxisf
45 {
46 Eigen::Vector3f axis = covariance.block<3, 1>(3, 3 + index);
47 const float angle = axis.norm();
48 axis /= angle;
49 if (global)
50 {
51 axis = simox::math::orientation(mean) * axis;
52 }
53 return {angle, axis};
54 }
55
57 PoseManifoldGaussian::getTransformed(const Eigen::Matrix4f& transform) const
58 {
60 covRotation.block<3, 3>(0, 0) = covRotation.block<3, 3>(3, 3) =
61 simox::math::orientation(transform);
62
63 PoseManifoldGaussian transformed = *this;
64 transformed.mean = transform * transformed.mean;
65 // We just need to apply the orientation.
66 transformed.covariance = covRotation * transformed.covariance * covRotation.transpose();
67 return transformed;
68 }
69
71 PoseManifoldGaussian::getTransformed(const Eigen::Matrix4f& fromFrame,
72 const Eigen::Matrix4f& toFrame) const
73 {
74 // T_to = T_(from->to) * T_from
75 // T_(from->to) = T_to * (T_from)^-1
76 Eigen::Matrix4f transform = toFrame * simox::math::inverted_pose(fromFrame);
78 }
79
80} // namespace armarx::objpose
uint8_t index
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition algorithm.h:351
double angle(const Point &a, const Point &b, const Point &c)
Definition point.hpp:109
A "gaussian" distribution in pose space (i.e.
Eigen::Matrix4f mean
The mean (i.e. a pose).
PoseManifoldGaussian getTransformed(const Eigen::Matrix4f &transform) const
Transform this gaussian by the given transform (e.g.
Eigen::AngleAxisf getScaledRotationAxis(int index, bool global=false) const
Get a column of the pure orientational covariance matrix as axis-angle rotation.
Ellipsoid getPositionEllipsoid() const
Get the parameters of a 3D ellipsoid illustrating this gaussian.
Eigen::Matrix< float, 6, 6 > covariance
The covariance matrix.