@@ -4,8 +4,8 @@ LocalGlobalMapperNode::LocalGlobalMapperNode(const ros::NodeHandle& nh)
44 : nh_(nh) {
55 initParams ();
66
7- cloud_sub = nh_.subscribe (cloud_name_, 1 ,
8- &LocalGlobalMapperNode::cloudCallback, this );
7+ cloud_sub = nh_.subscribe (
8+ cloud_name_, 1 , &LocalGlobalMapperNode::cloudCallback, this );
99
1010 global_map_pub =
1111 nh_.advertise <kr_planning_msgs::VoxelMap>(" global_voxel_map" , 1 , true );
@@ -116,9 +116,12 @@ void LocalGlobalMapperNode::globalMapInit() {
116116 const double global_res = global_map_info_.resolution ;
117117 int8_t global_val_default = 0 ;
118118 // 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_));
122125
123126 // build the array for map inflation
124127 global_infla_array_.clear ();
@@ -153,9 +156,12 @@ void LocalGlobalMapperNode::storageMapInit() {
153156 const double res = storage_map_info_.resolution ;
154157 int8_t storage_val_default = 0 ;
155158 // 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_));
159165}
160166
161167void LocalGlobalMapperNode::localInflaInit () {
@@ -213,15 +219,17 @@ void LocalGlobalMapperNode::getLidarPoses(
213219 // for real robot, the point cloud frame_id may not exist in the tf tree,
214220 // manually defining it here.
215221 // 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 );
220226 if ((!tf_map_lidar) || (!tf_odom_lidar)) {
221227 ROS_WARN (
222228 " [Mapper real-robot:] Failed to get transform (either from %s to %s; "
223229 " 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 (),
225233 odom_frame_.c_str ());
226234 return ;
227235 } else {
@@ -237,13 +245,15 @@ void LocalGlobalMapperNode::getLidarPoses(
237245 ROS_WARN (
238246 " [Mapper simulation:] Failed to get transform map to lidar (from %s "
239247 " 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 ());
241250 return ;
242251 } else if (!tf_odom_lidar) {
243252 ROS_WARN (
244253 " [Mapper simulation:] Failed to get transform odom to lidar (from %s "
245254 " 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 ());
247257 return ;
248258 } else {
249259 *pose_map_lidar_ptr = *tf_map_lidar;
@@ -262,8 +272,10 @@ void LocalGlobalMapperNode::processCloud(const sensor_msgs::PointCloud& cloud) {
262272 geometry_msgs::Pose pose_odom_lidar;
263273 getLidarPoses (cloud.header , &pose_map_lidar, &pose_odom_lidar);
264274
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);
267279
268280 // This is the lidar position in the odom frame, used for raytracing &
269281 // cropping local map
@@ -283,12 +295,13 @@ void LocalGlobalMapperNode::processCloud(const sensor_msgs::PointCloud& cloud) {
283295 double min_range = 0.75 ; // points within this distance will be discarded
284296 double min_range_squared;
285297 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);
287300
288301 timer.start ();
289302 // 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_);
292305 ROS_DEBUG (" [storage map addCloud]: %f" ,
293306 static_cast <double >(timer.elapsed ().wall ) / 1e6 );
294307
@@ -311,8 +324,8 @@ void LocalGlobalMapperNode::processCloud(const sensor_msgs::PointCloud& cloud) {
311324 ++counter_;
312325 if (counter_ % update_interval_ == 0 ) {
313326 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_);
316329 ROS_DEBUG (" [global map addCloud]: %f" ,
317330 static_cast <double >(timer.elapsed ().wall ) / 1e6 );
318331 timer.start ();
@@ -334,8 +347,8 @@ void LocalGlobalMapperNode::processCloud(const sensor_msgs::PointCloud& cloud) {
334347 global_map_pub.publish (global_map);
335348 }
336349
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 ());
339352}
340353
341354void LocalGlobalMapperNode::cloudCallback (
0 commit comments