From 3628c012feaad8796e58a551fe065d074762e422 Mon Sep 17 00:00:00 2001 From: nakai-omer <108797279+nakai-omer@users.noreply.github.com> Date: Wed, 20 Jul 2022 18:05:31 +0300 Subject: [PATCH] Fix for #3078, fix image path in YAML --- 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 b26b09be38..99b63f1c5e 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); + + int file_name_index = mapdatafile.find_last_of("/\\"); + 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 <<