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

rosrun error FileNotFoundError: [Errno 2] No such file or directory

asked 2019-01-10 09:25:26 -0500

MCVB gravatar image

updated 2019-01-10 10:02:51 -0500

gvdhoorn gravatar image

I'm trying to run

rosrun package python scripts

and get some errors below:

(cv-py3) hoang@hoang-Nitro-AN515-51:~/catkin_ws$ rosrun testpy test.py 
Parsing cfg/tiny-yolo-voc-3c.cfg
Traceback (most recent call last):
  File "/home/hoang/catkin_ws/src/testpy/src/test.py", line 41, in <module>
    tfnet = TFNet(options)
  File "/home/hoang/catkin_ws/src/testpy/src/darkflow/net/build.py", line 58, in __init__
    darknet = Darknet(FLAGS)
  File "/home/hoang/catkin_ws/src/testpy/src/darkflow/dark/darknet.py", line 17, in __init__
    src_parsed = self.parse_cfg(self.src_cfg, FLAGS)
  File "/home/hoang/catkin_ws/src/testpy/src/darkflow/dark/darknet.py", line 68, in parse_cfg
    for i, info in enumerate(cfg_layers):
  File "/home/hoang/catkin_ws/src/testpy/src/darkflow/utils/process.py", line 66, in cfg_yielder
    layers, meta = parser(model); yield meta;
  File "/home/hoang/catkin_ws/src/testpy/src/darkflow/utils/process.py", line 17, in parser
    with open(model, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'cfg/tiny-yolo-voc-3c.cfg'

Note: those errors stop when I run rosrun in the script's folder. But, I wanna add a node in package launch file to use roslaunch for python scripts.

What I need to do? Thanks in advance!

I followed these steps:

$ cd ~

$ mkdir catkin_ws/src -p

$ cd catkin_ws

$ catkin_make

$ cd src

$ catkin_create_pkg testpy rospy

this step I copy all scripts to package/src folder

$ cd ~/catkin_ws

$ catkin_make

$ . ~/catkin_ws/devel/setup.bash

$ roscore

$ chmod +x test.py (added #!/usr/bin/env python)

$ rosrun testpy test.py

edit retag flag offensive close merge delete

Comments

Please copy-paste the errors directly into your question. Do not use screenshots. It's all text.

gvdhoorn gravatar image gvdhoorn  ( 2019-01-10 09:33:19 -0500 )edit

Ok, It was edited

MCVB gravatar image MCVB  ( 2019-01-10 10:02:50 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-01-10 10:02:20 -0500

gvdhoorn gravatar image

updated 2019-01-10 10:04:11 -0500

FileNotFoundError: [Errno 2] No such file or directory: 'cfg/tiny-yolo-voc-3c.cfg'

ROS changes the current working directory for nodes when using rosrun and roslaunch. You cannot use relative filenames then. Change it to an absolute path and it should work.

See #q33890 for a very old -- but still correct -- explanation of this.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-01-10 09:25:26 -0500

Seen: 3,862 times

Last updated: Jan 10 '19