diff --git a/src/test_tif_loader.cpp b/src/test_tif_loader.cpp index a1dddc4..98ab52c 100644 --- a/src/test_tif_loader.cpp +++ b/src/test_tif_loader.cpp @@ -60,14 +60,17 @@ class MapPublisher : public rclcpp::Node { map_ = std::make_shared(); 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::SharedPtr original_map_pub_; std::shared_ptr map_;