Home | Tutorials | Wiki | Issues
Ask Your Question
0

Writing Gazebo/ROS unit tests

asked 2018-10-29 12:14:23 -0500

Robert Brothers gravatar image

Hello,

I've been trying to use the Gazebo ServerFixture to set up very basic unit tests for a ROS enabled Gazebo plugin. I'm using the velodyne lidar tutorial as a simple example that I know will compile and work as expected to help me understand the process of setting up the testing environment. I'm using ROS Kinetic on Ubuntu 16.04 with gazebo 7.14.0. I also have Gtest 1.7.0 installed from the Debian package.

I'd like to be able to use the catkin_add_gtest macro in my CMakeList to add tests and then be able to build and run them with catkin run_tests, but I don't know if this is possible. I have the plugin set up in a catkin package and it properly build and run. But when I run catkin run_tests, there seems to be an issue linking with Gazebo. The output from the terminal is below:

[100%] Linking CXX executable /home/robert/gazebo_sandbox_ws/devel/.private/velodyne_hld32_plugin/lib/velodyne_hld32_plugin/velodyne_hld32_plugin-test /usr/bin/cmake -E cmake_link_script CMakeFiles/velodyne_hld32_plugin-test.dir/link.txt --verbose=1 /usr/bin/c++ -std=c++11 CMakeFiles/velodyne_hld32_plugin-test.dir/test/test_velodyne_hld32_plugin.cpp.o -o /home/robert/gazebo_sandbox_ws/devel/.private/velodyne_hld32_plugin/lib/velodyne_hld32_plugin/velodyne_hld32_plugin-test -L/usr/lib/x86_64-linux-gnu/gazebo-7/plugins -L/home/robert/gazebo_sandbox_ws/build/velodyne_hld32_plugin/gtest -rdynamic gtest/gtest/libgtest.so /home/robert/gazebo_sandbox_ws/devel/.private/velodyne_hld32_plugin/lib/libvelodyne_hld32_plugin.so -lpthread /opt/ros/kinetic/lib/libgazebo_ros_api_plugin.so /opt/ros/kinetic/lib/libgazebo_ros_paths_plugin.so /opt/ros/kinetic/lib/libroslib.so /opt/ros/kinetic/lib/librospack.so -lpython2.7 -lboost_program_options -ltinyxml /opt/ros/kinetic/lib/libtf.so /opt/ros/kinetic/lib/libtf2_ros.so /opt/ros/kinetic/lib/libactionlib.so /opt/ros/kinetic/lib/libmessage_filters.so /opt/ros/kinetic/lib/libtf2.so /opt/ros/kinetic/lib/libdynamic_reconfigure_config_init_mutex.so /opt/ros/kinetic/lib/libroscpp.so -lboost_filesystem -lboost_signals /opt/ros/kinetic/lib/librosconsole.so /opt/ros/kinetic/lib/librosconsole_log4cxx.so /opt/ros/kinetic/lib/librosconsole_backend_interface.so -llog4cxx -lboost_regex /opt/ros/kinetic/lib/libxmlrpcpp.so /opt/ros/kinetic/lib/libroscpp_serialization.so /opt/ros/kinetic/lib/librostime.so /opt/ros/kinetic/lib/libcpp_common.so -lboost_system -lboost_thread -lboost_chrono -lboost_date_time -lboost_atomic -lpthread -lconsole_bridge -Wl,-rpath,/usr/lib/x86_64-linux-gnu/gazebo-7/plugins:/home/robert/gazebo_sandbox_ws/build/velodyne_hld32_plugin/gtest:/home/robert/gazebo_sandbox_ws/build/velodyne_hld32_plugin/gtest/gtest:/home/robert/gazebo_sandbox_ws/devel/.private/velodyne_hld32_plugin/lib:/opt/ros/kinetic/lib CMakeFiles/velodyne_hld32_plugin-test.dir/test/test_velodyne_hld32_plugin.cpp.o: In function `VelodyneHLD32PluginTest_TestLoadingWorld_Test::TestBody()': test_velodyne_hld32_plugin.cpp:(.text+0xaf): undefined reference to `gazebo::physics::get_world(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' CMakeFiles/velodyne_hld32_plugin-test.dir/test/test_velodyne_hld32_plugin.cpp.o: In function `VelodyneHLD32PluginTest::VelodyneHLD32PluginTest()': test_velodyne_hld32_plugin.cpp:(.text._ZN23VelodyneHLD32PluginTestC2Ev[_ZN23VelodyneHLD32PluginTestC5Ev]+0x14): undefined reference to `gazebo::ServerFixture::ServerFixture()' CMakeFiles/velodyne_hld32_plugin-test.dir/test/test_velodyne_hld32_plugin.cpp.o: In function `VelodyneHLD32PluginTest::~VelodyneHLD32PluginTest()': test_velodyne_hld32_plugin.cpp:(.text._ZN23VelodyneHLD32PluginTestD2Ev[_ZN23VelodyneHLD32PluginTestD5Ev]+0x20): undefined reference to `gazebo::ServerFixture::~ServerFixture()' CMakeFiles/velodyne_hld32_plugin-test.dir/test/test_velodyne_hld32_plugin.cpp.o:(.rodata._ZTV45VelodyneHLD32PluginTest_TestLoadingWorld_Test[_ZTV45VelodyneHLD32PluginTest_TestLoadingWorld_Test]+0x28): undefined reference to `gazebo::ServerFixture::TearDown()' CMakeFiles/velodyne_hld32_plugin-test.dir/test/test_velodyne_hld32_plugin.cpp.o:(.rodata._ZTV45VelodyneHLD32PluginTest_TestLoadingWorld_Test[_ZTV45VelodyneHLD32PluginTest_TestLoadingWorld_Test]+0x40): undefined reference to `gazebo::ServerFixture::Unload()' CMakeFiles ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-11-14 13:54:41 -0500

ServerFixture is build as a static library and is not part of GAZEBO_LIBRARIES. Add it like this: target_link_libraries(myTarget "libgazebo_test_fixture.a")

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-10-29 12:14:23 -0500

Seen: 228 times

Last updated: Oct 29 '18