Skip to content

Commit 2e42ef4

Browse files
committed
publish disjoint set image rather than imshow it. Just cosmetic changes
1 parent 5b6006c commit 2e42ef4

4 files changed

Lines changed: 36 additions & 5 deletions

File tree

src/PoseGraphSLAM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ void PoseGraphSLAM::reinit_ceres_problem_onnewloopedge_optimize6DOF()
18801880
// reint_problem.SetParameterBlockConstant( get_raw_ptr_to_opt_variable_q(ww_start) );
18811881
// reint_problem.SetParameterBlockConstant( get_raw_ptr_to_opt_variable_t(ww_start) );
18821882

1883-
ceres::CostFunction * regularixa_cost = NodePoseRegularization::Create( getNodePose(ww_start), 1.2 );
1883+
ceres::CostFunction * regularixa_cost = NodePoseRegularization::Create( getNodePose(ww_start), 2.3 );
18841884
ceres::ResidualBlockId resi_id = reint_problem.AddResidualBlock( regularixa_cost, NULL, get_raw_ptr_to_opt_variable_q(ww_start), get_raw_ptr_to_opt_variable_t(ww_start) );
18851885
regularization_terms_list.push_back( resi_id );
18861886

src/VizPoseGraph.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ void VizPoseGraph::setVisualizationPublisher( const ros::Publisher& pub )
77
pub_pgraph = pub;
88
}
99

10+
void VizPoseGraph::setImagePublisher( const ros::Publisher& pub )
11+
{
12+
13+
pub_image = pub;
14+
}
15+
16+
17+
1018
// TODO removal
1119
void VizPoseGraph::setPathPublisher( const ros::Publisher& pub )
1220
{
@@ -453,3 +461,10 @@ void VizPoseGraph::publishThisVisualMarker( const visualization_msgs::Marker& th
453461
{
454462
pub_pgraph.publish( the_marker );
455463
}
464+
465+
466+
void VizPoseGraph::publishImage( const cv::Mat& im )
467+
{
468+
sensor_msgs::ImagePtr msg = cv_bridge::CvImage( std_msgs::Header(), "bgr8", im ).toImageMsg();
469+
pub_image.publish( msg );
470+
}

src/VizPoseGraph.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class VizPoseGraph
4040
public:
4141
VizPoseGraph( const NodeDataManager* _manager, const PoseGraphSLAM* _slam ) : manager(_manager), slam(_slam){};
4242
void setVisualizationPublisher( const ros::Publisher& pub );
43+
void setImagePublisher( const ros::Publisher& pub );
44+
4345
void setPathPublisher( const ros::Publisher& pub ); //< TODO: removal
4446
void setOdometryPublisher( const ros::Publisher& pub );
4547

@@ -60,14 +62,16 @@ class VizPoseGraph
6062
void publishSlamResidueVisual( int n ) const;
6163
void publishCameraVisualMarker( const Matrix4d& wTc, const string& ns, float r, float g, float b );
6264

63-
void publishThisVisualMarker( const visualization_msgs::Marker& the_marker );
65+
void publishThisVisualMarker( const visualization_msgs::Marker& the_marker );
66+
void publishImage( const cv::Mat& im );
6467

6568
private:
6669
const NodeDataManager * manager=NULL;
6770
const PoseGraphSLAM * slam = NULL;
6871

6972
// Publish Marker
7073
ros::Publisher pub_pgraph; //< Marker
74+
ros::Publisher pub_image; //< publishes image.
7175
ros::Publisher pub_path_opt; //< Path, TODO: Removal
7276
ros::Publisher pub_odometry_opt; // nav_msgs::Odometry //TODO Removal
7377
};

src/keyframe_pose_graph_slam_node.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,23 @@ void periodic_publish_optimized_poses_smart( const NodeDataManager * manager, co
245245
}
246246

247247

248-
void monitor_disjoint_set_datastructure( const NodeDataManager * manager )
248+
void monitor_disjoint_set_datastructure( const NodeDataManager * manager, const VizPoseGraph * viz )
249249
{
250250
ros::Rate loop_rate(1);
251251

252252
#if 1
253253
while( ros::ok() )
254254
{
255255
cv::Mat im_disp;
256-
manager->getWorldsConstPtr()->disjoint_set_status_image(im_disp);
256+
// manager->getWorldsConstPtr()->disjoint_set_status_image(im_disp); // will get bubles as well as the text
257+
manager->getWorldsConstPtr()->disjoint_set_status_image(im_disp, true, false); // only bubles
258+
259+
#if 1 // set this to zero to imshow the image. helpful for debugging.
260+
viz->publishImage( im_disp );
261+
#else
257262
cv::imshow( "disjoint_set_status_image" , im_disp );
258263
cv::waitKey(30);
264+
#endif
259265

260266
loop_rate.sleep();
261267
}
@@ -556,6 +562,11 @@ int main( int argc, char ** argv)
556562
ROS_INFO( "Publish to %s", marker_topic.c_str() );
557563
ros::Publisher pub = nh.advertise<visualization_msgs::Marker>( marker_topic , 1000 );
558564

565+
//--- Image ---//
566+
string im_topic = string( "viz/disjoint_set_status_image");
567+
ROS_INFO( "Publish Image to %s", im_topic.c_str() );
568+
ros::Publisher pub_im = nh.advertise<sensor_msgs::Image>( im_topic , 1000 );
569+
559570

560571
//--- Optimzied Path Publisher ---//
561572
string opt_path_topic = string( "opt_path");
@@ -583,13 +594,14 @@ int main( int argc, char ** argv)
583594
// another class for viz.
584595
VizPoseGraph * viz = new VizPoseGraph( manager, slam );
585596
viz->setVisualizationPublisher( pub );
597+
viz->setImagePublisher( pub_im );
586598
viz->setPathPublisher( pub_path );
587599
viz->setOdometryPublisher( pub_odometry_opt );
588600

589601
// setup manager publishers threads - adhoc
590602
// std::thread th3( periodic_publish_optimized_poses_smart, manager, slam, viz );
591603
std::thread th4( periodic_publish_odoms, manager, viz );
592-
std::thread th5( monitor_disjoint_set_datastructure, manager );
604+
std::thread th5( monitor_disjoint_set_datastructure, manager, viz );
593605

594606
opt_traj_publisher_options options;
595607
options.line_color_style = 10;

0 commit comments

Comments
 (0)