Robotics StackExchange | Archived questions

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.

Asked by vik748 on 2018-07-04 19:57:13 UTC

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.

Asked by Mikhail K. on 2018-07-05 00:36:58 UTC

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.

Asked by gvdhoorn on 2018-07-05 02:30:50 UTC

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

Asked by vik748 on 2018-07-05 14:30:08 UTC

Answers