From 0aa80aca271543b38e0de7f311f2736ddd5db239 Mon Sep 17 00:00:00 2001 From: "Isaac I.Y. Saito" <130s@2000.jukuin.keio.ac.jp> Date: Sat, 6 Jan 2018 08:41:26 -0800 Subject: [PATCH] [description] Generalization. Add unit test using kobuki. [description][test] Use source permission to pass the tests in install space. --- openni_description/CMakeLists.txt | 9 ++-- openni_description/model/kinect.urdf.xacro | 19 ++++----- .../model/kinect_gazebo.urdf.xacro | 42 +++++++++++++++++++ openni_description/package.xml | 3 ++ openni_description/test/sample_kobuki.test | 4 ++ .../test/sample_kobuki.urdf.xacro | 13 ++++++ openni_description/test/test_openni_desc.py | 32 ++++++++++++++ .../test/turtlebot_properties.urdf.xacro | 2 +- 8 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 openni_description/model/kinect_gazebo.urdf.xacro create mode 100644 openni_description/test/sample_kobuki.test create mode 100644 openni_description/test/sample_kobuki.urdf.xacro create mode 100755 openni_description/test/test_openni_desc.py diff --git a/openni_description/CMakeLists.txt b/openni_description/CMakeLists.txt index a3f32fc..add8022 100644 --- a/openni_description/CMakeLists.txt +++ b/openni_description/CMakeLists.txt @@ -5,6 +5,9 @@ find_package(catkin REQUIRED) catkin_package() -install(DIRECTORY model - DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/ -) +install(DIRECTORY model DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) +install(DIRECTORY test DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} USE_SOURCE_PERMISSIONS) +if (CATKIN_ENABLE_TESTING) + find_package(catkin REQUIRED COMPONENTS rostest) + add_rostest(test/sample_kobuki.test) +endif () diff --git a/openni_description/model/kinect.urdf.xacro b/openni_description/model/kinect.urdf.xacro index 8700d5c..f62201c 100644 --- a/openni_description/model/kinect.urdf.xacro +++ b/openni_description/model/kinect.urdf.xacro @@ -1,13 +1,12 @@ - - - + + + - - + - + @@ -21,7 +20,7 @@ - + @@ -29,7 +28,7 @@ - + @@ -51,7 +50,7 @@ files. However, for Gazebo simulation we need them, so we add them here. (Hence, don't publish them additionally!) --> - + @@ -65,6 +64,6 @@ - + diff --git a/openni_description/model/kinect_gazebo.urdf.xacro b/openni_description/model/kinect_gazebo.urdf.xacro new file mode 100644 index 0000000..c6263fe --- /dev/null +++ b/openni_description/model/kinect_gazebo.urdf.xacro @@ -0,0 +1,42 @@ + + + + + + + true + 20.0 + + ${60.0*M_PI/180.0} + + B8G8R8 + 640 + 480 + + + 0.05 + 8.0 + + + + camera + true + 10 + rgb/image_raw + depth/image_raw + depth/points + rgb/camera_info + depth/camera_info + camera_depth_optical_frame + 0.1 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.4 + + + + + diff --git a/openni_description/package.xml b/openni_description/package.xml index b72f66c..b2d6729 100644 --- a/openni_description/package.xml +++ b/openni_description/package.xml @@ -13,4 +13,7 @@ catkin urdf xacro + kobuki_description + rostest + turtlebot_description diff --git a/openni_description/test/sample_kobuki.test b/openni_description/test/sample_kobuki.test new file mode 100644 index 0000000..19578eb --- /dev/null +++ b/openni_description/test/sample_kobuki.test @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/openni_description/test/sample_kobuki.urdf.xacro b/openni_description/test/sample_kobuki.urdf.xacro new file mode 100644 index 0000000..bb66721 --- /dev/null +++ b/openni_description/test/sample_kobuki.urdf.xacro @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/openni_description/test/test_openni_desc.py b/openni_description/test/test_openni_desc.py new file mode 100755 index 0000000..4d3485f --- /dev/null +++ b/openni_description/test/test_openni_desc.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +PKG = 'openni_description' + +import os +import subprocess +import unittest + +import rospkg + + +class TestOpenniDescription(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + True + + def test_urdf_turtlebot(self): + """ + Check if check_urdf command passes with the urdf that is generated in + the .test file this test case is called from. + """ + self.assertTrue(os.path.isfile(rospkg.RosPack().get_path('openni_description') + "/test/sample_kobuki.urdf.xacro") + print(subprocess.check_output(["rosrun", "xacro", "xacro", rospkg.RosPack().get_path('openni_description') + "/test/sample_kobuki.urdf.xacro", "-o", "./sample_kobuki.urdf"])) + self.assertEqual(0, subprocess.call(["check_urdf", "./sample_kobuki.urdf"])) + +if __name__ == '__main__': + import rostest + rostest.rosrun(PKG, 'test_openni_description', TestOpenniDescription) diff --git a/openni_description/test/turtlebot_properties.urdf.xacro b/openni_description/test/turtlebot_properties.urdf.xacro index d4c7d0b..d7915ff 100644 --- a/openni_description/test/turtlebot_properties.urdf.xacro +++ b/openni_description/test/turtlebot_properties.urdf.xacro @@ -23,7 +23,7 @@ (currently in development and awaiting feedback) --> - +