Ask Your Question
1

Relative path doesnt work on yaml file with launch file

asked 2017-09-25 02:36:24 -0500

kiasoso gravatar image

updated 2017-09-25 02:36:53 -0500

I want to load a map into the rosparam server. My yaml file looks like this:

image: "./office_right2_parking.pgm"
resolution: 0.050000
origin: [0.0, 0.0, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196

The pgm file is in the same folder. The relative path doesn't work, I know this because when I use the absolute path my programme runs smoothly. The yaml file gets "executed" from this launch file:

<?xml version="1.0"?>
<launch>   
     <arg name="map_yaml" default="$(find localization)/include/maps/office_right2_parking.yaml"/>
     <rosparam command="load" file="$(arg map_yaml)" />

     <node name="ppm_main" pkg="navigation" type="ppm_main" output="screen" />  

</launch>

The launch file and the yaml file do not lay in the same directory.

Path of the yaml and map: src --> localization --> include --> maps

Path of the launch: src --> navigation --> launch

How can I make sure that the relative path works? The code will get executed on different computers, so absolute paths are not really the way to go. Changing the path of the launch file would be an option, but will be a lot of work to do and I havent looked into it.

I've read that relative paths reference to/from where you execute the launch file, but how can I make sure that every user makes the right decision in executing the launch file in the right place. This seems not very intuitive.

I hope you have any advice for me! Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-09-25 02:41:24 -0500

gvdhoorn gravatar image

I've read that relative paths reference to/from where you execute the launch file [..]

I don't believe this is actually true, and that this is what is causing you trouble.

See #q235337, #q236116, #q207149 and #q33890 for some related older questions.

In short: don't use paths relative to your file system (FS), but make them relative to a ROS package. Then use any of the tools provided to map those paths to absolute FS paths (ie: $(find <pkg name>), rospack find <pkg name>, etc) and things should start working like you expect.

edit flag offensive delete link more

Comments

So I would have to

  • either use $(find <pkg name>) in my yaml file (does this work?)

  • or edit the launch file, so that the parameter is set relative to my ROS package.

I will have a closer look at these (and maybe some other) options.

kiasoso gravatar image kiasoso  ( 2017-09-25 03:45:25 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-09-25 02:36:24 -0500

Seen: 3,190 times

Last updated: Sep 25 '17