Skip to content

Commit

Permalink
catch runtime_error if the message from laser is malformed (#2511)
Browse files Browse the repository at this point in the history
* catch runtime_error if the message from laser is malformed

* fix styling

Co-authored-by: Kai-Tao Xie <kaitaoxie@qq.com>
  • Loading branch information
2 people authored and SteveMacenski committed Sep 14, 2021
1 parent e326d3f commit 8316fa2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nav2_costmap_2d/plugins/obstacle_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ ObstacleLayer::laserScanCallback(
global_frame_.c_str(),
ex.what());
projector_.projectLaser(*message, cloud);
} catch (std::runtime_error & ex) {
RCLCPP_WARN(
logger_,
"transformLaserScanToPointCloud error, it seems the message from laser is malformed."
" Ignore this message. what(): %s",
ex.what());
return;
}

// buffer the point cloud
Expand Down Expand Up @@ -327,6 +334,13 @@ ObstacleLayer::laserScanValidInfCallback(
"High fidelity enabled, but TF returned a transform exception to frame %s: %s",
global_frame_.c_str(), ex.what());
projector_.projectLaser(message, cloud);
} catch (std::runtime_error & ex) {
RCLCPP_WARN(
logger_,
"transformLaserScanToPointCloud error, it seems the message from laser is malformed."
" Ignore this message. what(): %s",
ex.what());
return;
}

// buffer the point cloud
Expand Down

0 comments on commit 8316fa2

Please sign in to comment.