@@ -42,6 +42,46 @@ First, let us create an :program:`ament_python` package that depends on our newl
42
42
--build-type ament_python \
43
43
--dependencies rclpy package_with_interfaces
44
44
45
+ .. dropdown :: ros2 pkg create output
46
+
47
+ .. code :: console
48
+
49
+ going to create a new package
50
+ package name: python_package_that_uses_the_messages
51
+ destination directory: /root/ros2_tutorial_workspace/src
52
+ package format: 3
53
+ version: 0.0.0
54
+ description: TODO: Package description
55
+ maintainer: ['root <[email protected] >']
56
+ licenses: ['TODO: License declaration']
57
+ build type: ament_python
58
+ dependencies: ['rclpy', 'package_with_interfaces']
59
+ creating folder ./python_package_that_uses_the_messages
60
+ creating ./python_package_that_uses_the_messages/package.xml
61
+ creating source folder
62
+ creating folder ./python_package_that_uses_the_messages/python_package_that_uses_the_messages
63
+ creating ./python_package_that_uses_the_messages/setup.py
64
+ creating ./python_package_that_uses_the_messages/setup.cfg
65
+ creating folder ./python_package_that_uses_the_messages/resource
66
+ creating ./python_package_that_uses_the_messages/resource/python_package_that_uses_the_messages
67
+ creating ./python_package_that_uses_the_messages/python_package_that_uses_the_messages/__init__.py
68
+ creating folder ./python_package_that_uses_the_messages/test
69
+ creating ./python_package_that_uses_the_messages/test/test_copyright.py
70
+ creating ./python_package_that_uses_the_messages/test/test_flake8.py
71
+ creating ./python_package_that_uses_the_messages/test/test_pep257.py
72
+
73
+ [WARNING]: Unknown license 'TODO: License declaration'. This has been set in the package.xml, but no LICENSE file has been created.
74
+ It is recommended to use one of the ament license identifiers:
75
+ Apache-2.0
76
+ BSL-1.0
77
+ BSD-2.0
78
+ BSD-2-Clause
79
+ BSD-3-Clause
80
+ GPL-3.0-only
81
+ LGPL-3.0-only
82
+ MIT
83
+ MIT-0
84
+
45
85
Overview
46
86
--------
47
87
@@ -147,7 +187,7 @@ For the subscriber Node, create a file in :file:`python_package_that_uses_the_me
147
187
:language: python
148
188
:linenos:
149
189
:lines: 24-
150
- :emphasize-lines: 3, 11-15, 17-30
190
+ :emphasize-lines: 3, 11-15, 17-31
151
191
152
192
Similarly to the publisher, in the subscriber, we start by importing the message in question
153
193
@@ -168,7 +208,7 @@ where the only difference with respect to the publisher is the third argument, n
168
208
.. literalinclude :: ../../ros2_tutorial_workspace/src/python_package_that_uses_the_messages/python_package_that_uses_the_messages/amazing_quote_subscriber_node.py
169
209
:language: python
170
210
:lines: 40-53
171
- :emphasize-lines: 7,11,13
211
+ :emphasize-lines: 8,12,14
172
212
173
213
That callback method will be automatically called by ROS2, as one of the tasks performed by :code: `rclpy.spin(Node) `. Depending on the :code: `qos_profile `, it will not necessarily be the latest message.
174
214
@@ -220,41 +260,30 @@ which outputs
220
260
221
261
.. code :: console
222
262
223
- [INFO] [1684215672.344532584] [amazing_quote_subscriber_node]:
224
- I have received the most amazing of quotes.
225
- It says
226
-
227
- 'Use the force, Pikachu!'
228
-
229
- And was thought by the following genius
230
-
231
- -- Uncle Ben
232
-
233
- This latest quote had the id=3.
263
+ [INFO] [1753664072.638312553] [amazing_quote_subscriber_node]:
264
+ I have received the most amazing of quotes.
265
+ It says
234
266
235
- [INFO] [1684215672.844618237] [amazing_quote_subscriber_node]:
236
- I have received the most amazing of quotes.
237
- It says
267
+ 'Use the force, Pikachu!'
238
268
239
- 'Use the force, Pikachu!'
269
+ And was thought by the following genius
240
270
241
- And was thought by the following genius
271
+ -- Uncle Ben
242
272
243
- -- Uncle Ben
273
+ This latest quote had the id=37.
244
274
245
- This latest quote had the id=4.
275
+ [INFO] [1753664073.121886428] [amazing_quote_subscriber_node]:
276
+ I have received the most amazing of quotes.
277
+ It says
246
278
247
- [INFO] [1684215673.344514856] [amazing_quote_subscriber_node]:
248
- I have received the most amazing of quotes.
249
- It says
279
+ 'Use the force, Pikachu!'
250
280
251
- 'Use the force, Pikachu!'
281
+ And was thought by the following genius
252
282
253
- And was thought by the following genius
283
+ -- Uncle Ben
254
284
255
- -- Uncle Ben
285
+ This latest quote had the id=38.
256
286
257
- This latest quote had the id=5.
258
287
259
288
260
289
.. note ::
0 commit comments