Skip to content

Commit 72ca792

Browse files
author
Minggang Wang
committed
Replace the deprecated rclpy interfaces used in the unit tests
Fix #518
1 parent afb605f commit 72ca792

File tree

5 files changed

+58
-58
lines changed

5 files changed

+58
-58
lines changed

test/py/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def main():
3737
rclpy.init()
3838
node = rclpy.create_node('add_client')
3939
client = node.create_client(AddTwoInts, service)
40-
publisher = node.create_publisher(Int8, 'back_' + service)
40+
publisher = node.create_publisher(Int8, 'back_' + service, 10)
4141
request = AddTwoInts.Request()
4242
request.a = 1
4343
request.b = 2

test/py/listener.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def main():
3939

4040
rclpy.init()
4141
node = rclpy.create_node('py_listener')
42-
publisher = node.create_publisher(String, 'back_' + topic)
43-
subscription = node.create_subscription(String, topic, callback)
42+
publisher = node.create_publisher(String, 'back_' + topic, 10)
43+
subscription = node.create_subscription(String, topic, callback, 10)
4444
while rclpy.ok():
4545
rclpy.spin_once(node)
4646

test/py/publisher_msg.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,77 +42,77 @@ def main():
4242

4343
if rclType == 'Bool':
4444
node = rclpy.create_node('py_bool_publisher')
45-
publisher = node.create_publisher(Bool, 'Bool_py_js_channel')
45+
publisher = node.create_publisher(Bool, 'Bool_py_js_channel', 10)
4646
msg = Bool()
4747
msg.data = True
4848
elif rclType == 'Byte':
4949
node = rclpy.create_node('py_byte_publisher')
50-
publisher = node.create_publisher(Byte, 'Byte_py_js_channel')
50+
publisher = node.create_publisher(Byte, 'Byte_py_js_channel', 10)
5151
msg = Byte()
5252
msg.data = b'\xff'
5353
elif rclType == 'Char':
5454
node = rclpy.create_node('py_char_publisher')
55-
publisher = node.create_publisher(Char, 'Char_py_js_channel')
55+
publisher = node.create_publisher(Char, 'Char_py_js_channel', 10)
5656
msg = Char()
5757
msg.data = 'A'
5858
elif rclType == 'String':
5959
node = rclpy.create_node('py_string_publisher')
60-
publisher = node.create_publisher(String, 'String_py_js_channel')
60+
publisher = node.create_publisher(String, 'String_py_js_channel', 10)
6161
msg = String()
6262
msg.data = 'Hello World'
6363
elif rclType == 'Int8':
6464
node = rclpy.create_node('py_int8_pulbisher')
65-
publisher = node.create_publisher(Int8, 'Int8_py_js_channel')
65+
publisher = node.create_publisher(Int8, 'Int8_py_js_channel', 10)
6666
msg = Int8()
6767
msg.data = 127
6868
elif rclType == 'UInt8':
6969
node = rclpy.create_node('py_uint8_pulbisher')
70-
publisher = node.create_publisher(UInt8, 'UInt8_py_js_channel')
70+
publisher = node.create_publisher(UInt8, 'UInt8_py_js_channel', 10)
7171
msg = UInt8()
7272
msg.data = 255
7373
elif rclType == 'Int16':
7474
node = rclpy.create_node('py_int16_publisher')
75-
publisher = node.create_publisher(Int16, 'Int16_py_js_channel')
75+
publisher = node.create_publisher(Int16, 'Int16_py_js_channel', 10)
7676
msg = Int16()
7777
msg.data = 0x7fff
7878
elif rclType == 'UInt16':
7979
node = rclpy.create_node('py_uint16_publisher')
80-
publisher = node.create_publisher(UInt16, 'UInt16_py_js_channel')
80+
publisher = node.create_publisher(UInt16, 'UInt16_py_js_channel', 10)
8181
msg = UInt16()
8282
msg.data = 0xffff;
8383
elif rclType == 'Int32':
8484
node = rclpy.create_node('py_int32_publisher')
85-
publisher = node.create_publisher(Int32, 'Int32_py_js_channel')
85+
publisher = node.create_publisher(Int32, 'Int32_py_js_channel', 10)
8686
msg = Int32()
8787
msg.data = 0x7fffffff
8888
elif rclType == 'UInt32':
8989
node = rclpy.create_node('py_uint32_publisher')
90-
publisher = node.create_publisher(UInt32, 'UInt32_py_js_channel')
90+
publisher = node.create_publisher(UInt32, 'UInt32_py_js_channel', 10)
9191
msg = UInt32()
9292
msg.data = 0xffffffff
9393
elif rclType == 'Int64':
9494
node = rclpy.create_node('py_int64_publisher')
95-
publisher = node.create_publisher(Int64, 'Int64_py_js_channel')
95+
publisher = node.create_publisher(Int64, 'Int64_py_js_channel', 10)
9696
msg = Int64()
9797
msg.data = pow(2, 53) - 1
9898
elif rclType == 'UInt64':
9999
node = rclpy.create_node('py_uint64_publisher')
100-
publisher = node.create_publisher(UInt64, 'UInt64_py_js_channel')
100+
publisher = node.create_publisher(UInt64, 'UInt64_py_js_channel', 10)
101101
msg = UInt64()
102102
msg.data = pow(2, 53) - 1
103103
elif rclType == 'Float32':
104104
node = rclpy.create_node('py_float32_publisher')
105-
publisher = node.create_publisher(Float32, 'Float32_py_js_channel')
105+
publisher = node.create_publisher(Float32, 'Float32_py_js_channel', 10)
106106
msg = Float32()
107107
msg.data = 3.14
108108
elif rclType == 'Float64':
109109
node = rclpy.create_node('py_float64_publisher')
110-
publisher = node.create_publisher(Float64, 'Float64_py_js_channel')
110+
publisher = node.create_publisher(Float64, 'Float64_py_js_channel', 10)
111111
msg = Float64()
112112
msg.data = 3.14
113113
elif rclType == 'Array':
114114
node = rclpy.create_node('py_array_publisher')
115-
publisher = node.create_publisher(ByteMultiArray, 'Array_py_js_channel');
115+
publisher = node.create_publisher(ByteMultiArray, 'Array_py_js_channel', 10);
116116

