From e8047ce99be519d1eb991db008c4db60af0e9b97 Mon Sep 17 00:00:00 2001 From: nakai-omer <108797279+nakai-omer@users.noreply.github.com> Date: Thu, 21 Jul 2022 18:59:53 +0300 Subject: [PATCH] Fix for #3078, fix image path in YAML (#3082) * Fix for #3078, fix image path in YAML * Update map_io.cpp * Update map_io.cpp * Update map_io.cpp * Update map_io.cpp --- nav2_map_server/src/map_io.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nav2_map_server/src/map_io.cpp b/nav2_map_server/src/map_io.cpp index b26b09be38b..050fc63d66e 100644 --- a/nav2_map_server/src/map_io.cpp +++ b/nav2_map_server/src/map_io.cpp @@ -504,11 +504,14 @@ void tryWriteMapToFile( tf2::Matrix3x3 mat(tf2::Quaternion(orientation.x, orientation.y, orientation.z, orientation.w)); double yaw, pitch, roll; mat.getEulerYPR(yaw, pitch, roll); + + const int file_name_index = mapdatafile.find_last_of("/\\"); + std::string image_name = mapdatafile.substr(file_name_index + 1); YAML::Emitter e; e << YAML::Precision(3); e << YAML::BeginMap; - e << YAML::Key << "image" << YAML::Value << mapdatafile; + e << YAML::Key << "image" << YAML::Value << image_name; e << YAML::Key << "mode" << YAML::Value << map_mode_to_string(save_parameters.mode); e << YAML::Key << "resolution" << YAML::Value << map.info.resolution; e << YAML::Key << "origin" << YAML::Flow << YAML::BeginSeq << map.info.origin.position.x <<