27#ifndef G2O_BASE_FIXED_SIZED_EDGE_H
28#define G2O_BASE_FIXED_SIZED_EDGE_H
37#include "g2o/config.h"
49 std::array<bool, K> aux = {
false};
54 return std::array<bool, 0>();
61 return j * (j - 1) / 2 + i;
96 T::RowsAtCompileTime == Eigen::Dynamic ? 0 : T::RowsAtCompileTime;
98 T::ColsAtCompileTime == Eigen::Dynamic ? 0 : T::ColsAtCompileTime;
99 return T(
nullptr, r, c);
102template <
typename... Args>
104 return std::tuple<Args...>{createHessianMapK<Args>()...};
107template <
int I,
typename EdgeType,
typename... CtorArgs>
113template <
int I,
typename EdgeType,
typename... CtorArgs>
117 using VertexType =
typename EdgeType::template VertexXnType<I>;
118 return new VertexType(args...);
124template <
int D,
typename E,
typename... VertexTypes>
127 template <
int N,
typename... Types>
128 using NthType =
typename std::tuple_element<N, std::tuple<Types...>>::type;
130 template <
int VertexN>
133 template <
int VertexN>
143 template <
int VertexN>
144 constexpr typename std::enable_if<VertexXnType<VertexN>::Dimension != -1,
int>::type
vertexDimension()
const {
147 template <
int VertexN>
148 typename std::enable_if<VertexXnType<VertexN>::Dimension == -1,
int>::type
vertexDimension()
const {
149 return vertexXn<VertexN>()->dimension();
155 template <
int VertexN>
159 template <
int VertexN>
169 template <
int EdgeDimension,
int VertexDimension>
172 EdgeDimension == 1 ? Eigen::RowMajor : Eigen::ColMajor>::AlignedMapType;
175 template <
int DN,
int DM>
177 Eigen::Matrix<double, DN, DM,
178 DN == 1 ? Eigen::RowMajor : Eigen::ColMajor>,
179 Eigen::Matrix<double, DN, DM,
180 DN == 1 ? Eigen::RowMajor : Eigen::ColMajor>::Flags &
181 Eigen::PacketAccessBit
194 template <std::size_t... Ints>
196 using type = std::tuple<HessianBlockTypeK<Ints>...>;
203 std::make_index_sequence<_nr_of_vertex_pairs>>::type;
205 std::make_index_sequence<_nr_of_vertex_pairs>>::typeTransposed;
219 template <
typename... CtorArgs>
221 if (i < 0)
return nullptr;
223 sizeof...(VertexTypes) - 1,
224 typename std::remove_reference<
decltype(*
this)>::type, CtorArgs...>(
228 virtual void resize(
size_t size);
230 template <std::size_t... Ints>
235 template <std::size_t... Ints>
237 std::index_sequence<Ints...>);
244 template <std::size_t... Ints>
252 const typename std::tuple_element<
253 N, std::tuple<JacobianType<D, VertexTypes::Dimension>...>>::type&
260 typename std::tuple_element<
261 N, std::tuple<JacobianType<D, VertexTypes::Dimension>...>>::type&
271 template <std::size_t... Ints>
274 std::index_sequence<Ints...>);
279 template <
int N,
typename AtOType>
281 std::index_sequence<>);
283 template <
int N, std::size_t... Ints,
typename AtOType>
285 std::index_sequence<Ints...>);
286 template <
int N,
int M,
typename AtOType>
307 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
InformationType _information
internal::BaseEdgeTraits< D >::ErrorVector ErrorVector
internal::BaseEdgeTraits< D >::InformationType InformationType
Measurement _measurement
the measurement of the edge
HessianBlockType< VertexXnType< internal::index_to_pair(K).first >::Dimension, VertexXnType< internal::index_to_pair(K).second >::Dimension > HessianBlockTypeK
BaseEdge< D, E >::InformationType InformationType
virtual bool allVerticesFixed() const
bool allVerticesFixedNs(std::index_sequence< Ints... >) const
void constructOffDiagonalQuadraticFormMs(const AtOType &AtO, std::index_sequence< Ints... >)
std::enable_if< VertexXnType< VertexN >::Dimension==-1, int >::type vertexDimension() const
static const std::size_t _nr_of_vertex_pairs
virtual void mapHessianMemory(double *d, int i, int j, bool rowMajor)
BaseEdge< D, E >::ErrorVector ErrorVector
std::tuple_element< N, std::tuple< JacobianType< D, VertexTypes::Dimension >... > >::type & jacobianOplusXn()
typename HessianTupleType< std::make_index_sequence< _nr_of_vertex_pairs > >::type HessianTuple
static const std::size_t _nr_of_vertices
void linearizeOplusNs(std::index_sequence< Ints... >)
HessianTuple _hessianTuple
void constructOffDiagonalQuadraticFormMs(const AtOType &, std::index_sequence<>)
static constexpr int VertexDimension()
Size of the N-th vertex at compile time.
virtual void constructQuadraticForm()
typename HessianTupleType< std::make_index_sequence< _nr_of_vertex_pairs > >::typeTransposed HessianTupleTransposed
Eigen::Map< Eigen::Matrix< double, DN, DM, DN==1 ? Eigen::RowMajor :Eigen::ColMajor >, Eigen::Matrix< double, DN, DM, DN==1 ? Eigen::RowMajor :Eigen::ColMajor >::Flags &Eigen::PacketAccessBit ? Eigen::Aligned :Eigen::Unaligned > HessianBlockType
it requires quite some ugly code to get the type of hessians...
std::array< bool, _nr_of_vertex_pairs > HessianRowMajorStorage
HessianTupleTransposed _hessianTupleTransposed
void linearizeOplus_allocate(JacobianWorkspace &jacobianWorkspace, std::index_sequence< Ints... >)
VertexXnType< VertexN > * vertexXn()
void constructQuadraticFormN(const InformationType &omega, const ErrorVector &weightedError)
HessianRowMajorStorage _hessianRowMajor
constexpr std::enable_if< VertexXnType< VertexN >::Dimension!=-1, int >::type vertexDimension() const
std::tuple< JacobianType< D, VertexTypes::Dimension >... > _jacobianOplus
typename Eigen::Matrix< double, EdgeDimension, VertexDimension, EdgeDimension==1 ? Eigen::RowMajor :Eigen::ColMajor >::AlignedMapType JacobianType
BaseEdge< D, E >::Measurement Measurement
const std::tuple_element< N, std::tuple< JacobianType< D, VertexTypes::Dimension >... > >::type & jacobianOplusXn() const
typename std::tuple_element< N, std::tuple< Types... > >::type NthType
static const int Dimension
virtual void resize(size_t size)
void constructOffDiagonalQuadraticFormM(const AtOType &AtO)
HessianBlockType< VertexXnType< internal::index_to_pair(K).second >::Dimension, VertexXnType< internal::index_to_pair(K).first >::Dimension > HessianBlockTypeKTransposed
NthType< VertexN, VertexTypes... > VertexXnType
The type of the N-th vertex.
void constructQuadraticFormNs(const InformationType &omega, const ErrorVector &weightedError, std::index_sequence< Ints... >)
OptimizableGraph::Vertex * createVertex(int i, CtorArgs... args)
create an instance of the Nth VertexType
const VertexXnType< VertexN > * vertexXn() const
virtual void linearizeOplus()
VertexContainer _vertices
virtual void resize(size_t size)
provide memory workspace for computing the Jacobians
virtual void computeError()=0
A general case Vertex for optimization.
some general case utility functions
constexpr TrivialPair index_to_pair(const int k, const int j=0)
std::array< bool, K > createBoolArray()
T createHessianMapK()
helper function to call the c'tor of Eigen::Map
std::tuple< Args... > createHessianMaps(const std::tuple< Args... > &)
helper function for creating a tuple of Eigen::Map
std::array< bool, 0 > createBoolArray< 0 >()
std::enable_if< I==-1, OptimizableGraph::Vertex * >::type createNthVertexType(int, const EdgeType &, CtorArgs...)
constexpr int pair_to_index(const int i, const int j)
std::tuple< HessianBlockTypeK< Ints >... > type
std::tuple< HessianBlockTypeKTransposed< Ints >... > typeTransposed
constexpr TrivialPair(int f, int s)
bool operator==(const TrivialPair &other) const