rayvburn / humap_local_planner

Human-aware robot trajectory planner using a hybrid trajectory candidates generation and spatiotemporal cost functions
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

fix `ros::TimeNotInitializedException` in unit tests #120

Open rayvburn opened 11 months ago

rayvburn commented 11 months ago

Recently, following exceptions have been observed in unit tests that depend on the main library of the planner (named as the project):

terminate called after throwing an instance of 'ros::TimeNotInitializedException'
  what():  Cannot use ros::Time::now() before the first NodeHandle has been created or ros::start() has been called.  If this is a standalone app or test that just uses ros::Time and does not communicate over ROS, you may also call ros::Time::init()
Aborted (core dumped)

Backtrace, obtained with the call of (from the main workspace directory):

gdb --args devel/.private/hubero_local_planner/lib/hubero_local_planner/test_trajectory

Then, in gdb terminal: run and after the exception, bt:

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff64977f1 in __GI_abort () at abort.c:79
#2  0x00007ffff6e8a957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff6e90ae6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff6e90b21 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff6e90d54 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff52563ae in ros::Time::now() () from /opt/ros/melodic/lib/librostime.so
#7  0x00007ffff78cf71b in __static_initialization_and_destruction_0 () from /home/rayvburn/ros_workspace/ws_social_navigation/devel/lib/libbase_local_planner.so
#8  0x00007ffff78cf73e in _GLOBAL__sub_I_simple_trajectory_generator.cpp () from /home/rayvburn/ros_workspace/ws_social_navigation/devel/lib/libbase_local_planner.so
#9  0x00007ffff7de38d3 in call_init (env=0x7fffffff7cc8, argv=0x7fffffff7cb8, argc=1, l=<optimized out>) at dl-init.c:72
#10 _dl_init (main_map=0x7ffff7ffe170, argc=1, argv=0x7fffffff7cb8, env=0x7fffffff7cc8) at dl-init.c:119
#11 0x00007ffff7dd40ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#12 0x0000000000000001 in ?? ()
#13 0x00007fffffff8117 in ?? ()
#14 0x0000000000000000 in ?? ()

(this output is for the non-debug compilation).

Note

Adding following to the test file does not help:

#include <ros/ros.h>

// ...

int main(int argc, char** argv) {
    ros::init(argc, argv, "test"); // this
    ros::start(); // this
    ros::Time::init(); // this

    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

Resources