ros::package::getPath seg faults in kinetic

asked 2018-07-04 19:57:13 -0500

vik748 gravatar image

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.

edit retag flag offensive close merge delete

Comments

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.

Mikhail K. gravatar image Mikhail K.  ( 2018-07-05 00:36:58 -0500 )edit

Any ideas on what might be going on?

the most efficient approach to figure this out is by running your node in gdb, and seeing where the SEGFAULT occurs.

The comment by @Mikhail K. is a good one: don't assume things succeed, always check return status.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-05 02:30:50 -0500 )edit

@Mikhail I am just getting the path and printing it out with cout. I am not doing anything with it currently.

vik748 gravatar image vik748  ( 2018-07-05 14:30:08 -0500 )edit