@@ -4,8 +4,8 @@ LocalGlobalMapperNode::LocalGlobalMapperNode(const ros::NodeHandle& nh)
4
4
: nh_(nh) {
5
5
initParams ();
6
6
7
- cloud_sub = nh_.subscribe (cloud_name_, 1 ,
8
- &LocalGlobalMapperNode::cloudCallback, this );
7
+ cloud_sub = nh_.subscribe (
8
+ cloud_name_, 1 , &LocalGlobalMapperNode::cloudCallback, this );
9
9
10
10
global_map_pub =
11
11
nh_.advertise <kr_planning_msgs::VoxelMap>(" global_voxel_map" , 1 , true );
@@ -116,9 +116,12 @@ void LocalGlobalMapperNode::globalMapInit() {
116
116
const double global_res = global_map_info_.resolution ;
117
117
int8_t global_val_default = 0 ;
118
118
// Initialize the mapper
119
- global_voxel_mapper_.reset (new mapper::VoxelMapper (
120
- global_origin, global_dim_d, global_res, global_val_default,
121
- global_decay_times_to_empty_));
119
+ global_voxel_mapper_.reset (
120
+ new mapper::VoxelMapper (global_origin,
121
+ global_dim_d,
122
+ global_res,
123
+ global_val_default,
124
+ global_decay_times_to_empty_));
122
125
123
126
// build the array for map inflation
124
127
global_infla_array_.clear ();
@@ -153,9 +156,12 @@ void LocalGlobalMapperNode::storageMapInit() {
153
156
const double res = storage_map_info_.resolution ;
154
157
int8_t storage_val_default = 0 ;
155
158
// Initialize the mapper
156
- storage_voxel_mapper_.reset (new mapper::VoxelMapper (
157
- storage_origin, storage_dim_d, res, storage_val_default,
158
- local_decay_times_to_empty_));
159
+ storage_voxel_mapper_.reset (
160
+ new mapper::VoxelMapper (storage_origin,
161
+ storage_dim_d,
162
+ res,
163
+ storage_val_default,
164
+ local_decay_times_to_empty_));
159
165
}
160
166
161
167
void LocalGlobalMapperNode::localInflaInit () {
@@ -213,15 +219,17 @@ void LocalGlobalMapperNode::getLidarPoses(
213
219
// for real robot, the point cloud frame_id may not exist in the tf tree,
214
220
// manually defining it here.
215
221
// TODO(xu): make this automatic
216
- auto tf_map_lidar = tf_listener.LookupTransform (map_frame_, lidar_frame_,
217
- cloud_header.stamp );
218
- auto tf_odom_lidar = tf_listener.LookupTransform (odom_frame_, lidar_frame_,
219
- cloud_header.stamp );
222
+ auto tf_map_lidar = tf_listener.LookupTransform (
223
+ map_frame_, lidar_frame_, cloud_header.stamp );
224
+ auto tf_odom_lidar = tf_listener.LookupTransform (
225
+ odom_frame_, lidar_frame_, cloud_header.stamp );
220
226
if ((!tf_map_lidar) || (!tf_odom_lidar)) {
221
227
ROS_WARN (
222
228
" [Mapper real-robot:] Failed to get transform (either from %s to %s; "
223
229
" or from %s to %s)" ,
224
- lidar_frame_.c_str (), map_frame_.c_str (), lidar_frame_.c_str (),
230
+ lidar_frame_.c_str (),
231
+ map_frame_.c_str (),
232
+ lidar_frame_.c_str (),
225
233
odom_frame_.c_str ());
226
234
return ;
227
235
} else {
@@ -237,13 +245,15 @@ void LocalGlobalMapperNode::getLidarPoses(
237
245
ROS_WARN (
238
246
" [Mapper simulation:] Failed to get transform map to lidar (from %s "
239
247
" to %s)" ,
240
- cloud_header.frame_id .c_str (), map_frame_.c_str ());
248
+ cloud_header.frame_id .c_str (),
249
+ map_frame_.c_str ());
241
250
return ;
242
251
} else if (!tf_odom_lidar) {
243
252
ROS_WARN (
244
253
" [Mapper simulation:] Failed to get transform odom to lidar (from %s "
245
254
" to %s)" ,
246
- cloud_header.frame_id .c_str (), odom_frame_.c_str ());
255
+ cloud_header.frame_id .c_str (),
256
+ odom_frame_.c_str ());
247
257
return ;
248
258
} else {
249
259
*pose_map_lidar_ptr = *tf_map_lidar;
@@ -262,8 +272,10 @@ void LocalGlobalMapperNode::processCloud(const sensor_msgs::PointCloud& cloud) {
262
272
geometry_msgs::Pose pose_odom_lidar;
263
273
getLidarPoses (cloud.header , &pose_map_lidar, &pose_odom_lidar);
264
274
265
- const Eigen::Affine3d T_map_lidar = toTF (pose_map_lidar);
266
- const Eigen::Affine3d T_odom_lidar = toTF (pose_odom_lidar);
275
+ const Eigen::Affine3d T_map_lidar =
276
+ kr_planning_rviz_plugins::toTF (pose_map_lidar);
277
+ const Eigen::Affine3d T_odom_lidar =
278
+ kr_planning_rviz_plugins::toTF (pose_odom_lidar);
267
279
268
280
// This is the lidar position in the odom frame, used for raytracing &
269
281
// cropping local map
@@ -283,12 +295,13 @@ void LocalGlobalMapperNode::processCloud(const sensor_msgs::PointCloud& cloud) {
283
295
double min_range = 0.75 ; // points within this distance will be discarded
284
296
double min_range_squared;
285
297
min_range_squared = min_range * min_range;
286
- const auto pts = cloud_to_vec_filter (cloud, min_range_squared);
298
+ const auto pts =
299
+ kr_planning_rviz_plugins::cloud_to_vec_filter (cloud, min_range_squared);
287
300
288
301
timer.start ();
289
302
// local raytracing using lidar position in the map frame (not odom frame)
290
- storage_voxel_mapper_->addCloud (pts, T_map_lidar, local_infla_array_, false ,
291
- local_max_raycast_);
303
+ storage_voxel_mapper_->addCloud (
304
+ pts, T_map_lidar, local_infla_array_, false , local_max_raycast_);
292
305
ROS_DEBUG (" [storage map addCloud]: %f" ,
293
306
static_cast <double >(timer.elapsed ().wall ) / 1e6 );
294
307
@@ -311,8 +324,8 @@ void LocalGlobalMapperNode::processCloud(const sensor_msgs::PointCloud& cloud) {
311
324
++counter_;
312
325
if (counter_ % update_interval_ == 0 ) {
313
326
timer.start ();
314
- global_voxel_mapper_->addCloud (pts, T_map_lidar, global_infla_array_, false ,
315
- global_max_raycast_);
327
+ global_voxel_mapper_->addCloud (
328
+ pts, T_map_lidar, global_infla_array_, false , global_max_raycast_);
316
329
ROS_DEBUG (" [global map addCloud]: %f" ,
317
330
static_cast <double >(timer.elapsed ().wall ) / 1e6 );
318
331
timer.start ();
@@ -334,8 +347,8 @@ void LocalGlobalMapperNode::processCloud(const sensor_msgs::PointCloud& cloud) {
334
347
global_map_pub.publish (global_map);
335
348
}
336
349
337
- ROS_DEBUG_THROTTLE (1 , " [Mapper]: Got cloud, number of points: [%zu] " ,
338
- cloud.points .size ());
350
+ ROS_DEBUG_THROTTLE (
351
+ 1 , " [Mapper]: Got cloud, number of points: [%zu] " , cloud.points .size ());
339
352
}
340
353
341
354
void LocalGlobalMapperNode::cloudCallback (
0 commit comments