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