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

Ros noetic image cannot find files in volume

asked 2021-09-01 12:47:48 -0500

Idox gravatar image

updated 2021-09-01 13:16:38 -0500

I have a docker image of ros noetic : noetic-ros-core I have created a volume named catkin_ws connected to my personal noetic_ws:

sudo docker run --net=host --env="DISPLAY" -v ~/noetic_ws:/root/catkin_ws --name roslocal -it ros:noetic-ros-core roscore

In a second terminal I run a node connected to this with:

sudo docker exec -it roslocal bin/bash

But when I run my script

synt_win = loadmat('root/catkin_ws/synt_win.mat')['synt_win']

I get

FileNotFoundError: [Errno 2] No such file or directory: 'root/catkin_ws/synt_win.mat'

I also tried directing the script to my personal noetic_ws but this has not worked (and would not be logical to me if worked)

In my docker container the file exists.

I think this has more to do with how ROS works than how docker works but please correct me if I'm wrong.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-09-01 13:33:26 -0500

gvdhoorn gravatar image

You are using a relative path. That most likely won't work (search for previous Q&As mentioning relative paths).

edit flag offensive delete link more

Comments

Indeed thanks! https://answers.ros.org/question/2353...

Specifically this worked for me :

synt_win = loadmat('../catkin_ws/synt_win.mat')['synt_win']

Idox gravatar image Idox  ( 2021-09-01 13:40:29 -0500 )edit

All paths not starting with a / are relative.

I would strongly recommend to use absolute paths. Relative paths will not work reliably (this is not ROS-specific; any relative path will depend on the CWD being correct, which is really brittle).

Note that "absolute path" does not mean hard-coded. You can still just make it a ROS parameter or a launch file arg.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-01 13:52:57 -0500 )edit

What did you change @Mike Scheutzow?

gvdhoorn gravatar image gvdhoorn  ( 2021-09-03 02:06:52 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-09-01 12:47:48 -0500

Seen: 61 times

Last updated: Sep 01 '21