Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue loading saved map when saved under a subdirectory #3078

Closed
nakai-omer opened this issue Jul 17, 2022 · 4 comments
Closed

Issue loading saved map when saved under a subdirectory #3078

nakai-omer opened this issue Jul 17, 2022 · 4 comments

Comments

@nakai-omer
Copy link
Contributor

Bug report

Required Info:

  • Operating System:
    • Ubuntu 22.04
  • ROS2 Version:
    • Humble
  • Version or commit hash:
    • ros-humble-navigation2 1.1.0-2jammy.20220607.182532
  • DDS implementation:
    • Fast-RTPS

Steps to reproduce issue

Call the map saver server with a map_url that includes a subdirectory:

ros2 service call /map_saver/save_map nav2_msgs/srv/SaveMap "{map_topic: map, map_url: maps/nakai_world, image_format: pgm, map_mode: trinary, free_thresh: 0.25, occupied_thresh: 0.65}"

Expected behavior

Output yaml file image file will have a relative path to the yaml file, and not to current working directory. Conversely, when loading the map, map_server should not append the yaml file's path to the image path, rather it should append the currect working directory to the image path.

Actual behavior

Image path inside the map's yaml file, is relative to current working directory and not to the yaml file.

image: maps/nakai_world.pgm 
mode: trinary
resolution: 0.05
origin: [-9.39e-05, -0.68, 0]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.25

Additional information

When trying to later load the map using map_server, getting the following error:

[ERROR] [map_io]: Failed to load image file ./maps/maps/nakai_world.pgm for reason: Magick: Unable to open file (./maps/maps/nakai_world.pgm) reported by magick/blob.c:3089 (OpenBlob)

All commands were ran under the same working directory.

@SteveMacenski
Copy link
Member

SteveMacenski commented Jul 18, 2022

@AlexeyMerzlyakov please add this to your queue.

Output yaml file image file will have a relative path to the yaml file, and not to current working directory.

The actual command is going to be relative to your requested location. Right, if you give a relative location, it'll be relative to where you called it. So assuming when you call SaveMap with a relative path for the yaml of ./my_relative/path, you're saying that the YAML is correct, yes? Its just the image file that is wrong?

Conversely, when loading the map, map_server should not append the yaml file's path to the image path, rather it should append the currect working directory to the image path.

It sounds like the image: maps/nakai_world.pgm needs to just me nakai_world.pgm and the file itself is stored in the relative directory maps. Is that what you're looking for? I agree that that would be sensible.

Please be very particular, when exact commands, directories executed, and output file locations / contents describe your problem so we can reproduce a minimal case and resolve it, where appropriate. Your existing description is a bit too non-specific and vague for me to grasp what you're saying the specific issue is.

@nakai-omer
Copy link
Contributor Author

First of all, thanks for the quick reply.

Directory structure:

  • src
    • maps
      • nakai_world.pgm
      • nakai_world.yaml

Current working directory is src.

Inside of src we run the following command:

ros2 service call /map_saver/save_map nav2_msgs/srv/SaveMap "{map_topic: map, map_url: maps/nakai_world, image_format: pgm, map_mode: trinary, free_thresh: 0.25, occupied_thresh: 0.65}"

Result, files are created as expected under the maps folder in the structure described above.

YAML contains:

image: maps/nakai_world.pgm 
mode: trinary
resolution: 0.05
origin: [-9.39e-05, -0.68, 0]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.25

Next, still under src directory we load a "map_server" node with the following config:

yaml_filename: "maps/nakai_world.yaml"

Result, map_server successfully loads nakai_world.yaml, but fails to load the nakai_world.pgm

[ERROR] [map_io]: Failed to load image file ./maps/maps/nakai_world.pgm for reason: Magick: Unable to open file (./maps/maps/nakai_world.pgm) reported by magick/blob.c:3089 (OpenBlob)

It could be solved in (at least) two ways:

  1. Inside the YAML file, map_saver will make the path to the map image relative to the location of the YAML file. In our case ./nakai_world.pgm or just nakai_world.pgm, instead of maps/nakai_world.pgm.
  2. map_server will look for the image without prefixing the YAML file's directory. In our case, instead of maps/maps/nakai_world.pgm, it should be just maps/nakai_world.pgm

@SteveMacenski
Copy link
Member

Makes sense. I think (1) is the easiest, basically just strip out any relative paths when saving the yaml's image field. If we always save them side-by-side anyway, then there's no reason for any prefix to exist there. That should be a relatively easy fix.

nakai-omer added a commit to nakai-omer/navigation2 that referenced this issue Jul 20, 2022
@nakai-omer
Copy link
Contributor Author

Created a PR #3082

SteveMacenski pushed a commit that referenced this issue Jul 21, 2022
* Fix for #3078, fix image path in YAML

* Update map_io.cpp

