Ubuntu 22.04, ROS2 Humble
Hi,
Is there a programmatic way for a ros2 cpp node to resolve the full path of its parent package?
For instance I have a package that contains a cpp node as shown below
/home/az/ros2_ws/src/ros2_cpp_package/src/cpp_node.cpp
I can find the path to the home directory using cstdlib
and this command std::string homeDir = getenv('HOME')
in cpp_node.cpp
.
However the remaining part /ros2_ws/src/ros2_cpp_package/
, I had to hardcode which I want to avoid to make my code easily usable by other users when they would download it from my github repo.
Any help and suggestions would be most appreciated.
With best, Azmyin