1515#include < experimental/filesystem>
1616#include < string>
1717#include < memory>
18- #include < chrono>
1918
2019#include " rclcpp/rclcpp.hpp"
2120#include " nav2_map_server/map_io.hpp"
2221#include " test_constants/test_constants.h"
2322
2423#define TEST_DIR TEST_DIRECTORY
2524
26- using namespace std ::chrono_literals;
2725using namespace nav2_map_server ; // NOLINT
2826using std::experimental::filesystem::path;
2927
@@ -34,7 +32,8 @@ class TestPublisher : public rclcpp::Node
3432 : Node(" map_publisher" )
3533 {
3634 std::string pub_map_file = path (TEST_DIR) / path (g_valid_yaml_file);
37- LOAD_MAP_STATUS status = loadMapFromYaml (pub_map_file, msg_);
35+ nav_msgs::msg::OccupancyGrid msg;
36+ LOAD_MAP_STATUS status = loadMapFromYaml (pub_map_file, msg);
3837 if (status != LOAD_MAP_SUCCESS) {
3938 RCLCPP_ERROR (get_logger (), " Can not load %s map file" , pub_map_file);
4039 return ;
@@ -43,19 +42,11 @@ class TestPublisher : public rclcpp::Node
4342 map_pub_ = create_publisher<nav_msgs::msg::OccupancyGrid>(
4443 " map" ,
4544 rclcpp::QoS (rclcpp::KeepLast (1 )).transient_local ().reliable ());
46-
47- timer_ = create_wall_timer (300ms, std::bind (&TestPublisher::mapPublishCallback, this ));
45+ map_pub_->publish (msg);
4846 }
4947
5048protected:
51- void mapPublishCallback ()
52- {
53- map_pub_->publish (msg_);
54- }
55-
5649 rclcpp::Publisher<nav_msgs::msg::OccupancyGrid>::SharedPtr map_pub_;
57- rclcpp::TimerBase::SharedPtr timer_;
58- nav_msgs::msg::OccupancyGrid msg_;
5950};
6051
6152int main (int argc, char ** argv)
0 commit comments