@@ -1369,8 +1369,8 @@ bool PoseGraphSLAM::saveAsJSON(const string base_path)
13691369// the start of each worlds as constant. You can tune this as need be.
13701370// The reason I do not use ceres::SetParameterBlockConstant() is that it cannot be
13711371// set to not constant which hinders when the initial guess moves.
1372- // #define __reint_node_regularization_info( msg ) msg;
1373- #define __reint_node_regularization_info ( msg ) ;
1372+ #define __reint_node_regularization_info ( msg ) msg;
1373+ // #define __reint_node_regularization_info( msg ) ;
13741374
13751375
13761376// Print Ceres Brief Report and other info on solving
@@ -1570,37 +1570,52 @@ void PoseGraphSLAM::reinit_ceres_problem_onnewloopedge_optimize6DOF()
15701570
15711571 )
15721572 // compute the relative transforms between the 2 worlds
1573- Matrix4d wa_T_a = this ->getNodePose ( _a );
1574- Matrix4d wb_T_b = this ->getNodePose ( _b );
1573+ Matrix4d wa_T_a = manager ->getNodePose ( _a );
1574+ Matrix4d wb_T_b = manager ->getNodePose ( _b );
15751575 Matrix4d b_T_a_observed = manager->getEdgePose (e);
15761576
15771577 Matrix4d wb_T_a = wb_T_b * b_T_a_observed;
15781578 Matrix4d wb_T_wa = wb_T_a * wa_T_a.inverse ();
15791579 __reinit_loopedge_cout (
15801580 cout << " I just computed the rel pose between 2 worlds, wb_T_wa=" << TermColor::iBLUE () << PoseManipUtils::prettyprintMatrix4d (wb_T_wa) << TermColor::RESET () << endl;
15811581 )
1582+ // Done...!
15821583
1584+
1585+ // The following bit of code, records the setID states before `setPoseBetweenWorlds` and after `setPoseBetweenWorlds`
1586+ // This is done so that we know which world's base changed. This is used later to initialize/reinitialize the guesses for optimization
1587+
1588+ // ---- get setID (before)
15831589 std::map<int ,int > mipmap_before_union, mipmap_after_union;
15841590 __reinit_loopedge_cout (
15851591 cout << " CURRENT STATUS OF WORLDS (disjoint set) before:\n " ;
1586-
15871592 manager->getWorldsPtr ()->print_summary ();
15881593 )
15891594 manager->getWorldsPtr ()->getWorld2SetIDMap ( mipmap_before_union );
15901595
1596+
1597+
1598+ // ---- setPoseBetweenWorlds()
15911599 __reinit_loopedge_cout (
15921600 cout << " setting var rel_pose_between_worlds__wb_T_wa[ " << __b_world_is << " ," << __a_world_is << " ] = " << PoseManipUtils::prettyprintMatrix4d (wb_T_wa) << endl;
15931601 )
15941602 string info_string = " this pose computed from edge " + std::to_string (_a) + " <--> " + std::to_string (_b);
15951603 // THIS IS THE ONLY PLACE WHERE THE 2 SETS CAN MERGE AND THE SETID OF THE WORLDS CAN CHANGE.
15961604 manager->getWorldsPtr ()->setPoseBetweenWorlds ( __b_world_is, __a_world_is, wb_T_wa, info_string );
15971605
1606+
1607+
1608+
1609+ // ---- get setID (after)
15981610 __reinit_loopedge_cout (
15991611 cout << " CURRENT STATUS OF WORLDS (disjoint set) after:\n " ;
16001612 manager->getWorldsPtr ()->print_summary ();
16011613 )
16021614 manager->getWorldsPtr ()->getWorld2SetIDMap ( mipmap_after_union );
16031615
1616+
1617+
1618+ // ---- findout the changes from `mipmap_before_union` to `mipmap_after_union`
16041619 __reinit_loopedge_cout (
16051620 cout << TermColor::iWHITE ();
16061621 cout << " Changes in the setID of the worlds\n " ;
@@ -1889,13 +1904,13 @@ void PoseGraphSLAM::reinit_ceres_problem_onnewloopedge_optimize6DOF()
18891904
18901905 // Matrix4d ww_start_pose = manager->getNodePose(ww_start);
18911906 // Functionally similar to marking it as constant
1892- double regularization_weight = max ( 1 .1 , log ( 1 +ww_end - ww_start )/2 . );
1907+ double regularization_weight = max ( 2 .1 , log ( 1 +ww_end - ww_start )/2 . );
18931908
1894- for ( int s=0 ; s<1 ; s++ )
1909+ for ( int s=0 ; s<3 ; s++ )
18951910 {
18961911 __reint_node_regularization_info ( cout << " s=" << s << " " ; )
1897- // Matrix4d ww_start_pose = this->getNodePose(ww_start+s);
1898- Matrix4d ww_start_pose = manager->getNodePose (ww_start+s);
1912+ Matrix4d ww_start_pose = this ->getNodePose (ww_start+s);
1913+ // Matrix4d ww_start_pose = manager->getNodePose(ww_start+s);
18991914 __reint_node_regularization_info ( cout << " regularization_weight=" << regularization_weight << " ww_start_pose : " << PoseManipUtils::prettyprintMatrix4d ( ww_start_pose ) << endl; )
19001915 ceres::CostFunction * regularixa_cost = NodePoseRegularization::Create ( ww_start_pose, regularization_weight );
19011916 ceres::ResidualBlockId resi_id = reint_problem.AddResidualBlock ( regularixa_cost, NULL , get_raw_ptr_to_opt_variable_q (ww_start+s), get_raw_ptr_to_opt_variable_t (ww_start+s) );
0 commit comments