22 #if defined(_MSC_VER) && (_MSC_VER < 1700 ) && (MRPT_WORD_SIZE==32) // handle MSVC versions older than 2012
23 # define SRBA_WORKAROUND_MSVC9_DEQUE_BUG
43 template <
class LANDMARK_TYPE,
class OBS_TYPE>
49 template <
class POSE_TRAITS>
53 typedef typename POSE_TRAITS::pose_t
pose_t;
63 pose_flag_t(
const pose_t &pose_,
const bool updated_) : pose(pose_),updated(updated_) { }
78 typename std::deque<std::pair<TKeyFrameID,frameid2pose_map_t> >
99 template <
class LM_TRAITS>
112 template <
typename LANDMARK_POS>
114 for (
size_t i=0;i<LM_TRAITS::LM_DIMS;i++)
pos[i]=_pos[i];
139 template <
class OBS_TRAITS>
184 template <
typename PAIR,
typename V>
186 return p.first==one ? p.second : p.first;
190 template <
typename K2K_EDGE,
typename V>
192 return p.from==one ? p.to: p.from;
206 template <
class KF2KF_POSE_TYPE,
class LANDMARK_TYPE>
245 template <
class KF2KF_POSE_TYPE,
class LANDMARK_TYPE>
272 template <
typename Scalar,
int N,
int M1,
int M2>
284 const matrix1_t *
J1;
285 const matrix2_t *
J2;
290 THessianSymbolicInfoEntry(
const matrix1_t *
const J1_,
const matrix2_t *
const J2_,
const char *
const J1_valid_,
const char *
const J2_valid_,
const size_t obs_idx_ ) :
291 J1(J1_), J2(J2_),J1_valid(J1_valid_),J2_valid(J2_valid_),obs_idx(obs_idx_)
308 template <
class KF2KF_POSE_TYPE,
class LANDMARK_TYPE,
class OBS_TYPE>
313 static const size_t LM_DIMS = LANDMARK_TYPE::LM_DIMS;
329 template <
class KF2KF_POSE_TYPE,
class LANDMARK_TYPE,
class OBS_TYPE>
334 static const size_t LM_DIMS = LANDMARK_TYPE::LM_DIMS;
350 #if !defined(SRBA_WORKAROUND_MSVC9_DEQUE_BUG)
361 template <
class KF2KF_POSE_TYPE,
class LM_TYPE,
class OBS_TYPE>
413 template <
class REL_POS>
inline void setRelPos(
const REL_POS &pos) {
414 for (
size_t i=0;i<LM_TYPE::LM_DIMS;i++) feat_rel_pos[i]=pos[i];
419 #ifdef SRBA_WORKAROUND_MSVC9_DEQUE_BUG
473 template <
class KF2KF_POSE_TYPE,
class LM_TYPE,
class OBS_TYPE,
class RBA_OPTIONS>
476 typedef typename KF2KF_POSE_TYPE::pose_t
pose_t;
489 #ifdef SRBA_WORKAROUND_MSVC9_DEQUE_BUG
504 std::map<TKeyFrameID,TSpanTreeEntry>,
505 std::deque<std::pair<TKeyFrameID,std::map<TKeyFrameID,TSpanTreeEntry> > >
511 std::map<TKeyFrameID, k2k_edge_vector_t>,
512 std::deque<std::pair<TKeyFrameID,std::map<TKeyFrameID, k2k_edge_vector_t > > >
565 const TKeyFrameID new_node_id,
566 const TPairKeyFrameID & new_edge,
567 const topo_dist_t max_depth,
568 const bool check_all_obs_are_connected =
false,
569 const new_kf_observations_t * obs = NULL
578 size_t update_numeric(
const std::set<TKeyFrameID> & kfs_to_update,
bool skip_marked_as_uptodate =
false);
600 bool save_as_dot_file(
const std::string &sFileName,
const std::vector<TKeyFrameID> &kf_roots_to_save = std::vector<TKeyFrameID>() )
const;
604 size_t &num_nodes_min,
605 size_t &num_nodes_max,
606 double &num_nodes_mean,
607 double &num_nodes_std)
const;
663 unknown_lms_inf_matrices.clear();
666 spanning_tree.
clear();
667 all_observations.clear();
683 const TKeyFrameID from,
684 const TKeyFrameID to,
685 std::vector<TKeyFrameID> * out_path_IDs,
691 double &out_mean_degree,
692 double &out_std_degree,
693 double &out_max_degree)
const;
706 const TPairKeyFrameID &ids,
707 const pose_t &init_inv_pose_val =
pose_t() );
kf2kf_pose_traits< KF2KF_POSE_TYPE >::pose_flag_t pose_flag_t
kf2kf_pose_traits< KF2KF_POSE_TYPE >::frameid2pose_map_t frameid2pose_map_t
next_edge_maps_t next_edge
Given all interesting spanning tree roots (=SOURCE), this structure holds: map[SOURCE] |-> map[TARGET...
mrpt::utils::map_as_vector< TKeyFrameID, std::map< TKeyFrameID, k2k_edge_vector_t >, std::deque< std::pair< TKeyFrameID, std::map< TKeyFrameID, k2k_edge_vector_t > > > > all_edges_maps_t
The definition seems complex but behaves just like: std::map< TKeyFrameID, std::map >
mrpt::aligned_containers< TLandmarkEntry >::deque_t all_lms
Index (by feat ID) of ALL landmarks stored in unknown_lms and known_lms.
Elemental observation data.
const kf2kf_traits_t::pose_flag_t * rel_pose_base_from_obs
The relative poses used in this Jacobian (see papers) Pointers to the elements in the "numeric" part ...
TJacobianSymbolicInfo_dh_df< KF2KF_POSE_TYPE, LANDMARK_TYPE > jacob_dh_df_info_t
const kf2kf_traits_t::pose_flag_t * rel_pose_base_from_d1
A STL-like container which looks and behaves (almost exactly) like a std::map<> but is implemented as...
obs_traits_t::observation_t obs
Observation data.
TLandmarkID feat_id
Observed what.
Symbolic information of each Jacobian dh_df.
mrpt::math::CArrayDouble< LM_TRAITS::LM_DIMS > array_landmark_t
A fixed-length array of the size of the parameters of one landmark in the map (e.g. if Euclidean coordinates are used, this will hold the coordinates)
OBS_TRAITS::obs_data_t obs_data
Observed data.
struct mrpt::srba::TRBA_Problem_state::TSpanningTree::TSpanningTreeSym sym
void setRelPos(const REL_POS &pos)
Sets feat_rel_pos from any object that offers a [] operator and has the expected length "LM_TYPE::LM_...
mrpt::srba::TEdgeCreationPolicy enum_t
static const size_t LM_DIMS
size_t alloc_kf2kf_edge(const TPairKeyFrameID &ids, const pose_t &init_inv_pose_val=pose_t())
Creates a new kf2kf edge variable.
rba_joint_parameterization_traits_t< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE >::new_kf_observations_t new_kf_observations_t
vec_t::const_iterator const_iterator
kf2kf_traits_t::k2k_edge_t k2k_edge_t
size_t k2k_edge_id
The ID (0-based index in k2k_edges) of the edge wrt we are taking derivatives.
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
size_t obs_idx
The global index of the observation that generates this Jacobian.
uint64_t TLandmarkID
Numeric IDs for landmarks.
Types for the Hessian blocks:
THessianSymbolicInfo< double, OBS_DIMS, REL_POSE_DIMS, LM_DIMS > hessian_Apf_info_t
mrpt::utils::map_as_vector< TKeyFrameID, frameid2pose_map_t, typename std::deque< std::pair< TKeyFrameID, frameid2pose_map_t > > > TRelativePosesForEachTarget
kf2kf_pose_traits< KF2KF_POSE_TYPE >::k2k_edge_vector_t k2k_edge_vector_t
TEdgeCreationPolicy
For usage in RbaEngine.parameters.
kf2kf_pose_traits< KF2KF_POSE_TYPE > kf2kf_traits_t
bool edge_normal_dir
If true, the edge direction points in the "canonical" direction: from "d" towards the direction of "o...
Don't recover any covariance information.
kf2kf_pose_traits< KF2KF_POSE_TYPE >::k2k_edge_t k2k_edge_t
TKeyFrameID kf_base
The ID of the base keyframe of the observed feature.
std::deque< char > all_observations_Jacob_validity
Its size grows simultaneously to all_observations, its values are updated during optimization to refl...
std::map< TYPE1, TYPE2, std::less< TYPE1 >, Eigen::aligned_allocator< std::pair< const TYPE1, TYPE2 > > > map_t
The sub-map method introduced in the ICRA2013 paper.
size_t id
0-based index of this edge, in the std::list "k2k_edges".
static const size_t REL_POSE_DIMS
mrpt::math::CArrayDouble< POSE_TRAITS::REL_POSE_DIMS > array_pose_t
A fixed-length array of the size of the relative poses between keyframes.
Only specializations of this class are defined for each enum type of interest.
TLandmarkEntry(bool has_known_pos_, TRelativeLandmarkPos *rfp_)
Keyframe-to-keyframe edge: an unknown of the problem.
std::deque< TYPE1, Eigen::aligned_allocator< TYPE1 > > deque_t
bool has_aprox_init_val
Whether the edge was assigned an approximated initial value.
size_t obs_idx
The global index of the observation that generates this Jacobian.
uint64_t topo_dist_t
Unsigned integral type for topological distances in a graph/tree.
std::deque< k2k_edge_t * > adjacent_k2k_edges
void clear()
Empties all members.
std::deque< new_kf_observation_t > new_kf_observations_t
A set of all the observations made from a new KF, as provided by the user.
Helper types for STL containers with Eigen memory allocators.
landmark_traits< LM_TYPE >::TRelativeLandmarkPosMap TRelativeLandmarkPosMap
landmark_traits< LM_TYPE >::TLandmarkEntry TLandmarkEntry
std::deque< k2k_edge_t * > k2k_edge_vector_t
A sequence of edges (a "path")
Keyframe-to-feature edge: observations in the problem.
array_landmark_t pos
The parameterization of the feature location, wrt to the camera frame id_frame_base - For example...
THessianSymbolicInfo< double, OBS_DIMS, LM_DIMS, LM_DIMS > hessian_f_info_t
rba_joint_parameterization_traits_t< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE >::keyframe_info keyframe_info
TKeyFrameID next
The next keyframe in the tree.
std::deque< k2f_edge_t * > adjacent_k2f_edges
This Hessian block equals the sum of all J1^t * * J2, with J1=first, J2=second in each std::pair "co...
lm_traits_t::TRelativeLandmarkPos * feat_rel_pos
Pointer to the known/unknown rel.pos. (always!=NULL)
obs_traits_t::array_obs_t obs_arr
Observation data, summarized as an array of its parameters: obs.obs_data.getAsArray(obs_arr);.
landmarks2infmatrix_t unknown_lms_inf_matrices
Information matrices that model the uncertainty in each XYZ position for the unknown LMs - these matr...
obs_traits_t::observation_t obs
TCovarianceRecoveryPolicy
Covariances recovery from Hessian matrix policy, for usage in RbaEngine.parameters.
landmark_traits< LM_TYPE > lm_traits_t
TRelativeLandmarkPos(const TKeyFrameID _id_frame_base, const LANDMARK_POS &_pos)
Constructor from a base KF ID "_id_frame_base" and any object "_pos" that offers a read [] operator a...
Generic declaration, of which specializations are defined for each combination of LM+OBS type...
Useful data structures that depend of a combination of "OBSERVATION_TYPE"+"LANDMARK_PARAMETERIZATION_...
new_kf_observation_t()
Default ctor.
The argument "POSE_TRAITS" can be any of those defined in srba/models/kf2kf_poses.h (typically, either kf2kf_poses::SE3 or kf2kf_poses::SE2).
pose_flag_t(const pose_t &pose_, const bool updated_)
rba_joint_parameterization_traits_t< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE >::k2f_edge_t k2f_edge_t
mrpt::math::CArrayDouble< OBS_TRAITS::OBS_DIMS > residual_t
A fixed-length array of the size of one residual (=the size of one observation).
Observations, as provided by the user.
std::map< TLandmarkID, TRelativeLandmarkPos > TRelativeLandmarkPosMap
An index of feature IDs and their relative locations.
bool save_as_dot_file(const std::string &sFileName, const std::vector< TKeyFrameID > &kf_roots_to_save=std::vector< TKeyFrameID >()) const
Saves all (or a subset of all) the spanning trees If kf_roots_to_save is left empty, all STs are saved.
TLinearSystem lin_system
The sparse linear system of equations.
bool is_fixed
If true, feat_rel_pos has the fixed relative position of this landmark (Can be set to true only upon ...
k2k_edges_deque_t k2k_edges
(unknowns) All keyframe-to-keyframe edges
mrpt::math::MatrixBlockSparseCols< double, REL_POSE_DIMS, LM_DIMS, hessian_Apf_info_t, false > TSparseBlocksHessian_Apf
bool is_first_obs_of_unknown
true if this is the first observation of a feature with unknown relative position ...
A bidirectional version of std::map, declared as bimap and which actually contains two std...
void update_symbolic_new_node(const TKeyFrameID new_node_id, const TPairKeyFrameID &new_edge, const topo_dist_t max_depth, const bool check_all_obs_are_connected=false, const new_kf_observations_t *obs=NULL)
Incremental update of spanning trees after the insertion of ONE new node and ONE OR MORE edges...
kf_observation_t(const typename obs_traits_t::observation_t &obs_, const TKeyFrameID kf_id_)
size_t obs_idx
Global index of the observation that generated this Hessian entry (used to retrieve the in "J1^t * \...
kf2kf_pose_traits< POSE_TRAITS > me_t
Each keyframe is only connected to its predecessor (no loop closures)
jacobian_traits< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE >::TSparseBlocksJacobians_dh_df dh_df
Both symbolic & numeric info on the sparse Jacobians wrt. the observations.
void mark_outdated() const
all_edges_maps_t all_edges
From the previous data, we can build this alternative, more convenient representation: map[SOURCE] |-...
void compute_all_node_degrees(double &out_mean_degree, double &out_std_degree, double &out_max_degree) const
Computes stats on the degree (# of adjacent nodes) of all the nodes in the graph. ...
Used in TRBA_Problem_state.
Eigen::Matrix< Scalar, N, M2 > matrix2_t
V getTheOtherFromPair(const V one, const PAIR &p)
Aux function for getting, from a std::pair, "the other" element which is different to a known given o...
kf2kf_pose_traits< KF2KF_POSE_TYPE > kf2kf_traits_t
A templated column-indexed efficient storage of block-sparse Jacobian or Hessian matrices, together with other arbitrary information.
TKeyFrameID kf_d
The ID of the keyframe before the edge wrt which we are taking derivatives (before if going backwards...
mrpt::aligned_containers< k2k_edge_t >::deque_t k2k_edges_deque_t
char * is_valid
A reference to the validity bit in the global list TRBA_Problem_state::all_observations_Jacob_validit...
TRBA_Problem_state & operator=(const TRBA_Problem_state &)
mrpt::math::MatrixBlockSparseCols< double, OBS_DIMS, REL_POSE_DIMS, jacob_dh_dAp_info_t, false > TSparseBlocksJacobians_dh_dAp
The "false" is since we don't need to "remap" indices.
All the important data of a RBA problem at any given instant of time Operations on this structure are...
static void fill(bimap< enum_t, std::string > &m_map)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void get_stats(size_t &num_nodes_min, size_t &num_nodes_max, double &num_nodes_mean, double &num_nodes_std) const
Returns min/max and mean/std stats on the number of nodes found on all the spanning trees...
TKeyFrameID id_frame_base
The ID of the camera frame which is the coordinate reference of pos.
TJacobianSymbolicInfo_dh_dAp< KF2KF_POSE_TYPE, LANDMARK_TYPE > jacob_dh_dAp_info_t
mrpt::math::MatrixBlockSparseCols< double, REL_POSE_DIMS, REL_POSE_DIMS, hessian_Ap_info_t, false > TSparseBlocksHessian_Ap
const TRBA_Problem_state< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE, RBA_OPTIONS > * m_parent
The "symbolic" part of the spanning tree.
static const size_t REL_POSE_DIMS
mrpt::utils::map_as_vector< TKeyFrameID, std::map< TKeyFrameID, TSpanTreeEntry >, std::deque< std::pair< TKeyFrameID, std::map< TKeyFrameID, TSpanTreeEntry > > > > next_edge_maps_t
The definition seems complex but behaves just like: std::map< TKeyFrameID, std::map >
pose_t inv_pose
Inverse pose: pose_from (-) pose_to , that is: "from" as seen from "to".
A joint structure for one relative pose + an "up-to-date" flag (needed for spanning trees numeric upd...
size_t update_numeric_only_all_from_node(const typename all_edges_maps_t::const_iterator &it, bool skip_marked_as_uptodate=false)
Updates all the numeric SE(3) poses from a given entry from sym.all_edges[i].
std::pair< TKeyFrameID, TKeyFrameID > TPairKeyFrameID
Used to represent the IDs of a directed edge (first –> second)
all_observations_deque_t all_observations
All raw observation data (k2f edges)
TKeyFrameID kf_id
Observed from.
const kf2kf_traits_t::pose_flag_t * rel_pose_d1_from_obs
The two relative poses used in this Jacobian (see papers) Pointers to the elements in the "numeric" p...
landmark_traits< LM_TRAITS > me_t
static void fill(bimap< enum_t, std::string > &m_map)
list_jacob_blocks_t lst_jacob_blocks
The list of Jacobian blocks itself.
bool find_path_bfs(const TKeyFrameID from, const TKeyFrameID to, std::vector< TKeyFrameID > *out_path_IDs, typename kf2kf_pose_traits< KF2KF_POSE_TYPE >::k2k_edge_vector_t *out_path_edges=NULL) const
Auxiliary, brute force (BFS) method for finding the shortest path between any two Keyframes...
The argument "LM_TRAITS" can be any of those defined in srba/models/landmarks.h (typically, either landmarks::Euclidean3D or landmarks::Euclidean2D).
mrpt::math::CArrayDouble< OBS_TRAITS::OBS_DIMS > array_obs_t
A fixed-length array of the size of one residual (=the size of one observation).
const lm_traits_t::TRelativeLandmarkPos * feat_rel_pos
Pointer to the relative feature position wrt its base KF.
char * is_valid
A reference to the validity bit in the global list TRBA_Problem_state::all_observations_Jacob_validit...
observation_traits< OBS_TYPE > obs_traits_t
THessianSymbolicInfo< double, OBS_DIMS, REL_POSE_DIMS, REL_POSE_DIMS > hessian_Ap_info_t
A partial specialization of CArrayNumeric for double numbers.
mrpt::utils::map_as_vector< TLandmarkID, typename TSparseBlocksHessian_f::matrix_t, typename mrpt::aligned_containers< std::pair< TLandmarkID, typename TSparseBlocksHessian_f::matrix_t > >::deque_t > landmarks2infmatrix_t
The list with all the information matrices (estimation uncertainty) for each unknown landmark...
TSpanningTree spanning_tree
Eigen::Matrix< Scalar, NROWS, NCOLS > matrix_t
mrpt::srba::TCovarianceRecoveryPolicy enum_t
bool are_keyframes_connected(const TKeyFrameID id1, const TKeyFrameID id2) const
Returns true if the pair of KFs are connected thru a kf2kf edge, no matter the direction of the edge...
size_t id
The new edge ID.
void clear()
Empty all sym & num data.
THessianSymbolicInfoEntry(const matrix1_t *const J1_, const matrix2_t *const J2_, const char *const J1_valid_, const char *const J2_valid_, const size_t obs_idx_)
mrpt::math::MatrixBlockSparseCols< double, LM_DIMS, LM_DIMS, hessian_f_info_t, false > TSparseBlocksHessian_f
mrpt::math::MatrixBlockSparseCols< double, OBS_DIMS, LM_DIMS, jacob_dh_df_info_t, true > TSparseBlocksJacobians_dh_df
TRelativeLandmarkPos * rfp
Pointers to elements in unknown_lms and known_lms.
std::deque< keyframe_info > keyframe_vector_t
Index are "TKeyFrameID" IDs. There's no NEED to make this a deque<> for preservation of references...
landmark_traits< LANDMARK_TYPE > lm_traits_t
std::vector< THessianSymbolicInfoEntry > list_jacob_blocks_t
Symbolic information of each Jacobian dh_dAp.
Used in the vector "all_lms".
kf2kf_pose_traits< KF2KF_POSE_TYPE >::TRelativePosesForEachTarget num
"Numeric" spanning tree: the SE(3) pose of each node wrt to any other: num[SOURCE] |–> map[TARGET] =...
keyframe_vector_t keyframes
All key frames (global poses are not included in an RBA problem). Vector indices are "TKeyFrameID" ID...
mrpt::aligned_containers< k2f_edge_t >::deque_t all_observations_deque_t
jacobian_traits< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE >::TSparseBlocksJacobians_dh_dAp dh_dAp
Both symbolic & numeric info on the sparse Jacobians wrt. the edges.
Used in TNewKeyFrameInfo.
TRelativeLandmarkPosMap unknown_lms
(unknown values) Landmarks with an unknown fixed 3D position relative to their base frame_id ...
Information per key-frame needed for RBA.
void insert(const KEY &k, const VALUE &v)
Insert a new pair KEY<->VALUE in the bi-map.
lm_traits_t::array_landmark_t feat_rel_pos
Ignored unless is_fixed OR is_unknown_with_init_val are true (only one of them at once)...
mrpt::aligned_containers< residual_t >::vector_t vector_residuals_t
TRBA_Problem_state()
Ctor.
landmark_traits< LANDMARK_TYPE > lm_traits_t
void dump_as_text(std::string &s) const
Useful for debugging.
Approximate covariances of landmarks as the inverse of the hessian diagonal blocks.
Keyframe-to-feature edge: observation data stored for each keyframe.
TRelativeLandmarkPosMap known_lms
(known values) Landmarks with a known, fixed 3D position relative to their base frame_id ...
All keyframes are connected to the first one (it can be used to emulate global coordinates) ...
rba_joint_parameterization_traits_t< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE >::new_kf_observation_t new_kf_observation_t
bool is_unknown_with_init_val
Can be set to true only upon FIRST observation of a landmark with UNKNOWN relative position (the norm...
topo_dist_t distance
Remaining distance until the given target from this point.
bool feat_has_known_rel_pos
whether it's a known or unknown relative position feature
hessian_traits< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE >::landmarks2infmatrix_t landmarks2infmatrix_t
size_t update_numeric(bool skip_marked_as_uptodate=false)
Updates all the numeric SE(3) poses from ALL the sym.all_edges.
static const size_t OBS_DIMS
std::vector< TYPE1, Eigen::aligned_allocator< TYPE1 > > vector_t
kf2kf_pose_traits< KF2KF_POSE_TYPE > kf2kf_traits_t
bool dump_as_text_to_file(const std::string &sFileName) const
Useful for debugging.
bool has_known_pos
true: This landmark has a fixed (known) relative position. false: The relative pos of this landmark i...
mrpt::aligned_containers< TKeyFrameID, pose_flag_t >::map_t frameid2pose_map_t
"numeric" values of spanning tree poses:
POSE_TRAITS::pose_t pose_t
Will be mrpt::poses::CPose3D, ...
Eigen::Matrix< Scalar, N, M1 > matrix1_t
static const size_t OBS_DIMS
KF2KF_POSE_TYPE::pose_t pose_t
Symbolic information of each Hessian block.
lm_traits_t::TRelativeLandmarkPos * feat_rel_pos
A pointer to the relative position structure within rba_state.unknown_lms[] for this feature...
One relative feature observation entry, used with some relative bundle-adjustment functions...
THessianSymbolicInfoEntry()
V getTheOtherFromPair2(const V one, const K2K_EDGE &p)
For usage with K2K_EDGE = typename kf2kf_pose_traits
::k2k_edge_t.
static const size_t LM_DIMS
uint64_t TKeyFrameID
Numeric IDs for key-frames (KFs)