@@ -73,9 +73,11 @@ void periodic_publish_odoms( const NodeDataManager * manager, const VizPoseGraph
7373{
7474 cout << " Start `periodic_publish`\n " ;
7575 ros::Rate loop_rate (15 );
76- double offset_x = 30 ., offset_y=0 ., offset_z=0 .;
76+ // double offset_x = 30., offset_y=0., offset_z=0.;
77+ double offset_x = 0 ., offset_y=0 ., offset_z=0 .;
7778
7879 map<int , vector<Matrix4d> > jmb;
80+ bool published_axis = false ;
7981 while ( ros::ok () )
8082 {
8183 if ( manager->getNodeLen () == 0 ) {
@@ -132,9 +134,9 @@ void periodic_publish_odoms( const NodeDataManager * manager, const VizPoseGraph
132134 #endif
133135
134136
135- // only publish the latest odometry. Set this to zero if you dont need this.
136- #if 1
137- int to_publish_key = -1 ;
137+
138+ #if 1 // only publish the latest odometry. Set this to zero if you dont need this.
139+ int to_publish_key = -1 ; // lets the largest key value
138140 for ( auto it=jmb.begin () ; it!=jmb.end () ; it++ ) {
139141
140142 if ( it->first > to_publish_key && it->first >=0 )
@@ -151,6 +153,16 @@ void periodic_publish_odoms( const NodeDataManager * manager, const VizPoseGraph
151153 #endif
152154
153155
156+
157+ if ( published_axis==false || rand () % 100 == 0 ) {
158+ // Publish Axis - publish infrequently
159+ Matrix4d odm_axis_pose = Matrix4d::Identity ();
160+ odm_axis_pose (0 ,3 ) += offset_x; odm_axis_pose (1 ,3 ) += offset_y; odm_axis_pose (2 ,3 ) += offset_z;
161+ viz->publishXYZAxis ( odm_axis_pose, " odom-axis" , 0 );
162+ published_axis = true ;
163+ }
164+
165+
154166 loop_rate.sleep ();
155167 }
156168 cout << " END `periodic_publish`\n " ;
@@ -334,7 +346,7 @@ void opt_traj_publisher_colored_by_world( const NodeDataManager * manager, const
334346
335347 ros::Rate loop_rate (20 );
336348 map<int , vector<Matrix4d> > jmb;
337- vector< Vector3d > lbm; // a corrected poses. Same index as the node.
349+ vector< Vector3d > lbm; // a corrected poses. Same index as the node. These are used for loopedges.
338350 while ( ros::ok () )
339351 {
340352 // cout << "[opt_traj_publisher_colored_by_world]---\n";
@@ -361,7 +373,7 @@ void opt_traj_publisher_colored_by_world( const NodeDataManager * manager, const
361373 int world_id = manager->which_world_is_this ( manager->getNodeTimestamp (i) );
362374
363375 // i>=0 and i<solvedUntil()
364- if ( i>=0 && i< ____solvedUntil ) {
376+ if ( i>=0 && i<= ____solvedUntil ) {
365377 Matrix4d w_T_c_optimized, w_T_c;
366378
367379 // cerr << "world_id=" << world_id << " ";
@@ -393,20 +405,37 @@ void opt_traj_publisher_colored_by_world( const NodeDataManager * manager, const
393405
394406 // i>solvedUntil() < manager->getNodeLen() only odometry available here.
395407
396- if ( i>= (____solvedUntil) && manager-> getNodeLen () ) {
408+ if ( i>(____solvedUntil) ) {
397409 int last_idx=-1 ;
398410 Matrix4d w_TM_i;
399411
412+ /*
400413 if( ____solvedUntil == 0 ) {
401414 w_TM_i = manager->getNodePose( i );
402415 } else if( world_id < 0 ) {
403416 last_idx = manager->nodeidx_of_world_i_ended( -world_id-1 );
404417 } else if(world_id == ____solvedUntil_worldid && ____solvedUntil_worldid_is_neg==false) {
405418 last_idx = ____solvedUntil;
419+ }
420+ else if(world_id == ____solvedUntil_worldid && ____solvedUntil_worldid_is_neg==true) {
421+ last_idx = ____solvedUntil;
406422 } else {
407423 // last_idx = manager->nodeidx_of_world_i_started( world_id );
408424 w_TM_i = manager->getNodePose( i );
409425 }
426+ */
427+
428+ if ( ____solvedUntil == 0 ) {
429+ w_TM_i = manager->getNodePose ( i );
430+ } else {
431+ if ( world_id >= 0 && ____solvedUntil_worldid == world_id )
432+ last_idx = ____solvedUntil;
433+ else if ( world_id >=0 && ____solvedUntil_worldid != world_id )
434+ w_TM_i = manager->getNodePose ( i );
435+ else
436+ last_idx = ____solvedUntil;
437+
438+ }
410439
411440 if ( last_idx >= 0 ) {
412441 Matrix4d w_T_last = slam->getNodePose (last_idx );
0 commit comments