117117
lengthDim = MultiArrayDimension()
118118
lengthDim.label = 'length'
@@ -128,15 +128,15 @@ def main():
128128
msg.data = [b'\x41', b'\x42', b'\x43']
129129
elif rclType == 'ColorRGBA':
130130
node = rclpy.create_node('py_colorrgba_publisher')
131-
publisher = node.create_publisher(ColorRGBA, 'ColorRGBA_py_js_channel')
131+
publisher = node.create_publisher(ColorRGBA, 'ColorRGBA_py_js_channel', 10)
132132
msg = ColorRGBA()
133133
msg.a = 0.5
134134
msg.r = 127.0
135135
msg.g = 255.0
136136
msg.b = 255.0
137137
elif rclType == 'Header':
138138
node = rclpy.create_node('py_header_publisher')
139-
publisher = node.create_publisher(Header, 'Header_py_js_channel')
139+
publisher = node.create_publisher(Header, 'Header_py_js_channel', 10)
140140
time = Time()
141141
time.sec = 123456
142142
time.nanosec = 789
@@ -145,7 +145,7 @@ def main():
145145
msg.frame_id = 'main frame'
146146
elif rclType == 'JointState':
147147
node = rclpy.create_node('py_jointstate_publisher')
148-
publisher = node.create_publisher(JointState, 'JointState_py_js_channel')
148+
publisher = node.create_publisher(JointState, 'JointState_py_js_channel', 10)
149149
time = Time()
150150
time.sec = 123456
151151
time.nanosec = 789

test/py/subscription_msg.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,76 +77,76 @@ def main():
7777

