File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -60,15 +60,17 @@ class MapPublisher : public rclcpp::Node {
60
60
61
61
map_ = std::make_shared<GridMapGeo>();
62
62
map_->Load (file_path, false , color_path);
63
- timer_ = this ->create_wall_timer (5s, std::bind (&MapPublisher::timer_callback, this ));
63
+ auto timer_callback = [this ]() -> void {
64
+ auto msg = grid_map::GridMapRosConverter::toMessage (map_->getGridMap ());
65
+ if (msg) {
66
+ msg->header .stamp = now ();
67
+ original_map_pub_->publish (std::move (msg));
68
+ }
69
+ };
70
+ timer_ = this ->create_wall_timer (5s, timer_callback);
64
71
}
65
72
66
73
private:
67
- void timer_callback () {
68
- auto msg = grid_map::GridMapRosConverter::toMessage (map_->getGridMap ());
69
- msg->header .stamp = now ();
70
- original_map_pub_->publish (std::move (msg));
71
- }
72
74
rclcpp::TimerBase::SharedPtr timer_;
73
75
rclcpp::Publisher<grid_map_msgs::msg::GridMap>::SharedPtr original_map_pub_;
74
76
std::shared_ptr<GridMapGeo> map_;
You can’t perform that action at this time.
0 commit comments