@@ -54,7 +54,7 @@ class MapPublisher : public rclcpp::Node {
54
54
original_map_pub_ = this ->create_publisher <grid_map_msgs::msg::GridMap>(" elevation_map" , 1 );
55
55
56
56
const std::string gdal_dataset_path = this ->declare_parameter (" gdal_dataset_path" , " ." );
57
- const std::string color_path = this ->declare_parameter (" tif_color_path " , " . " );
57
+ const std::string color_path = this ->declare_parameter (" gdal_dataset_color_path " , COLOR_MAP_DEFAULT_PATH );
58
58
rcl_interfaces::msg::ParameterDescriptor max_map_descriptor;
59
59
max_map_descriptor.read_only = true ;
60
60
max_map_descriptor.description =
@@ -74,20 +74,25 @@ class MapPublisher : public rclcpp::Node {
74
74
std::clamp (this ->declare_parameter (" max_map_height" , 1024 , max_map_descriptor),
75
75
max_map_descriptor_int_range.from_value , max_map_descriptor_int_range.to_value );
76
76
77
- RCLCPP_INFO_STREAM (get_logger (), " file_path " << file_path );
78
- RCLCPP_INFO_STREAM (get_logger (), " color_path " << color_path);
77
+ RCLCPP_INFO_STREAM (get_logger (), " gdal_dataset_path: ' " << gdal_dataset_path << " ' " );
78
+ RCLCPP_INFO_STREAM (get_logger (), " gdal_dataset_color_path: ' " << color_path << " ' " );
79
79
80
80
map_ = std::make_shared<GridMapGeo>();
81
81
map_->setMaxMapSizePixels (max_map_width, max_map_height);
82
82
map_->Load (gdal_dataset_path, false , color_path);
83
- // timer_ = this->create_wall_timer(5s, std::bind(&MapPublisher::timer_callback, this));
83
+
84
+ auto timer_callback = [this ]() -> void {
85
+ auto msg = grid_map::GridMapRosConverter::toMessage (map_->getGridMap ());
86
+ if (msg) {
87
+ msg->header .stamp = now ();
88
+ original_map_pub_->publish (std::move (msg));
89
+ }
90
+ };
91
+ timer_ = this ->create_wall_timer (5s, timer_callback);
84
92
}
85
93
86
94
private:
87
- void timer_callback () {
88
- auto msg = grid_map::GridMapRosConverter::toMessage (map_->getGridMap ());
89
- original_map_pub_->publish (std::move (msg));
90
- }
95
+ void timer_callback () {}
91
96
rclcpp::TimerBase::SharedPtr timer_;
92
97
rclcpp::Publisher<grid_map_msgs::msg::GridMap>::SharedPtr original_map_pub_;
93
98
std::shared_ptr<GridMapGeo> map_;
0 commit comments