7878
if rclType == 'Bool':
7979
node = rclpy.create_node('py_bool_subscription')
80-
publisher = node.create_publisher(Bool, 'Bool_js_py_back_channel')
81-
subscription = node.create_subscription(Bool, 'Bool_js_py_channel', callback)
80+
publisher = node.create_publisher(Bool, 'Bool_js_py_back_channel', 10)
81+
subscription = node.create_subscription(Bool, 'Bool_js_py_channel', callback, 10)
8282
elif rclType == 'Byte':
8383
node = rclpy.create_node('py_byte_subscription')
84-
publisher = node.create_publisher(Byte, 'Byte_js_py_back_channel');
85-
subscription = node.create_subscription(Byte, 'Byte_js_py_channel', callback)
84+
publisher = node.create_publisher(Byte, 'Byte_js_py_back_channel', 10);
85+
subscription = node.create_subscription(Byte, 'Byte_js_py_channel', callback, 10)
8686
elif rclType == 'Char':
8787
node = rclpy.create_node('py_char_subscription')
88-
publisher = node.create_publisher(Char, 'Char_js_py_back_channel')
89-
subscription = node.create_subscription(Char, 'Char_js_py_channel', callback)
88+
publisher = node.create_publisher(Char, 'Char_js_py_back_channel', 10)
89+
subscription = node.create_subscription(Char, 'Char_js_py_channel', callback, 10)
9090
elif rclType == 'String':
9191
node = rclpy.create_node('py_string_subscription')
92-
publisher = node.create_publisher(String, 'String_js_py_back_channel')
93-
subscription = node.create_subscription(String, 'String_js_py_channel', callback)
92+
publisher = node.create_publisher(String, 'String_js_py_back_channel', 10)
93+
subscription = node.create_subscription(String, 'String_js_py_channel', callback, 10)
9494
elif rclType == 'Int8':
9595
node = rclpy.create_node('py_int8_subscription')
96-
publisher = node.create_publisher(Int8, 'Int8_js_py_back_channel')
97-
subscription = node.create_subscription(Int8, 'Int8_js_py_channel', callback)
96+
publisher = node.create_publisher(Int8, 'Int8_js_py_back_channel', 10)
97+
subscription = node.create_subscription(Int8, 'Int8_js_py_channel', callback, 10)
9898
elif rclType == 'UInt8':
9999
node = rclpy.create_node('py_uint8_subscription')
100-
publisher = node.create_publisher(UInt8, 'UInt8_js_py_back_channel')
101-
subscription = node.create_subscription(UInt8, 'UInt8_js_py_channel', callback)
100+
publisher = node.create_publisher(UInt8, 'UInt8_js_py_back_channel', 10)
101+
subscription = node.create_subscription(UInt8, 'UInt8_js_py_channel', callback, 10)
102102
elif rclType == 'Int16':
103103
node = rclpy.create_node('py_int16_subscription')
104-
publisher = node.create_publisher(Int16, 'Int16_js_py_back_channel')
105-
subscription = node.create_subscription(Int16, 'Int16_js_py_channel', callback)
104+
publisher = node.create_publisher(Int16, 'Int16_js_py_back_channel', 10)
105+
subscription = node.create_subscription(Int16, 'Int16_js_py_channel', callback, 10)
106106
elif rclType == 'UInt16':
107107
node = rclpy.create_node('py_uint16_subscription')
108-
publisher = node.create_publisher(UInt16, 'UInt16_js_py_back_channel')
109-
subscription = node.create_subscription(UInt16, 'UInt16_js_py_channel', callback)
108+
publisher = node.create_publisher(UInt16, 'UInt16_js_py_back_channel', 10)
109+
subscription = node.create_subscription(UInt16, 'UInt16_js_py_channel', callback, 10)
110110
elif rclType == 'Int32':
111111
node = rclpy.create_node('py_int32_subscription')
112-
publisher = node.create_publisher(Int32, 'Int32_js_py_back_channel')
113-
subscription = node.create_subscription(Int32, 'Int32_js_py_channel', callback)
112+
publisher = node.create_publisher(Int32, 'Int32_js_py_back_channel', 10)
113+
subscription = node.create_subscription(Int32, 'Int32_js_py_channel', callback, 10)
114114
elif rclType == 'UInt32':
115115
node = rclpy.create_node('py_uint32_subscription')
116-
publisher = node.create_publisher(UInt32, 'UInt32_js_py_back_channel')
117-
subscription = node.create_subscription(UInt32, 'UInt32_js_py_channel', callback)
116+
publisher = node.create_publisher(UInt32, 'UInt32_js_py_back_channel', 10)
117+
subscription = node.create_subscription(UInt32, 'UInt32_js_py_channel', callback, 10)
118118
elif rclType == 'Int64':
119119
node = rclpy.create_node('py_int64_subscription')
120-
publisher = node.create_publisher(Int64, 'Int64_js_py_back_channel')
121-
subscription = node.create_subscription(Int64, 'Int64_js_py_channel', callback)
120+
publisher = node.create_publisher(Int64, 'Int64_js_py_back_channel', 10)
121+
subscription = node.create_subscription(Int64, 'Int64_js_py_channel', callback, 10)
122122
elif rclType == 'UInt64':
123123
node = rclpy.create_node('py_uint64_subscription')
124-
publisher = node.create_publisher(UInt64, 'UInt64_js_py_back_channel')
125-
subscription = node.create_subscription(UInt64, 'UInt64_js_py_channel', callback)
124+
publisher = node.create_publisher(UInt64, 'UInt64_js_py_back_channel', 10)
125+
subscription = node.create_subscription(UInt64, 'UInt64_js_py_channel', callback, 10)
126126
elif rclType == 'Float32':
127127
node = rclpy.create_node('py_float32_subscription')
128-
publisher = node.create_publisher(Float32, 'Float32_js_py_back_channel')
129-
subscription = node.create_subscription(Float32, 'Float32_js_py_channel', callback)
128+
publisher = node.create_publisher(Float32, 'Float32_js_py_back_channel', 10)
129+
subscription = node.create_subscription(Float32, 'Float32_js_py_channel', callback, 10)
130130
elif rclType == 'Float64':
131131
node = rclpy.create_node('py_float64_subscription')
132-
publisher = node.create_publisher(Float64, 'Float64_js_py_back_channel')
133-
subscription = node.create_subscription(Float64, 'Float64_js_py_channel', callback)
132+
publisher = node.create_publisher(Float64, 'Float64_js_py_back_channel', 10)
133+
subscription = node.create_subscription(Float64, 'Float64_js_py_channel', callback, 10)
134134
elif rclType == 'Array':
135135
node = rclpy.create_node('py_array_subscription')
136-
publisher = node.create_publisher(ByteMultiArray, 'Array_js_py_back_channel')
137-
subscription = node.create_subscription(ByteMultiArray, 'Array_js_py_channel', callback)
136+
publisher = node.create_publisher(ByteMultiArray, 'Array_js_py_back_channel', 10)
137+
subscription = node.create_subscription(ByteMultiArray, 'Array_js_py_channel', callback, 10)
138138
elif rclType == 'ColorRGBA':
139139
node = rclpy.create_node('py_colorrgba_subscription')
140-
publisher = node.create_publisher(ColorRGBA, 'ColorRGBA_js_py_back_channel')
141-
subscription = node.create_subscription(ColorRGBA, 'ColorRGBA_js_py_channel', callback)
140+
publisher = node.create_publisher(ColorRGBA, 'ColorRGBA_js_py_back_channel', 10)
141+
subscription = node.create_subscription(ColorRGBA, 'ColorRGBA_js_py_channel', callback, 10)
142142
elif rclType == 'Header':
143143
node = rclpy.create_node('py_header_subscription')
144-
publisher = node.create_publisher(Header, 'Header_js_py_back_channel')
145-
subscription = node.create_subscription(Header, 'Header_js_py_channel', callback)
144+
publisher = node.create_publisher(Header, 'Header_js_py_back_channel', 10)
145+
subscription = node.create_subscription(Header, 'Header_js_py_channel', callback, 10)
146146
elif rclType == 'JointState':
147147
node = rclpy.create_node('py_jointstate_subscrption')
148-
publisher = node.create_publisher(JointState, 'JointState_js_py_back_channel')
149-
subscription = node.create_subscription(JointState, 'JointState_js_py_channel', callback)
148+
publisher = node.create_publisher(JointState, 'JointState_js_py_back_channel', 10)
149+
subscription = node.create_subscription(JointState, 'JointState_js_py_channel', callback, 10)
150150
while rclpy.ok():
151151
rclpy.spin_once(node)
152152

test/py/talker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def main():
3636

3737
rclpy.init()
3838
node = rclpy.create_node('py_talker')
39-
publisher = node.create_publisher(String, topic)
39+
publisher = node.create_publisher(String, topic, 10)
4040

4141
msg = String()
4242
msg.data = 'Hello World'

0 commit comments

Comments
 (0)