@@ -39,21 +39,21 @@ Install colcon
3939
4040 .. group-tab :: Linux
4141
42- .. code-block :: bash
42+ .. code-block :: console
4343
44- sudo apt install python3-colcon-common-extensions
44+ $ sudo apt install python3-colcon-common-extensions
4545
4646 .. group-tab :: macOS
4747
48- .. code-block :: bash
48+ .. code-block :: console
4949
50- python3 -m pip install colcon-common-extensions
50+ $ python3 -m pip install colcon-common-extensions
5151
5252 .. group-tab :: Windows
5353
54- .. code-block :: bash
54+ .. code-block :: console
5555
56- pip install -U colcon-common-extensions
56+ $ pip install -U colcon-common-extensions
5757
5858
5959 Install ROS 2
@@ -73,7 +73,7 @@ Commonly there is a ``src`` subdirectory.
7373Inside that subdirectory is where the source code of ROS packages will be located.
7474Typically the directory starts otherwise empty.
7575
76- colcon does out of source builds.
76+ colcon performs out-of- source builds.
7777By default it will create the following directories as peers of the ``src `` directory:
7878
7979* The ``build `` directory will be where intermediate files are stored.
@@ -93,24 +93,24 @@ First, create a directory (``ros2_ws``) to contain our workspace:
9393
9494 .. group-tab :: Linux
9595
96- .. code-block :: bash
96+ .. code-block :: console
9797
98- mkdir -p ~ /ros2_ws/src
99- cd ~ /ros2_ws
98+ $ mkdir -p ~/ros2_ws/src
99+ $ cd ~/ros2_ws
100100
101101 .. group-tab :: macOS
102102
103- .. code-block :: bash
103+ .. code-block :: console
104104
105- mkdir -p ~ /ros2_ws/src
106- cd ~ /ros2_ws
105+ $ mkdir -p ~/ros2_ws/src
106+ $ cd ~/ros2_ws
107107
108108 .. group-tab :: Windows
109109
110- .. code-block :: bash
110+ .. code-block :: console
111111
112- md \d ev\r os2_ws\s rc
113- cd \d ev\r os2_ws
112+ $ md \dev\ros2_ws\src
113+ $ cd \dev\ros2_ws
114114
115115 At this point the workspace contains a single empty directory ``src ``:
116116
@@ -126,9 +126,9 @@ Add some sources
126126
127127Let's clone the `examples <https://github.com/ros2/examples >`__ repository into the ``src `` directory of the workspace:
128128
129- .. code-block :: bash
129+ .. code-block :: console
130130
131- git clone https://github.com/ros2/examples src/examples -b {REPOS_FILE_BRANCH}
131+ $ git clone https://github.com/ros2/examples src/examples -b {REPOS_FILE_BRANCH}
132132
133133 Now the workspace should have the source code to the ROS 2 examples:
134134
@@ -172,19 +172,19 @@ This allows the installed files to be changed by changing the files in the ``sou
172172
173173 .. code-block :: console
174174
175- colcon build --symlink-install
175+ $ colcon build --symlink-install
176176
177177 .. group-tab :: macOS
178178
179179 .. code-block :: console
180180
181- colcon build --symlink-install
181+ $ colcon build --symlink-install
182182
183183 .. group-tab :: Windows
184184
185185 .. code-block :: console
186186
187- colcon build --symlink-install --merge-install
187+ $ colcon build --symlink-install --merge-install
188188
189189 Windows doesn't allow long paths, so ``merge-install `` will combine all the paths into the ``install `` directory.
190190
@@ -213,21 +213,21 @@ To run tests for the packages we just built, run the following:
213213
214214 .. code-block :: console
215215
216- colcon test
216+ $ colcon test
217217
218218 .. group-tab :: macOS
219219
220220 .. code-block :: console
221221
222- colcon test
222+ $ colcon test
223223
224224 .. group-tab :: Windows
225225
226226 Remember to use a ``x64 Native Tools Command Prompt for VS 2019 `` for executing the following command, as we are going to build a workspace.
227227
228228 .. code-block :: console
229229
230- colcon test --merge-install
230+ $ colcon test --merge-install
231231
232232 You also need to specify ``--merge-install `` here since we used it for building above.
233233
@@ -245,43 +245,43 @@ These files will add all of the required elements to your path and library paths
245245
246246 .. group-tab :: Linux
247247
248- .. code-block :: bash
248+ .. code-block :: console
249249
250- source install/setup.bash
250+ $ source install/setup.bash
251251
252252 .. group-tab :: macOS
253253
254- .. code-block :: bash
254+ .. code-block :: console
255255
256- . install/setup.bash
256+ $ . install/setup.bash
257257
258258 .. group-tab :: Windows
259259
260- .. code-block :: bash
260+ .. code-block :: console
261261
262- call install\s etup.bat
262+ $ call install\setup.bat
263263
264264 Or with Powershell:
265265
266- .. code-block :: bash
266+ .. code-block :: console
267267
268- install\s etup.ps1
268+ $ install\setup.ps1
269269
270270 Try a demo
271271^^^^^^^^^^
272272
273273With the environment sourced, we can run executables built by colcon.
274274Let's run a subscriber node from the examples:
275275
276- .. code-block :: bash
276+ .. code-block :: console
277277
278- ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function
278+ $ ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function
279279
280280 In another terminal, let's run a publisher node (don't forget to source the setup script):
281281
282- .. code-block :: bash
282+ .. code-block :: console
283283
284- ros2 run examples_rclcpp_minimal_publisher publisher_member_function
284+ $ ros2 run examples_rclcpp_minimal_publisher publisher_member_function
285285
286286 You should see messages from the publisher and subscriber with numbers incrementing.
287287
@@ -307,22 +307,23 @@ Setup ``colcon_cd``
307307
308308The command ``colcon_cd `` allows you to quickly change the current working directory of your shell to the directory of a package.
309309As an example ``colcon_cd some_ros_package `` would quickly bring you to the directory ``~/ros2_ws/src/some_ros_package ``.
310+ To set up ``colcon_cd `` you need to run the following commands to modify your shell startup script:
310311
311312.. tabs ::
312313
313314 .. group-tab :: Linux
314315
315316 .. code-block :: console
316317
317- echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc
318- echo "export _colcon_cd_root=/opt/ros/{DISTRO}/" >> ~/.bashrc
318+ $ echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc
319+ $ echo "export _colcon_cd_root=/opt/ros/{DISTRO}/" >> ~/.bashrc
319320
320321 .. group-tab :: macOS
321322
322323 .. code-block :: console
323324
324- echo "source /usr/local/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc
325- echo "export _colcon_cd_root=~/ros2_install" >> ~/.bashrc
325+ $ echo "source /usr/local/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc
326+ $ echo "export _colcon_cd_root=~/ros2_install" >> ~/.bashrc
326327
327328 .. group-tab :: Windows
328329
346347
347348* If you want to run a single particular test from a package:
348349
349- .. code-block :: bash
350+ .. code-block :: console
350351
351- colcon test --packages-select YOUR_PKG_NAME --ctest-args -R YOUR_TEST_IN_PKG
352+ $ colcon test --packages-select YOUR_PKG_NAME --ctest-args -R YOUR_TEST_IN_PKG
352353
353354 Setup ``colcon `` mixins
354355-----------------------
@@ -359,21 +360,21 @@ For example, to change the CMake build type to debug, you normally use:
359360
360361.. code-block :: console
361362
362- colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug
363+ $ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug
363364
364365 To make common command line options easier to invoke this repository makes these "shortcuts" available.
365366
366367To install the default colcon mixins, run the following:
367368
368369.. code-block :: console
369370
370- colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
371- colcon mixin update default
371+ $ colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
372+ $ colcon mixin update default
372373
373374 Then, try out using the ``debug `` mixin:
374375
375376.. code-block :: console
376377
377- colcon build --mixin debug
378+ $ colcon build --mixin debug
378379
379380 For more details, see the `colcon mixin repository <https://github.com/colcon/colcon-mixin-repository >`__.
0 commit comments