Exercise 2.5 of ROS Navigation

I am currently stuck on how to prepare the launch file in order to launch the map_server node in the map_server package to load the map I created called ‘my_map’. How do you go about with this?

launch
node pkg=“provide_map” type=“map_server” name=“map_server” output=“screen” args=“/home/user/catkin_ws/src/my_map.yaml”
/node
/launch

This is what I have done so far…but i’m getting an error saying:
ERROR: cannot launch node of type [provide_map/map_server]: Cannot locate node of type [map_server] in package [provide_map]. Make sure file exists in package path and permission is set to executable (chmod +x). The launch file does have executable permission.

Hi, welcome to the community @RA2004!

  • The error says the system can’t find your package provide_map. If the package exist, you can source the workspace it is in:
source ~/catkin_ws/devel/setup.bash
  • Make sure that your launch file is formatted correctly. Check against the sample code in the Jupyter Notebook.

@RA2004
If you are referring to the following exercise, then it didn’t ask you to create a launch file, only to use rosrun. Launch files are not needed for rosrun..

image

In any case, if you want to create a launch file for the command, your pkg (package) would be map_server, not provide_map as you specified in your launch file.

PS: this course assumes that you have a knowledge of ROS Basics. If you don’t have it, then I recommend that you take the ROS Basics in 5 Days course.

My bad….it’s exercise 2.5, I’ve tried it with changing the pkg to map_server, but I’m still getting an error. Would the type and node also be map_server? What I’m confused abt is that in the ROS basics course…normally the type argument is a python file, so what would it be in this case?

What error are you getting? Paste your updated launch file and the error message here. Take a screenshot of the error, including the command you ran that gave the error.

Something like this should work. Make sure you compile and source your workspace first:

<launch>
    <node pkg="map_server" type="map_server" name="provide_map_via_map_server" output="screen" args="/home/user/catkin_ws/src/my_map.yaml" />
</launch>

Then launch it with:

roslaunch provide_map [launch_filename].launch

launch>
node pkg=‘map_server’ type=‘map_server’ name=‘map_server’ output=‘screen’ args=‘/home/user/catkin_ws/src/my_map.yaml’>
/node>
/launch>

That was my launch file. The error I was getting was:
[ERROR] [1697188821.561966561]: Map_server could not open /home/user/catkin_ws/src/my_map.yaml.
[map_server-1] process has died [pid 2785, exit code 255, cmd /opt/ros/noetic/lib/map_server/map_server /home/user/catkin_ws/src/my_map.yaml __name:=map_server __log:=/home/user/.ros/log/d9ac2698-69a7-11ee-a81f-0242ac1c0006/map_server-1.log].
log file: /home/user/.ros/log/d9ac2698-69a7-11ee-a81f-0242ac1c0006/map_server-1*.log

I’ve tried it with your code for the launch file as well but I’m getting the same error. Also, can I ask why the name argument is provide_map (if that is the name of the package that I was meant to create)?

the command i ran was: roslaunch provide_map launch_file.launch

Is this the correct location of the map file? Did you create the map file?

The name argument can be anything meaningful, such as provide_map_via_map_server.

That’s the name your node will have on the operation system (OS) when launched. Usually the OS will add something to it (in this case provide_map becomes provide_map-1).

Oh got it thank you! It was just that the map file was in the wrong directory…it was saved in ~/catkin_ws and not ~/catkin_ws/src : ) Thank you

1 Like

You’re welcome!

Error messages usually point to the problem. You need to learn to read them as a developer. In this case, it said:

Map_server could not open /home/user/catkin_ws/src/my_map.yaml

And if it could not open the file, it could be that the file is:

  • not in the location
  • in the location but missing the right permissions
  • in the location but is corrupt

Thank you so much for your help!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.