Skip to content

Commit

Permalink
Switch from bind to lambda for timer callback
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Friedman <[email protected]>
  • Loading branch information
Ryanf55 committed Jan 17, 2024
1 parent 341aaa5 commit 3d4c3f1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/test_tif_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ class MapPublisher : public rclcpp::Node {

map_ = std::make_shared<GridMapGeo>();
map_->Load(file_path, false, color_path);
timer_ = this->create_wall_timer(5s, std::bind(&MapPublisher::timer_callback, this));
auto timer_callback = [this]() -> void {
auto msg = grid_map::GridMapRosConverter::toMessage(map_->getGridMap());
if (msg) {
msg->header.stamp = now();
original_map_pub_->publish(std::move(msg));
}
};
timer_ = this->create_wall_timer(5s, timer_callback);
}

private:
void timer_callback() {
auto msg = grid_map::GridMapRosConverter::toMessage(map_->getGridMap());
original_map_pub_->publish(std::move(msg));
}
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<grid_map_msgs::msg::GridMap>::SharedPtr original_map_pub_;
std::shared_ptr<GridMapGeo> map_;
Expand Down

0 comments on commit 3d4c3f1

Please sign in to comment.