@@ -139,19 +139,19 @@ Make sure you are in the ``src`` folder before running the package creation comm
139
139
140
140
.. code-block :: console
141
141
142
- cd ~/ros2_ws/src
142
+ $ cd ~/ros2_ws/src
143
143
144
144
.. group-tab :: macOS
145
145
146
146
.. code-block :: console
147
147
148
- cd ~/ros2_ws/src
148
+ $ cd ~/ros2_ws/src
149
149
150
150
.. group-tab :: Windows
151
151
152
152
.. code-block :: console
153
153
154
- cd \ros2_ws\src
154
+ $ cd \ros2_ws\src
155
155
156
156
The command syntax for creating a new package in ROS 2 is:
157
157
@@ -161,13 +161,13 @@ The command syntax for creating a new package in ROS 2 is:
161
161
162
162
.. code-block :: console
163
163
164
- ros2 pkg create --build-type ament_cmake --license Apache-2.0 <package_name>
164
+ $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 <package_name>
165
165
166
166
.. group-tab :: Python
167
167
168
168
.. code-block :: console
169
169
170
- ros2 pkg create --build-type ament_python --license Apache-2.0 <package_name>
170
+ $ ros2 pkg create --build-type ament_python --license Apache-2.0 <package_name>
171
171
172
172
For this tutorial, you will use the optional arguments ``--node-name `` and ``--license ``.
173
173
``--node-name `` option creates a simple Hello World type executable in the package, and ``--license `` declares the license information for the package.
@@ -180,13 +180,13 @@ Enter the following command in your terminal:
180
180
181
181
.. code-block :: console
182
182
183
- ros2 pkg create --build-type ament_cmake --license Apache-2.0 --node-name my_node my_package
183
+ $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 --node-name my_node my_package
184
184
185
185
.. group-tab :: Python
186
186
187
187
.. code-block :: console
188
188
189
- ros2 pkg create --build-type ament_python --license Apache-2.0 --node-name my_node my_package
189
+ $ ros2 pkg create --build-type ament_python --license Apache-2.0 --node-name my_node my_package
190
190
191
191
You will now have a new folder within your workspace's ``src `` directory called ``my_package ``.
192
192
@@ -263,19 +263,19 @@ Return to the root of your workspace:
263
263
264
264
.. code-block :: console
265
265
266
- cd ~/ros2_ws
266
+ $ cd ~/ros2_ws
267
267
268
268
.. group-tab :: macOS
269
269
270
270
.. code-block :: console
271
271
272
- cd ~/ros2_ws
272
+ $ cd ~/ros2_ws
273
273
274
274
.. group-tab :: Windows
275
275
276
276
.. code-block :: console
277
277
278
- cd \ros2_ws
278
+ $ cd \ros2_ws
279
279
280
280
Now you can build your packages:
281
281
@@ -285,19 +285,19 @@ Now you can build your packages:
285
285
286
286
.. code-block :: console
287
287
288
- colcon build
288
+ $ colcon build
289
289
290
290
.. group-tab :: macOS
291
291
292
292
.. code-block :: console
293
293
294
- colcon build
294
+ $ colcon build
295
295
296
296
.. group-tab :: Windows
297
297
298
298
.. code-block :: console
299
299
300
- colcon build --merge-install
300
+ $ colcon build --merge-install
301
301
302
302
Windows doesn't allow long paths, so ``merge-install `` will combine all the paths into the ``install `` directory.
303
303
@@ -309,7 +309,7 @@ To build only the ``my_package`` package next time, you can run:
309
309
310
310
.. code-block :: console
311
311
312
- colcon build --packages-select my_package
312
+ $ colcon build --packages-select my_package
313
313
314
314
3 Source the setup file
315
315
^^^^^^^^^^^^^^^^^^^^^^^
@@ -324,19 +324,19 @@ Then, from inside the ``ros2_ws`` directory, run the following command to source
324
324
325
325
.. code-block :: console
326
326
327
- source install/local_setup.bash
327
+ $ source install/local_setup.bash
328
328
329
329
.. group-tab :: macOS
330
330
331
331
.. code-block :: console
332
332
333
- . install/local_setup.bash
333
+ $ . install/local_setup.bash
334
334
335
335
.. group-tab :: Windows
336
336
337
337
.. code-block :: console
338
338
339
- call install/local_setup.bat
339
+ $ call install/local_setup.bat
340
340
341
341
Now that your workspace has been added to your path, you will be able to use your new package's executables.
342
342
@@ -347,7 +347,7 @@ To run the executable you created using the ``--node-name`` argument during pack
347
347
348
348
.. code-block :: console
349
349
350
- ros2 run my_package my_node
350
+ $ ros2 run my_package my_node
351
351
352
352
Which will return a message to your terminal:
353
353
0 commit comments