@@ -283,7 +283,7 @@ void Composer::bf_traj_publish_thread( int looprate ) const
283283{
284284 // --- Options
285285 const int options_line_color_style = 10 ; // should be either 10 or 12. 10:color by WorldID; 12: //color by world setID
286- const float options_linewidth_multiplier = 3 ; // thickness of the line
286+ const float options_linewidth_multiplier = 1 ; // thickness of the line
287287
288288 // ---
289289
@@ -396,7 +396,7 @@ void Composer::bf_traj_publish_thread( int looprate ) const
396396void Composer::cam_visual_publish_thread ( int looprate ) const
397397{
398398 // --- Options
399- const int options_linewidth_multiplier = 3 ; // default 3
399+ const int options_linewidth_multiplier = 1 ; // default 3
400400 // ---
401401
402402
@@ -448,7 +448,7 @@ void Composer::path_publish_thread( int looprate )
448448 nav_msgs::Path path_msg;
449449
450450 string path_topic = string ( " adhoc/xpath" );
451- ROS_INFO ( " [Composer::setup_200hz_publishers ] Publish to %s" , path_topic.c_str () );
451+ ROS_INFO ( " [Composer::path_publish_thread ] Publish to %s" , path_topic.c_str () );
452452 pub_hz200_marker = nh.advertise <nav_msgs::Path>( path_topic , 1000 );
453453
454454 ros::Publisher pub___path = nh.advertise <nav_msgs::Path>( path_topic , 1000 );
@@ -519,6 +519,83 @@ void Composer::path_publish_thread( int looprate )
519519 cout << TermColor::RED () << " Finished `Composer::path_publish_thread`\n " << TermColor::RESET () << endl;
520520}
521521
522+
523+ // #define __Composer__detailed_path_publish_thread__(msg) msg;
524+ #define __Composer__detailed_path_publish_thread__ (msg ) ;
525+ void Composer::detailed_path_publish_thread ( int looprate=30 )
526+ {
527+ cout << TermColor::GREEN () << " start `Composer::detailed_path_publish_thread` @" << looprate << " hz" << TermColor::RESET () << endl;
528+ cout << " [Composer::detailed_path_publish_thread]will use `b_cam_visual_publish` for terminating this thread\n " ;
529+ assert ( looprate > 0 && looprate < 50 );
530+
531+
532+ int n, prev_n = 0 ;
533+ nav_msgs::Path path_msg;
534+
535+ string path_topic = string ( " adhoc/xpath_detailed" );
536+ ROS_INFO ( " [Composer::detailed_path_publish_thread] Publish to %s" , path_topic.c_str () );
537+ ros::Publisher pub___path = nh.advertise <nav_msgs::Path>( path_topic , 1000 );
538+
539+ ros::Rate rate (looprate);
540+ Matrix4d imu_T_cam = Matrix4d::Identity (); bool flag_imu_T_cam = false ;
541+
542+ while ( b_cam_visual_publish )
543+ {
544+ rate.sleep ();
545+ {
546+ std::lock_guard<std::mutex> lk (mx);
547+
548+ nav_msgs::Path path_msg;
549+ path_msg.poses .clear ();
550+ __Composer__detailed_path_publish_thread__ ( cout << " ---\n " ; )
551+ for ( int i=0 ; i<global_lmb.size () ; i++ )
552+ {
553+ if ( flag_imu_T_cam == false )
554+ {
555+ imu_T_cam = manager->get_imu_T_cam ();
556+ flag_imu_T_cam = true ;
557+ }
558+
559+ if ( flag_imu_T_cam == false ) {
560+ cout << " FATAIL.....This cannot be happening.....\n " ;
561+ exit (1 );
562+ }
563+ Matrix4d wTc = global_lmb[i]; // this is pose of camera in the co-ordinate system of setID_of_worldID
564+ Matrix4d w_T_imu = wTc * imu_T_cam.inverse ();
565+
566+
567+ ros::Time stamp = manager->getNodeTimestamp (i);
568+ int worldID = manager->which_world_is_this ( stamp );
569+
570+
571+ if ( worldID < 0 )
572+ continue ;
573+ int setID_of_worldID = manager->getWorldsConstPtr ()->find_setID_of_world_i ( worldID );
574+
575+ __Composer__detailed_path_publish_thread__ (
576+ cout << " [Composer::detailed_path_publish_thread]worldID:" << worldID << " \t setID_of_worldID:" << setID_of_worldID << " \t " << PoseManipUtils::prettyprintMatrix4d (wTc) << endl;
577+ );
578+
579+ geometry_msgs::PoseStamped pose_i;
580+ pose_i.header .stamp = stamp;
581+ pose_i.header .frame_id = " worldID:" + to_string ( worldID )+" :" +" setID_of_worldID:" +to_string (setID_of_worldID);
582+
583+ // PoseManipUtils::eigenmat_to_geometry_msgs_Pose( wTc, pose_i.pose );
584+ PoseManipUtils::eigenmat_to_geometry_msgs_Pose ( w_T_imu, pose_i.pose );
585+
586+
587+ path_msg.poses .push_back ( pose_i );
588+ }
589+ __Composer__detailed_path_publish_thread__ (
590+ cout << " [Composer::detailed_path_publish_thread]PUBLISH....path_msg.poses.size=" << path_msg.poses .size () << endl;
591+ )
592+ pub___path.publish ( path_msg );
593+ }
594+ }
595+
596+ }
597+
598+
522599#define __Composer__w0_T_w1_publish_thread ( msg ) msg;
523600// #define __Composer__w0_T_w1_publish_thread( msg ) ;
524601void Composer::w0_T_w1_publish_thread ( int looprate )
@@ -698,8 +775,45 @@ void Composer::disjointset_statusimage_publish_thread( int looprate ) const
698775 cout << TermColor::RED () << " Finished `Composer::disjointset_statusimage_publish_thread`\n " << TermColor::RESET () << endl;
699776}
700777
778+ void Composer::disjointset_statusjson_publish_thread ( int looprate )
779+ {
780+ cout << TermColor::GREEN () << " start `Composer::disjointset_statusjson_publish_thread` @" << looprate << " hz" << TermColor::RESET () << endl;
781+ assert ( looprate > 0 && looprate < 50 );
782+
783+ string jsonstring_topic = string ( " adhoc/disjoint_set_status_jsonstring" );
784+ ROS_INFO ( " [Composer::disjointset_statusjson_publish_thread] Publish to %s" , jsonstring_topic.c_str () );
785+ ros::Publisher pub_jsonstring = nh.advertise <std_msgs::String>( jsonstring_topic , 1000 );
786+
787+
701788
702789
790+ ros::Rate rate (looprate);
791+ string prev_status_str = " " ;
792+ while ( b_disjointset_statusimage_publish )
793+ {
794+ rate.sleep ();
795+
796+ string curr_status_str = manager->getWorldsConstPtr ()->disjoint_set_status_json ().dump (4 );
797+ if ( prev_status_str.compare (curr_status_str) == 0 ) {
798+ // same as old, no point publishing
799+ __Composer__disjointset_statusimage_publish_thread (
800+ cout << " [Composer::disjointset_statusjson_publish_thread] No change in status, so dont publish image." << endl;
801+ )
802+ continue ;
803+ }
804+
805+ // publish only when changed, modify as need be.
806+ std_msgs::String msg;
807+ msg.data = curr_status_str;
808+ pub_jsonstring.publish ( msg );
809+
810+
811+
812+ prev_status_str = curr_status_str;
813+ }
814+
815+ cout << TermColor::RED () << " Finished `Composer::disjointset_statusjson_publish_thread`\n " << TermColor::RESET () << endl;
816+ }
703817
704818// ------ Publish body pose @200Hz ------//
705819
0 commit comments