test_urdf.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 PKG='cob_description'
00003 import roslib; roslib.load_manifest(PKG)
00004 
00005 import sys
00006 import os
00007 import unittest
00008 
00009 ## A sample python unit test
00010 class TestUrdf(unittest.TestCase):
00011 
00012         def test_correct_format(self):
00013                 print sys.argv
00014                 print len(sys.argv)
00015         
00016                 if len(sys.argv) < 2:
00017                         self.fail("no urdf file given, usage: " + os.path.basename(sys.argv[0]) + " file.urdf.xacro. \ninput parameters are: " + str(sys.argv))
00018         
00019                 file_to_test = sys.argv[1]
00020                 print "testing " + file_to_test
00021                 
00022                 # check if file exists
00023                 if not os.path.exists(file_to_test):
00024                         self.fail('file "' + file_to_test + '" not found')
00025 
00026                 # check if xacro can be converted
00027                 if os.system("`rospack find xacro`/xacro.py " + file_to_test + " > /tmp/test.urdf") != 0:
00028                         self.fail("cannot convert xacro. file: " + file_to_test)
00029 
00030                 # check if urdf is correct
00031                 if os.system("rosrun urdfdom check_urdf /tmp/test.urdf") != 0:
00032                         self.fail("urdf not correct. file: " + file_to_test)
00033  
00034 if __name__ == '__main__':
00035         import rosunit
00036         rosunit.unitrun(PKG, 'test_urdf', TestUrdf) 


cob_description
Author(s): Florian Weisshardt
autogenerated on Sun Oct 5 2014 22:58:11