About the configuration file in package

Hi !
I’m writing a package that needs to read a configuration file .
I use install(FILES xxx.yaml DESTINATION share/${PROJECT_NAME}) to copy the configuration file to the path : /shr/package-name

But i have no good way to get the right path where the file stores and then read it

i’m using the absolute path to read the file now but i want to make it relative so the package can be used in different environment .

looking forward to some suggestions !

Thanks for the question, but we ask that you post it on answers.ros.org with the ros2 tag instead. You can link to it from here once you do so.

ROS Discourse is for news and general interest discussions. ROS Answers provides a forum which can be filtered by tags to make sure the relevant people can find and/or answer the question, and not overload everyone with hundreds of posts.

edit: posted at https://answers.ros.org/question/290767/how-to-load-the-configuration-file-in-package-in-ros2/

sorry to post it here and thank you !