@@ -7,14 +7,19 @@ namespace loam
7
7
8
8
void ImageProjection::onInit ()
9
9
{
10
+ NODELET_INFO (" ---------- ImageProjection init -----------" );
10
11
TicToc t_init;
11
- nh_ = getNodeHandle ();
12
+ nh_ = getMTNodeHandle ();
12
13
13
- seg_info_msg_.startRingIndex .resize (N_SCAN);
14
- seg_info_msg_.endRingIndex .resize (N_SCAN);
15
- seg_info_msg_.segmentedCloudColInd .assign (N_SCAN * Horizon_SCAN, false );
16
- seg_info_msg_.segmentedCloudGroundFlag .assign (N_SCAN * Horizon_SCAN, 0 );
17
- seg_info_msg_.segmentedCloudRange .assign (N_SCAN * Horizon_SCAN, 0 );
14
+ segmented_cloud_msg_.reset (new sensor_msgs::PointCloud2 ());
15
+ seg_info_msg_.reset (new alego::cloud_info ());
16
+ outlier_cloud_msg_.reset (new sensor_msgs::PointCloud2 ());
17
+
18
+ seg_info_msg_->startRingIndex .resize (N_SCAN);
19
+ seg_info_msg_->endRingIndex .resize (N_SCAN);
20
+ seg_info_msg_->segmentedCloudColInd .assign (N_SCAN * Horizon_SCAN, false );
21
+ seg_info_msg_->segmentedCloudGroundFlag .assign (N_SCAN * Horizon_SCAN, 0 );
22
+ seg_info_msg_->segmentedCloudRange .assign (N_SCAN * Horizon_SCAN, 0 );
18
23
full_cloud_.reset (new PointCloudT ());
19
24
segmented_cloud_.reset (new PointCloudT ());
20
25
outlier_cloud_.reset (new PointCloudT ());
@@ -33,34 +38,34 @@ void ImageProjection::onInit()
33
38
neighbor_iter_.emplace_back (0 , 1 );
34
39
35
40
pub_segmented_cloud_ = nh_.advertise <sensor_msgs::PointCloud2>(" /segmented_cloud" , 10 );
36
- pub_seg_info_ = nh_.advertise <sensor_msgs::PointCloud2 >(" /seg_info" , 10 );
41
+ pub_seg_info_ = nh_.advertise <alego::cloud_info >(" /seg_info" , 10 );
37
42
pub_outlier_ = nh_.advertise <sensor_msgs::PointCloud2>(" /outlier" , 10 );
38
43
sub_pc_ = nh_.subscribe <sensor_msgs::PointCloud2>(" /lslidar_point_cloud" , 10 , boost::bind (&ImageProjection::pcCB, this , _1));
39
- cout << " onInit end: " << t_init.toc () << endl ;
44
+ NODELET_INFO_STREAM ( " ImageProjection onInit end: " << t_init.toc ()) ;
40
45
}
41
46
42
47
void ImageProjection::pcCB (const sensor_msgs::PointCloud2ConstPtr &msg)
43
48
{
44
- cout << " pcCB" << endl;
49
+ // cout << "pcCB" << endl;
45
50
TicToc t_whole;
46
51
47
- seg_info_msg_. header = msg->header ;
52
+ seg_info_msg_-> header = msg->header ;
48
53
PointCloudT::Ptr cloud_in (new PointCloudT ());
49
54
pcl::fromROSMsg (*msg, *cloud_in);
50
55
// ROS_INFO("cloud_in size: %d", cloud_in->points.size());
51
56
52
57
int cloud_size = cloud_in->points .size ();
53
- seg_info_msg_. startOrientation = -atan2 (cloud_in->points [0 ].y , cloud_in->points [0 ].x );
54
- seg_info_msg_. endOrientation = -atan2 (cloud_in->points [cloud_size - 1 ].y , cloud_in->points [cloud_size - 1 ].x ) + 2 * M_PI;
55
- if (seg_info_msg_. endOrientation - seg_info_msg_. startOrientation > 3 * M_PI)
58
+ seg_info_msg_-> startOrientation = -atan2 (cloud_in->points [0 ].y , cloud_in->points [0 ].x );
59
+ seg_info_msg_-> endOrientation = -atan2 (cloud_in->points [cloud_size - 1 ].y , cloud_in->points [cloud_size - 1 ].x ) + 2 * M_PI;
60
+ if (seg_info_msg_-> endOrientation - seg_info_msg_-> startOrientation > 3 * M_PI)
56
61
{
57
- seg_info_msg_. endOrientation -= 2 * M_PI;
62
+ seg_info_msg_-> endOrientation -= 2 * M_PI;
58
63
}
59
- else if (seg_info_msg_. endOrientation - seg_info_msg_. startOrientation < M_PI)
64
+ else if (seg_info_msg_-> endOrientation - seg_info_msg_-> startOrientation < M_PI)
60
65
{
61
- seg_info_msg_. endOrientation += 2 * M_PI;
66
+ seg_info_msg_-> endOrientation += 2 * M_PI;
62
67
}
63
- seg_info_msg_. orientationDiff = seg_info_msg_. endOrientation - seg_info_msg_. startOrientation ;
68
+ seg_info_msg_-> orientationDiff = seg_info_msg_-> endOrientation - seg_info_msg_-> startOrientation ;
64
69
65
70
float vertical_ang, horizon_ang;
66
71
int row_id, col_id, index ;
@@ -145,7 +150,7 @@ void ImageProjection::pcCB(const sensor_msgs::PointCloud2ConstPtr &msg)
145
150
int line_size = 0 ;
146
151
for (int i = 0 ; i < N_SCAN; ++i)
147
152
{
148
- seg_info_msg_. startRingIndex [i] = line_size + 5 ;
153
+ seg_info_msg_-> startRingIndex [i] = line_size + 5 ;
149
154
for (int j = 0 ; j < Horizon_SCAN; ++j)
150
155
{
151
156
if (label_mat_ (i, j) > 0 || ground_mat_ (i, j) == 1 )
@@ -167,18 +172,14 @@ void ImageProjection::pcCB(const sensor_msgs::PointCloud2ConstPtr &msg)
167
172
}
168
173
}
169
174
170
- seg_info_msg_. segmentedCloudGroundFlag [line_size] = (ground_mat_ (i, j) == 1 );
171
- seg_info_msg_. segmentedCloudColInd [line_size] = j;
172
- seg_info_msg_. segmentedCloudRange [line_size] = range_mat_ (i, j);
175
+ seg_info_msg_-> segmentedCloudGroundFlag [line_size] = (ground_mat_ (i, j) == 1 );
176
+ seg_info_msg_-> segmentedCloudColInd [line_size] = j;
177
+ seg_info_msg_-> segmentedCloudRange [line_size] = range_mat_ (i, j);
173
178
segmented_cloud_->points .push_back (full_cloud_->points [j + i * Horizon_SCAN]);
174
179
++line_size;
175
180
}
176
- else if (label_mat_ (i, j) == 0 && range_mat_ (i, j) != std::numeric_limits<float >::max ())
177
- {
178
- ROS_WARN (" error" );
179
- }
180
181
}
181
- seg_info_msg_. endRingIndex [i] = line_size - 1 - 5 ;
182
+ seg_info_msg_-> endRingIndex [i] = line_size - 1 - 5 ;
182
183
}
183
184
publish ();
184
185
@@ -195,7 +196,7 @@ void ImageProjection::pcCB(const sensor_msgs::PointCloud2ConstPtr &msg)
195
196
nan_p.intensity = -1 ;
196
197
std::fill (full_cloud_->points .begin (), full_cloud_->points .end (), nan_p);
197
198
198
- std::cout << " image projection time: " << t_whole.toc () << " ms" << std::endl;
199
+ // std::cout << "image projection time: " << t_whole.toc() << " ms" << std::endl;
199
200
}
200
201
201
202
void ImageProjection::labelComponents (int row, int col)
@@ -314,14 +315,14 @@ void ImageProjection::publish()
314
315
}
315
316
if (pub_segmented_cloud_.getNumSubscribers () > 0 )
316
317
{
317
- pcl::toROSMsg (*segmented_cloud_, segmented_cloud_msg_);
318
- segmented_cloud_msg_. header = seg_info_msg_. header ;
318
+ pcl::toROSMsg (*segmented_cloud_, * segmented_cloud_msg_);
319
+ segmented_cloud_msg_-> header = seg_info_msg_-> header ;
319
320
pub_segmented_cloud_.publish (segmented_cloud_msg_);
320
321
}
321
322
if (pub_outlier_.getNumSubscribers () > 0 )
322
323
{
323
- pcl::toROSMsg (*outlier_cloud_, outlier_cloud_msg_);
324
- outlier_cloud_msg_. header = seg_info_msg_. header ;
324
+ pcl::toROSMsg (*outlier_cloud_, * outlier_cloud_msg_);
325
+ outlier_cloud_msg_-> header = seg_info_msg_-> header ;
325
326
pub_outlier_.publish (outlier_cloud_msg_);
326
327
}
327
328
}
0 commit comments