* Update map_io.cpp

* Update map_io.cpp

* Update map_io.cpp
SteveMacenski pushed a commit that referenced this issue Aug 24, 2022
* Fix for #3078, fix image path in YAML

* Update map_io.cpp

* Update map_io.cpp

* Update map_io.cpp

* Update map_io.cpp
SteveMacenski added a commit that referenced this issue Aug 24, 2022
* Fix size_t format specifier (#3003)

* clear up params file (#3004)

Signed-off-by: zhenpeng ge <zhenpeng.ge@qq.com>

* Bt test fix (#2999)

* fixed tests

* undo

* linting fix (#3007)

Signed-off-by: zhenpeng ge <zhenpeng.ge@qq.com>

* Add nav2_constrained_smoother to metapackage

* adding humble release to table (#3008)

* Fix for costmap nodes lifecycle status (#3009)

Lifecycle status for global and local cost nodes not correct.
ros2 lifecycle/service commands  shows unconfigured for these two.
This is due to directly calling on_configure/on_activate/on_cleanup
calls in parent node.  This PR to replace on_xxxxxx() to
configure()/activate()/cleanup() calls of lifecycle base.

Signed-off-by: Arshad <arshad.mehmood@intel.com>

* Get parameters on configure transition addressing #2985 (#3000)

* Get parameters on configure transition

Signed-off-by: MartiBolet <mboletboixeda@gmail.com>

* Remove past setting of parameters

Signed-off-by: MartiBolet <mboletboixeda@gmail.com>

* Expose transition functions to public for test

Signed-off-by: MartiBolet <mboletboixeda@gmail.com>

* fix: wrong input type in navigate_to_pose_action.hpp and navigate_to_… (#2994)

* fix: wrong input type in navigate_to_pose_action.hpp and navigate_to_pose_action.hpp

* Update navigate_through_poses_action.hpp

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Nav2 Velocity Smoother (#2964)

* WIP velocity smoother with ruckig

* a few comments

* vel smoother prototype

* updating defaults

* adding defaults to readme

* removing note from readme

* updates to velocity smoother TODO items

* adding unit tests

* finishing system tests

* adding failure to change parameters tests

* fix last bits

* fixing negative sign bug

* lint

* update tests

* setting defaults

* Adding warning

* Update velocity_smoother.cpp

* Fixing rebase issue

* adding plugin type for static in local + removing unused print (#3021)

* removed extra includes (#3026)

* remove extra sub (#3025)

* Fix missing dependency on nav2_velocity_smoother (#3031)

* adding timeout for action client initialization (#3029)

* adding timeout for action client initialization

Signed-off-by: Vinny Ruia <vinny.ruia@fireflyautomatix.com>

* adding constant 1s timeout, catching exception

Signed-off-by: Vinny Ruia <vinny.ruia@fireflyautomatix.com>

* cleanup warnings (#3028)

* cleanup warnings

* removed referenc

* installing plugins folder of nav2_behaviors package (#3051)

Co-authored-by: Srijanee Biswas <srijanee.biswas@toyotatmh.com>

* Completed PR 2929 (#3038)

* accepting empty yaml_filename if no initial map is available

* invalid load_map-request does not invalidate existing map, added Testcase

* style

* finish PR 2929

* finish linting

* removing change

* removing change

* Update test_map_server_node.cpp

* Update test_map_server_node.cpp

Co-authored-by: Nikolas Engelhard <nikolas.engelhard@gmail.com>

* zero z values in rpp transformed plan (#3066)

* removing get node options default for nav2 utils (#3073)

* adding looping timeout for lifecycle service clients + adding string name of action for BT action nodes (#3071)

* adding looping timeout for lifecycle service clients + adding string name of action for BT action nodes

* fix linting

* remove inline comment

* adding goal updated controller node to test

* Smac Planner 2D changes (#3083)

* removing 4-connected option from smac; fixing 2D heuristic and traversal function from other planner's changes

* fix name of variable since no longer a neighborhood

* partial test updates

* ported unit tests fully

* revert to no costmap downsampling

* Collision monitor (#2982)

* Add Collision Monitor node

* Meet review items

* Fix next review items

* Code cleanup

* Support dynamic footprint. More optimizations.

* Switch to multiple footprints. Move variables.
Remove odom subscriber. Add 0-velocity optimization

* Update nav2_collision_monitor/include/nav2_collision_monitor/polygon.hpp

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/params/collision_monitor_params.yaml

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/params/collision_monitor_params.yaml

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/params/collision_monitor_params.yaml

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Meet smaller review items

* Add fixes found during unit test development

* Fix uncrustify issues

* Add unit tests

* Fix number of polygons points

* Move tests

* Add kinematics unit test

* Minor tests fixes

* Remove commented line

* Add edge case checking testcase and references

* Update comment

* Add README.md

* Fixed table

* Minor changes in README.md

* Fix README.md for documentation pages

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Update nav2_collision_monitor/README.md

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* Meet review items

* Meet review items (part 2)

* Update polygons picture for README

* Change simulation_time_step to 0.1

* Fix bounding boxes to fit the demo from README.md

* Terminology fixes

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

* removing the extra argument in class dec (#3084)

* 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

* do not depend on velocity for approach scaling (#3047)

* do not depend on velocity for approach scaling

* add approach_velocity_scaling_dist to README

* do not pass references to shared ptr

* fixup! do not pass references to shared ptr

* fix approach velocity scaling compile issues

* default approach_velocity_scaling_dist based on costmap size

* change default approach_velocity_scaling_dist to 0.6 to match previous behavior

* update tests for approach velocity scaling

* remove use_approach_linear_velocity_scaling from readme

* smooth approach velocity scaling

* Use correct timeout when checking future (#3087)

* Adds missing commas so default plugin names are not stuck together (#3093)

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>

* Fix Costmap Filters system tests (#3120)

* Fix Costmap Filters system tests

* Update map_io.cpp

Co-authored-by: Alexey Merzlyakov <alexey.merzlyakov@samsung.com>

* Finding distance H if obstacle H is <= 0 (#3122)

* adding checks on goal IDs in results for waypoint follower (#3130)

* ComputePathToPose Sets empty path on blackboard if action is aborted or cancelled (#3114)

* set empty path on black on failure

* docs

* switched to correct message type

* set empty path for compute_path_through_poses

* Ignore feedback from old goals in waypoint follower (#3139)

* apply joinchar in pathify (#3141)

Co-authored-by: kevin <kevin@floatic.io>

* Log level (#3110)

* added log level for navigation launch

* localization log level

* slam log level

* revert use_comp

* added log level to components

* linting and uncrusitfy fixes for CI (#3144)

* start is now added to the path (#3140)

* start is now added to the path

* lint fix

* Update README.md (#3147)

Current example doesn't work with the updates.

* fixing linting problem

* Setting map map's yaml path to empty string, since overridden in launch (#3123)

* Update nav2_params.yaml

* Update nav2_params.yaml

* Update nav2_params.yaml

* bumping to 1.1.1 for release

Signed-off-by: zhenpeng ge <zhenpeng.ge@qq.com>
Signed-off-by: Arshad <arshad.mehmood@intel.com>
Signed-off-by: MartiBolet <mboletboixeda@gmail.com>
Signed-off-by: Vinny Ruia <vinny.ruia@fireflyautomatix.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Co-authored-by: M. Mostafa Farzan <m2_farzan@yahoo.com>
Co-authored-by: Zhenpeng Ge <zhenpeng.ge@qq.com>
Co-authored-by: Joshua Wallace <47819219+jwallace42@users.noreply.github.com>
Co-authored-by: Arshad Mehmood <arshad.mehmood@intel.com>
Co-authored-by: MartiBolet <43337758+MartiBolet@users.noreply.github.com>
Co-authored-by: shoufei <907575489@qq.com>
Co-authored-by: hodnajit <jitkahodna67@gmail.com>
Co-authored-by: Vinny Ruia <vinny.ruia@fireflyautomatix.com>
Co-authored-by: SrijaneeBiswas <30804865+SrijaneeBiswas@users.noreply.github.com>
Co-authored-by: Srijanee Biswas <srijanee.biswas@toyotatmh.com>
Co-authored-by: Nikolas Engelhard <nikolas.engelhard@gmail.com>
Co-authored-by: Adam Aposhian <aposhian.dev@gmail.com>
Co-authored-by: Alexey Merzlyakov <60094858+AlexeyMerzlyakov@users.noreply.github.com>
Co-authored-by: Pradheep Krishna <padhupradheep@gmail.com>
Co-authored-by: nakai-omer <108797279+nakai-omer@users.noreply.github.com>
Co-authored-by: Samuel Lindgren <samuel@dynorobotics.se>
Co-authored-by: Aaron Chong <aaronchongth@gmail.com>
Co-authored-by: Alexey Merzlyakov <alexey.merzlyakov@samsung.com>
Co-authored-by: Pedro Alejandro González <71234974+pepisg@users.noreply.github.com>
Co-authored-by: 정찬희 <60467877+ladianchad@users.noreply.github.com>
Co-authored-by: kevin <kevin@floatic.io>
Co-authored-by: Austin Greisman <92941098+austin-InDro@users.noreply.github.com>
jwallace42 pushed a commit to jwallace42/navigation2 that referenced this issue Dec 14, 2022
)

* Fix for ros-navigation#3078, fix image path in YAML

* Update map_io.cpp

* Update map_io.cpp

* Update map_io.cpp

* Update map_io.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants