@@ -396,6 +396,10 @@ struct opt_traj_publisher_options
396396
397397 // The thickness of the lines
398398 float linewidth_multiplier=1.0 ;
399+
400+
401+ // Udumbe offset_y. When multiple co-ordinates exist, the offset for plotting on rviz. keep it 30.0
402+ float udumbe_offset_y = 30.0 ;
399403};
400404
401405// comment the following #define to remove the code which checks file's exisitance before printing.
@@ -1017,9 +1021,45 @@ void opt_traj_publisher_colored_by_world( const NodeDataManager * manager, const
10171021
10181022 }
10191023
1024+ // -----------------------------------------------------------------------------------------------//
1025+ // ------------------------- After this only uses jmb and lmb to publish -------------------------//
1026+ // -----------------------------------------------------------------------------------------------//
1027+
1028+ // ---
1029+ // --- Decide offset's (for plotting) different co-ordinate systems
1030+ // ---
1031+ #if 1
1032+ map< int , int > setids_to_udumbes;
1033+ if ( jmb.size () > 0 )
1034+ {
1035+ int h=0 ;
1036+ for ( auto it=jmb.begin () ; it!=jmb.end () ; it++ ) {
1037+ int setid = manager->getWorldsConstPtr ()->find_setID_of_world_i ( it->first );
1038+ if ( setid < 0 ) // ignore negative setids
1039+ continue ;
1040+ if ( setids_to_udumbes.count (setid) == 0 ) {
1041+ setids_to_udumbes[ setid ] = h;
1042+ h++;
1043+ }
1044+ }
1045+
1046+ #if 0
1047+ cout << TermColor::MAGENTA() << "---\n";
1048+ for( auto it=setids_to_udumbes.begin() ; it!=setids_to_udumbes.end() ; it++ ) {
1049+ cout << "setid=" << it->first << "\tudumbe=" << it->second << endl;
1050+ }
1051+ cout << TermColor::RESET();
1052+ #endif
1053+
1054+ }
1055+ #endif
1056+
1057+
1058+
10201059
10211060 // ---
1022- // --- Publish jmb
1061+ // --- Publish jmb.
1062+ // Note: jmb's keys are `worldIDs` and jmb's values are `vector<Matrix4d>& w_T_ci`
10231063 // ---
10241064 if ( jmb.size () == 0 )
10251065 {
@@ -1037,6 +1077,7 @@ void opt_traj_publisher_colored_by_world( const NodeDataManager * manager, const
10371077
10381078 float c_r=0 ., c_g=0 ., c_b=0 .;
10391079 int rng=-1 ;
1080+
10401081 if ( options.line_color_style == 10 )
10411082 rng = it->first ; // color by world id WorldID
10421083 else if ( options.line_color_style == 12 )
@@ -1060,7 +1101,21 @@ void opt_traj_publisher_colored_by_world( const NodeDataManager * manager, const
10601101 c_b = color[0 ]/255 .;
10611102 }
10621103
1063- viz->publishNodesAsLineStrip ( it->second , ns.c_str (), c_r, c_g, c_b, options.linewidth_multiplier );
1104+ int curr_set_id = manager->getWorldsConstPtr ()->find_setID_of_world_i ( it->first );
1105+ float offset_x=0 ., offset_y=0 ., offset_z=0 .;
1106+ if ( curr_set_id >= 0 ) {
1107+ if ( setids_to_udumbes.count (curr_set_id) > 0 ) {
1108+ // cout << "rng=" << rng << "setids_to_udumbes"<< setids_to_udumbes.at( rng ) << endl;
1109+ offset_y = setids_to_udumbes.at ( curr_set_id )*options.udumbe_offset_y ;
1110+ }
1111+ } else {
1112+ curr_set_id = manager->getWorldsConstPtr ()->find_setID_of_world_i ( -it->first -1 );
1113+ if ( setids_to_udumbes.count (curr_set_id) > 0 ) {
1114+ offset_y = setids_to_udumbes.at ( curr_set_id )*options.udumbe_offset_y ;
1115+ }
1116+ }
1117+
1118+ viz->publishNodesAsLineStrip ( it->second , ns.c_str (), c_r, c_g, c_b, options.linewidth_multiplier , offset_x, offset_y, offset_z );
10641119 }
10651120 // #endif
10661121
@@ -1091,7 +1146,25 @@ void opt_traj_publisher_colored_by_world( const NodeDataManager * manager, const
10911146 c_g = color[1 ]/255 .;
10921147 c_b = color[0 ]/255 .;
10931148 }
1094- viz->publishCameraVisualMarker ( wi_T_latest, " world##" , c_r, c_g, c_b, options.linewidth_multiplier , 20 );
1149+
1150+
1151+ int curr_set_id = manager->getWorldsConstPtr ()->find_setID_of_world_i ( latest_pose_worldid );
1152+ float offset_x=0 ., offset_y=0 ., offset_z=0 .;
1153+ if ( curr_set_id >= 0 ) {
1154+ if ( setids_to_udumbes.count (curr_set_id) > 0 ) {
1155+ // cout << "rng=" << rng << "setids_to_udumbes"<< setids_to_udumbes.at( rng ) << endl;
1156+ offset_y = setids_to_udumbes.at ( curr_set_id )*options.udumbe_offset_y ;
1157+ }
1158+ } else {
1159+ curr_set_id = manager->getWorldsConstPtr ()->find_setID_of_world_i ( -latest_pose_worldid-1 );
1160+ if ( setids_to_udumbes.count (curr_set_id) > 0 ) {
1161+ offset_y = setids_to_udumbes.at ( curr_set_id )*options.udumbe_offset_y ;
1162+ }
1163+ }
1164+
1165+ viz->publishCameraVisualMarker ( wi_T_latest, " world##" , c_r, c_g, c_b,
1166+ options.linewidth_multiplier , 20 ,
1167+ offset_x, offset_y, offset_z );
10951168
10961169
10971170 // Publish loop edges
@@ -1107,19 +1180,53 @@ void opt_traj_publisher_colored_by_world( const NodeDataManager * manager, const
11071180 auto pair = manager->getEdgeIdxInfo ( it );
11081181 int __a = pair.first ;
11091182 int __b = pair.second ;
1110- Vector3d ____apose = lbm[__a];
1111- Vector3d ____bpose = lbm[__b];
1183+
1184+ int __a_worldid = manager->which_world_is_this ( manager->getNodeTimestamp (__a) );
1185+ int __a_setid = manager->getWorldsConstPtr ()->find_setID_of_world_i ( __a_worldid );
1186+ int __b_worldid = manager->which_world_is_this ( manager->getNodeTimestamp (__b) );
1187+ int __b_setid = manager->getWorldsConstPtr ()->find_setID_of_world_i ( __b_worldid );
1188+ #if 0
1189+ cout << TermColor::CYAN() ;
1190+ cout << "it=" << it;
1191+ cout << "__a=" << __a << " __a_worldid=" << __a_worldid << " __a_setid=" << __a_setid << "\t|";
1192+ cout << "__b=" << __b << " __b_worldid=" << __b_worldid << " __b_setid=" << __b_setid << "\n";
1193+ cout << TermColor::RESET();
1194+ #endif
1195+
1196+ int __a_udumbe = 0 , __b_udumbe=0 ;
1197+ if ( setids_to_udumbes.count (__a_setid) > 0 )
1198+ __a_udumbe = setids_to_udumbes.at ( __a_setid );
1199+ if ( setids_to_udumbes.count (__b_setid) > 0 )
1200+ int __b_udumbe = setids_to_udumbes.at ( __b_setid );
1201+
1202+ Vector3d ____apose = lbm[__a] + Vector3d ( 0 ., options.udumbe_offset_y *__a_udumbe , 0.0 );
1203+ Vector3d ____bpose = lbm[__b] + Vector3d ( 0 ., options.udumbe_offset_y *__a_udumbe , 0.0 );
11121204
11131205 RosMarkerUtils::add_point_to_marker ( ____apose, linelist_marker, false );
11141206 RosMarkerUtils::add_point_to_marker ( ____bpose, linelist_marker, false );
11151207 }
11161208 viz->publishThisVisualMarker ( linelist_marker );
11171209
11181210
1211+ // if( published_axis || rand() % 100 == 0 ) {
11191212 if ( published_axis || rand () % 100 == 0 ) {
1120- Matrix4d _axis_pose = Matrix4d::Identity ();
11211213 // odm_axis_pose(0,3) += offset_x; odm_axis_pose(1,3) += offset_y; odm_axis_pose(2,3) += offset_z;
1122- viz->publishXYZAxis ( _axis_pose, " opt_traj_axis" , 0 );
1214+ // viz->publishXYZAxis( _axis_pose, "opt_traj_axis", 0 );
1215+
1216+ for ( int p=0 ; p<setids_to_udumbes.size () ; p++ ) {
1217+ Matrix4d _axis_pose = Matrix4d::Identity ();
1218+ _axis_pose (0 ,3 ) += 0.0 ; _axis_pose (1 ,3 ) += p*options.udumbe_offset_y ; _axis_pose (2 ,3 ) += 0.0 ;
1219+ viz->publishXYZAxis ( _axis_pose, " opt_traj_axis" , p, 2.0 );
1220+ }
1221+
1222+ if ( rand () %1000 == 0 ) {
1223+ // once in a while flush the unused co-ordinates
1224+ Matrix4d _axis_pose = Matrix4d::Identity ();
1225+ for ( int p=setids_to_udumbes.size () ; p<20 ; p++ ) {
1226+ viz->publishXYZAxis ( _axis_pose, " opt_traj_axis" , 0 , 0.0 );
1227+ }
1228+ }
1229+
11231230 published_axis = false ;
11241231 }
11251232
@@ -1355,7 +1462,8 @@ int main( int argc, char ** argv)
13551462 // 10 //< color the line with worldID
13561463 // 12 //< color the line with setID( worldID )
13571464 options.line_color_style = 10 ;
1358- options.linewidth_multiplier = 0.25 ;
1465+ options.linewidth_multiplier = 3 ; // 0.25; //8
1466+ options.udumbe_offset_y = 30.0 ;
13591467 std::thread th6 ( opt_traj_publisher_colored_by_world, manager, slam, viz, options );
13601468
13611469
@@ -1384,7 +1492,7 @@ int main( int argc, char ** argv)
13841492
13851493
13861494
1387- #define __LOGGING__ 1 // make this 1 to enable logging. 0 to disable logging. rememeber to catkin_make after this change
1495+ #define __LOGGING__ 0 // make this 1 to enable logging. 0 to disable logging. rememeber to catkin_make after this change
13881496 #if __LOGGING__
13891497 // Note: If using roslaunch to launch this node and when LOGGING is enabled,
13901498 // roslaunch sends a sigterm and kills this thread when ros::ok() returns false ie.
0 commit comments