From 335e7d8e7d82189c64e0141ff79eb6d90b8952b4 Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Thu, 28 Apr 2016 05:40:48 -0700 Subject: [PATCH] #408 Increasing max time because some systems are taking 0.6 seconds to receive the messages (still well less than 2.0 seconds). Also all the tests can be run with run_tests_gazebo_plugins_rostest but only with the -j1 flag #409 --- gazebo_plugins/CMakeLists.txt | 1 - gazebo_plugins/test/camera/camera.cpp | 2 +- gazebo_plugins/test/camera/depth_camera.cpp | 19 +++++++++++-------- gazebo_plugins/test/camera/multicamera.cpp | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gazebo_plugins/CMakeLists.txt b/gazebo_plugins/CMakeLists.txt index 9ee4c40a3..1215d6898 100644 --- a/gazebo_plugins/CMakeLists.txt +++ b/gazebo_plugins/CMakeLists.txt @@ -371,7 +371,6 @@ if (CATKIN_ENABLE_TESTING) add_rostest(test/range/range_plugin.test) target_link_libraries(set_model_state-test ${catkin_LIBRARIES}) - # Can't run these and the above test together add_rostest_gtest(depth_camera-test test/camera/depth_camera.test test/camera/depth_camera.cpp) diff --git a/gazebo_plugins/test/camera/camera.cpp b/gazebo_plugins/test/camera/camera.cpp index 25a2932d3..b7805bbae 100644 --- a/gazebo_plugins/test/camera/camera.cpp +++ b/gazebo_plugins/test/camera/camera.cpp @@ -60,7 +60,7 @@ TEST_F(CameraTest, cameraSubscribeTest) // this likely isn't that robust - what if the testing system is really slow? double time_diff = (ros::Time::now() - image_stamp_).toSec(); ROS_INFO_STREAM(time_diff); - EXPECT_LT(time_diff, 0.5); + EXPECT_LT(time_diff, 1.0); cam_sub_.shutdown(); } diff --git a/gazebo_plugins/test/camera/depth_camera.cpp b/gazebo_plugins/test/camera/depth_camera.cpp index b6809e87c..596e6d50f 100644 --- a/gazebo_plugins/test/camera/depth_camera.cpp +++ b/gazebo_plugins/test/camera/depth_camera.cpp @@ -80,22 +80,25 @@ TEST_F(DepthCameraTest, cameraSubscribeTest) EXPECT_EQ(depth_stamp_.toSec(), image_stamp_.toSec()); EXPECT_EQ(depth_stamp_.toSec(), points_stamp_.toSec()); - // This check depends on the update period being much longer - // than the expected difference between now and the received image time + // This check depends on the update period (currently 1.0/update_rate = 2.0 seconds) + // being much longer than the expected difference between now and the + // received image time. + const double max_time = 1.0; + const ros::Time current_time = ros::Time::now(); // TODO(lucasw) // this likely isn't that robust - what if the testing system is really slow? double time_diff; - time_diff = (ros::Time::now() - image_stamp_).toSec(); + time_diff = (current_time - image_stamp_).toSec(); ROS_INFO_STREAM(time_diff); - EXPECT_LT(time_diff, 0.5); + EXPECT_LT(time_diff, max_time); - time_diff = (ros::Time::now() - depth_stamp_).toSec(); + time_diff = (current_time - depth_stamp_).toSec(); ROS_INFO_STREAM(time_diff); - EXPECT_LT(time_diff, 0.5); + EXPECT_LT(time_diff, max_time); - time_diff = (ros::Time::now() - points_stamp_).toSec(); + time_diff = (current_time - points_stamp_).toSec(); ROS_INFO_STREAM(time_diff); - EXPECT_LT(time_diff, 0.5); + EXPECT_LT(time_diff, max_time); cam_sub_.shutdown(); depth_sub_.shutdown(); diff --git a/gazebo_plugins/test/camera/multicamera.cpp b/gazebo_plugins/test/camera/multicamera.cpp index cd66a0778..0823c53da 100644 --- a/gazebo_plugins/test/camera/multicamera.cpp +++ b/gazebo_plugins/test/camera/multicamera.cpp @@ -89,7 +89,7 @@ TEST_F(MultiCameraTest, cameraSubscribeTest) // this likely isn't that robust - what if the testing system is really slow? double time_diff = (ros::Time::now() - image_left_stamp_).toSec(); ROS_INFO_STREAM(time_diff); - EXPECT_LT(time_diff, 0.5); + EXPECT_LT(time_diff, 1.0); // cam_sub_.shutdown(); }