Roslaunch: file not found error for logging
Hi, I am working on a project, and I want to start the different nodes using a launch file. In the latter I start one Python node and the other is an rqt plugin that I created:
<launch>
<node name="PiMaster_node" pkg="airplane_master" type="PiMaster.py" output="screen"/>
<node name="airplane_master" pkg="airplane_master" type="airplane_master"/>
</launch>
My problem is that when I run the two scripts separately using rosrun
, everything works perfectly, but when I use roslaunch
to start my .launch file I get this error:
Traceback (most recent call last):
File "/home/micdev/catkin_ws/devel/lib/airplane_master/PiMaster.py", line 15, in <module>
exec(compile(fh.read(), python_script, 'exec'), context)
File "/home/micdev/catkin_ws/src/airplane_master/scripts/PiMaster.py", line 21, in <module>
logging.basicConfig(filename='src/airplane_master/src/airplane_master/Master.log', level=logging.ERROR,
File "/usr/lib/python3.8/logging/__init__.py", line 1988, in basicConfig
h = FileHandler(filename, mode)
File "/usr/lib/python3.8/logging/__init__.py", line 1147, in __init__
StreamHandler.__init__(self, self._open())
File "/usr/lib/python3.8/logging/__init__.py", line 1176, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/home/micdev/.ros/src/airplane_master/src/airplane_master/Master.log'
Basically it says that it couldn't find a Log file (that actually exists): I use the logging
module in Python to log some infos in Master.log
file... Maybe it is interacting with the ROS logger? If this is the case why doesn't it happen when I run the python file using rosrun?
Can someone help me, I'm stuck :(
Thanks in advance!