How to create custom directory
Hello, I want to create custom directory with images to process (get contours and then draw them with turtlesim). My current folder structure is (inside src folder):
contour_drawing
--| contour_drawing
----| init.py
----| contour_drawing.py
--| img
----| img1.png
--| launch
----| contour_drawing_launch.py
--| resource
----| *default structure*
--| test
----| *default structure*
--| package.xml
--| setup.cfg
--| setup.py
Right now I am using absolute paths, but I don't like that method. I would like to use relative paths, but nothing I tried is working. How can I get path to img1.png? I'm using ROS2 Humble, Python 3.11 and Ubuntu 22.04 VM
Have you tried looking to launch files capabilities? I have almost no experience working with them, but it would seem that somehow you might be able to get the location context for your workspace: Tutorial: ROS2 launch files – All you need to know
I'm using launch file, it has nothing to do with path to static file
What I meant is that you can get e.g. pwd running os.getcwd() command in python launch file and pass it as an argument to the node or something like that. That probably may be not the cleanest approach, but it would seem like it should work.
For me the os.getcwd() call returned the workspace directory.
Ok that's weird approach, it's something but still looking for an answer. Thank you for your answer tho.