6#include "robust_kernel.h"
11 using namespace Eigen;
20 template <s
int04 t_dims,
typename E,
typename VertexXi>
26 typedef typename Eigen::Matrix<g_type, t_dims, VertexXiType::Dimension>::AlignedMapType
JacobianXiOplusType;
45 lib_assert(
dynamic_cast<VertexXiType*
>(v),
"wrong type");
58 lib_assert(jacobianWorkspace.maxNumVertices() >= 1,
"Bad vertex size");
59 lib_assert(jacobianWorkspace.maxDimension() >= t_dims * VertexXiType::Dimension,
"Bad vertex dimension");
88 constexpr g_type delta = g_type(1e-9);
89 constexpr g_type scalar = g_type(1.0) / (2 * delta);
93 g_type add_vi[VertexXiType::Dimension];
94 std::fill(add_vi, add_vi + VertexXiType::Dimension, g_type(0.0));
96 for (
int d = 0; d < VertexXiType::Dimension; ++d)
115 _error = errorBeforeNumeric;
133 const auto A_trans = A.transpose();
134 const auto omega_e = omega.selfadjointView<Eigen::Upper>() *
_error;
138 Eigen::Vector3<g_type> rho;
141 const g_type w = rho[1];
147 b.noalias() -= w * A_trans * omega_e;
150 H.noalias() += A_trans * weighted_omega.selfadjointView<Eigen::Upper>() * A;
156 b.noalias() -= A_trans * omega_e;
159 H.noalias() += A_trans * omega.selfadjointView<Eigen::Upper>() * A;
189 virtual void mapHessianMemory(g_type*,
int,
int,
bool)
final override { lib_assert(
false,
"BaseUnaryEdge does not map memory of the Hessian"); }
201 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Base class for edges with a fixed-size error vector and measurement type.
g_type chi2() const final override
Computes the chi-squared error: e^T * Omega * e.
BaseEdge()
Default constructor.
InformationType robustInformation(const Eigen::Vector3< g_type > &rho) const
calculate the robust information matrix by updating the information matrix of the error
static constexpr sint04 Dimension
Compile-time dimension of the error vector.
Eigen::Matrix< g_type, t_dims, t_dims > InformationType
Fixed-size information (inverse covariance) matrix type.
const InformationType & information() const
Returns a const reference to the information matrix.
Measurement _measurement
The stored measurement for this edge.
ErrorVector _error
The current error vector.
Eigen::Matrix< g_type, t_dims, 1 > ErrorVector
Fixed-size error vector type.
E Measurement
The measurement type stored by this edge.
void constructQuadraticForm()
Constructs the quadratic form (Hessian block and gradient) for this unary edge.
BaseUnaryEdge()
Default constructor.
virtual HyperGraph::HGVertex * vertex(uint04) final override
Returns a mutable pointer to the single vertex.
virtual void linearizeOplusAndConstructQuadraticForm(JacobianWorkspace &jacobianWorkspace) final override
Linearizes the oplus operator and constructs the quadratic form.
virtual const HyperGraph::HGVertex * vertex(uint04) const final override
Returns a const pointer to the single vertex.
virtual uint04 vertexCount() const final override
Returns the number of vertices (always 1 for unary edges).
BaseEdge< t_dims, E >::Measurement Measurement
The measurement type.
VertexXi VertexXiType
The vertex type.
VertexXiType * m_vertex
Pointer to the connected vertex.
BaseEdge< t_dims, E >::ErrorVector ErrorVector
The error vector type.
Eigen::Matrix< g_type, t_dims, VertexXiType::Dimension >::AlignedMapType JacobianXiOplusType
Jacobian type w.r.t. the vertex.
virtual void setVertex(uint04, HyperGraph::HGVertex *v) final override
Sets the vertex, with type-checking.
BaseEdge< t_dims, E >::InformationType InformationType
The information matrix type.
virtual void linearizeOplus()
Linearizes the oplus operator in the vertex, and stores the result in temporary variables _jacobianOp...
virtual void mapHessianMemory(g_type *, int, int, bool) final override
maps the internal matrix to some external memory location, you need to provide the memory before call...
const JacobianXiOplusType & jacobianOplusXi() const
returns the result of the linearization in the manifold space for the node xi
JacobianXiOplusType _jacobianOplusXi
Jacobian of the error w.r.t. the vertex.
virtual bool allVerticesFixed() const final override
Returns true if the single vertex is fixed.
abstract Vertex, your types must derive from that one
provide memory workspace for computing the Jacobians
virtual void computeError()=0
Computes the error of the edge and stores it internally.
RobustKernel * robustKernel() const
if NOT NULL, error of this edge will be robustifed with the kernel
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.