@@ -111,6 +111,21 @@ bool PoseGraphSLAM::nodePoseExists( int i ) const //< returns if ith node pose e
111111
112112}
113113
114+ bool PoseGraphSLAM::nodePoseExists__nolock ( int i ) const // < returns if ith node pose exist
115+ {
116+ #if defined(___OPT_AS_DOUBLE_STAR )
117+ // std::lock_guard<std::mutex> lk(mutex_opt_vars);
118+ if ( i>= 0 && i<_opt_len_ )
119+ return true ;
120+ return false ;
121+ #else
122+ // std::lock_guard<std::mutex> lk(mutex_opt_vars);
123+ if ( i>=0 && i <opt_quat.size () )
124+ return true ;
125+ return false ;
126+ #endif
127+
128+ }
114129
115130void PoseGraphSLAM::allocate_and_append_new_opt_variable_withpose ( const Matrix4d& pose )
116131{
@@ -1671,7 +1686,7 @@ void PoseGraphSLAM::reinit_ceres_problem_onnewloopedge_optimize6DOF()
16711686 int setID_of__world_of_u = manager->getWorldsConstPtr ()->find_setID_of_world_i ( world_of_u );
16721687
16731688 // --------------> add odometry residue : u <---> u-f
1674- for ( int f=1 ; f<5 ; f++ ){
1689+ for ( int f=1 ; f<6 ; f++ ){
16751690 int world_of_u_m_f=-1 ;
16761691 if ( u-f >= 0 )
16771692 world_of_u_m_f = manager->which_world_is_this ( manager->getNodeTimestamp (u-f) );
@@ -1899,7 +1914,8 @@ void PoseGraphSLAM::reinit_ceres_problem_onnewloopedge_optimize6DOF()
18991914 continue ;
19001915 }
19011916 __reint_node_regularization_info ( cout << TermColor::CYAN () << " &&&&&&&&&&&&world#" << ww << " is in setID=" << ww_setid << " with ww_start=" << ww_start << " ww_end=" << ww_end << TermColor::RESET () << endl; )
1902- if ( (ww_setid >= 0 && ww_setid==ww) )
1917+ if ( (ww_setid >= 0 && ww_setid==ww) ) // < Mark only setIDs as constant,
1918+ // if( ww_setid >= 0 ) //< call all 0th nodes as constant
19031919 {
19041920 __reint_node_regularization_info ( cout << " Mark node#" << ww_start << " as constant. \n " ; )
19051921 reg_debug_info += " Mark node#" + to_string (ww_start) + " as constant \n " ;
@@ -1964,13 +1980,23 @@ void PoseGraphSLAM::reinit_ceres_problem_onnewloopedge_optimize6DOF()
19641980 reinit_ceres_problem_onnewloopedge_optimize6DOF_status = 2 ; // solving in progress.
19651981 eta.tic ();
19661982 {
1967- std::lock_guard<std::mutex> lk (mutex_opt_vars);
1983+ // note: ideally you want to acquire the lock before you Solve,
1984+ // so that other threads do not access the opt_vars through the slam->getPose().
1985+ // However, since ceres doesnot change the opt variable until the
1986+ // end it is usually alright to not acquire the block.
1987+ // By not locking here, the stall in the viz goes away.
1988+ // If someone has a better suggestion here, feel free to open a
1989+ // discussion on github-issues.
1990+
1991+ // std::lock_guard<std::mutex> lk(mutex_opt_vars);
19681992 ceres::Solve ( reint_options, &reint_problem, &reint_summary );
19691993
19701994 __reint_ceres_solve_info ( cout << " summary.termination_type = " << (ceres::TerminationType::CONVERGENCE == reint_summary.termination_type ) << endl; )
19711995 // if( reint_summary.termination_type == ceres::TerminationType::CONVERGENCE )
1996+ {
19721997 solved_until = node_len-1 ;
19731998 __reint_ceres_solve_info ( cout << " solved_until:=" << node_len-1 << endl; )
1999+ }
19742000
19752001 if ( reint_summary.termination_type == ceres::TerminationType::CONVERGENCE )
19762002 n_solve_convergences++;
0 commit comments