ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Add files to be loaded when ROS node is launched

asked 2023-07-10 02:52:49 -0500

Lilipop gravatar image

updated 2023-07-10 05:10:46 -0500

Hello ROS community,

I have a python code for a hardware device (radar) that uses a parameters.cfg file for hardware settings (independantly of ROS).

In the same code, I am creating a ROS node so that the device publishes its collected data.

When I use a launch file, the basic format is as follows :

 <node pkg="radar_uart" 

But when I do my $roslaunch radar radar.launch command, I get the error that it could not find the config file : [ No such file or directory 'radar_config30hz.cfg' ]

I tested by adding this line to the launch file, so the config would be loaded when launching the node :

<rosparam file="$(find radar)/src/radar_config30hz.cfg" command="load"/>

It is still not working and the new error is : [ Ressource not found: your_package_name ]

PS : As said the file is a not a dynamic reconfigure file, it just contains parameters to be used by the radar Hardware.

Please enlighten me on how to simly make the ros node find the file and use it when it launches.

Thanks and regards,


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-07-10 08:03:30 -0500

bluegiraffe-sc gravatar image


The error with the No such file or directory could be due to the fact that you are giving a relative path for radar_config30hz.cfg, assuming that the working directory of your node will be the one in which the .py file is. Be aware that this is not the case unless you specify it with the cwd attribute on launch. Find below some possible solutions:

  • From inside your Python script, get the location of the ROS package with rospack and specify the absolute path to the .cfg file. This is what I would personally do.
  • From inside your Python script, get the location of the Python file by following these instructions and specify the absolute path to the .cfg file
  • Specify the working directory to be the one where your .cfg file lies with the cwd argument in the launch file.

As for the Resource not found error, from what you have written, the error is simply that your package name is radar_uart, but then you ask ROS to find radar instead.

edit flag offensive delete link more



Thanks for the answer, effectively I was giving a path related to my src directory before doing the catkin_make, I looked for the ROS package and added the cfg file then modified the path based on its location in the ROS package.

Thanks a lot :)

Lilipop gravatar image Lilipop  ( 2023-07-11 02:54:50 -0500 )edit

Glad it helped!

A minor piece of advice on the use of ROS Answers: the message you have just posted, should have been a comment to my previous answer, rather than an answer itself. Sorry for being so pedantic!

bluegiraffe-sc gravatar image bluegiraffe-sc  ( 2023-07-11 02:59:37 -0500 )edit

Question Tools



Asked: 2023-07-10 02:52:49 -0500

Seen: 47 times

Last updated: Jul 11 '23