34 PKG =
'test_roslaunch' 36 import os, sys, unittest
39 from xmlrpc.client
import Binary
41 from xmlrpclib
import Binary
46 master = rosgraph.Master(
'params_basic')
48 return master.getParam(*args)
56 self.assertEquals(
get_param(
'stringempty'),
'')
58 self.assertEquals(
get_param(
'stringbar'),
'bar')
59 self.assertEquals(
get_param(
'str10'),
'10')
60 self.assertEquals(
get_param(
'string10'),
'10')
61 self.assertEquals(
get_param(
'stringentity'),
'<stringentity/>')
63 self.assertEquals(
get_param(
"integerneg1"), -1)
64 self.assertEquals(
get_param(
"integer0"), 0)
65 self.assertEquals(
get_param(
"integer1"), 1)
66 self.assertEquals(
get_param(
"integernoop1"), 1)
67 self.assertEquals(
get_param(
"integer12345"), 12345)
69 self.assertEquals(
get_param(
"floatpi"),3.14159)
70 self.assertEquals(
get_param(
"floatnooppi"),3.14159)
71 self.assertEquals(
get_param(
"float3"),3.0)
72 self.assertEquals(
get_param(
"floatneg1"),-1.0)
74 for p
in [
'true',
'TRUE',
'True']:
76 for p
in [
'false',
"FALSE",
'False']:
81 self.assertEquals(
get_param(
"/wg/childparam"),
"wg")
82 self.assertEquals(
get_param(
"/wg2/childparam"),
"wg2")
83 self.assertEquals(
get_param(
"/wg3/childparam"),
"wg3")
84 self.assertEquals(
get_param(
"/wg/wg4/childparam"),
"wg4")
85 self.assertEquals(
get_param(
"/wg/wg4/wg5/childparam"),
"wg5")
87 self.assertEquals(
get_param(
"/wga/wg/childparam"),
"wg")
88 self.assertEquals(
get_param(
"/wga/wg2/childparam"),
"wg2")
89 self.assertEquals(
get_param(
"/wga/wg3/childparam"),
"wg3")
90 self.assertEquals(
get_param(
"/wga/wg/wg4/childparam"),
"wg4")
91 self.assertEquals(
get_param(
"/wga/wg/wg4/wg5/childparam"),
"wg5")
93 self.assertEquals(
get_param(
"/wga/wgb/wg/childparam"),
"bwg")
94 self.assertEquals(
get_param(
"/wga/wgb/wg2/childparam"),
"bwg2")
95 self.assertEquals(
get_param(
"/wga/wgb/wg3/childparam"),
"bwg3")
96 self.assertEquals(
get_param(
"/wga/wgb/wg/wg4/childparam"),
"bwg4")
97 self.assertEquals(
get_param(
"/wga/wgb/wg/wg4/wg5/childparam"),
"bwg5")
99 self.assertEquals(
get_param(
"/wgc/childparam"),
"wg")
100 self.assertEquals(
get_param(
"/wgc2/childparam"),
"wg2")
101 self.assertEquals(
get_param(
"/wgc3/childparam"),
"wg3")
102 self.assertEquals(
get_param(
"/wgc/wg4/childparam"),
"wg4")
103 self.assertEquals(
get_param(
"/wgc/wg4/wg5/childparam"),
"wg5")
107 dir = rospkg.RosPack().get_path(
'roslaunch')
108 with open(os.path.join(dir,
'resources',
'example.launch'),
'r') as f: 110 with open(os.path.join(dir, 'resources',
'example.launch'),
'rb')
as f:
111 binary_data = f.read()
112 self.assertEquals(
get_param(
"commandoutput"), binary_data)
113 self.assertEquals(
get_param(
"textfile"), text_data)
116 self.assertTrue(isinstance(bindata, Binary))
117 self.assertEquals(bindata.data, binary_data)
119 if __name__ ==
'__main__':
120 rostest.rosrun(PKG, sys.argv[0], TestParamsBasic, sys.argv)
Test Roslaunch 'param' tags.
def test_commandandfile(self)
test 'command' attribute
def test_ns(self)
Test roslaunch ns attribute (namespace) on params.
def test_values(self)
test primitive values