ros::package::getPath seg faults in kinetic
I am trying to use the ros::package::getPath() command to find path to a config file in my ros cpp code. I have added the relevant lines to CMakeLists.txt and package.xml. The code compiles fine but segfaults at runtime. I am running Ubuntu 16.04 with Ros Kinetic. Any ideas on what might be going on?
Thanks in advance.
I had a similar situation, and segfaults were caused by the program not able to find the file (it actually did not state that in the crash info). Maybe your config is not where the program actually executes.
the most efficient approach to figure this out is by running your node in
gdb
, and seeing where theSEGFAULT
occurs.The comment by @Mikhail K. is a good one: don't assume things succeed, always check return status.
@Mikhail I am just getting the path and printing it out with cout. I am not doing anything with it currently.