Skip to content

Commit 7c38a44

Browse files
Update code-blocks in Beginnter-CLI-Tools docu (#5236)
Signed-off-by: Nils-Christian Iseke <nilsmailiseke@gmail.com> Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com>
1 parent 026191b commit 7c38a44

File tree

10 files changed

+207
-362
lines changed

10 files changed

+207
-362
lines changed

source/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,25 @@ You will need to run this command on every new shell you open to have access to
5656

5757
.. group-tab:: Linux
5858

59-
.. code-block:: bash
59+
.. code-block:: console
60+
61+
$ source /opt/ros/{DISTRO}/setup.bash
6062
61-
# Replace ".bash" with your shell if you're not using bash
62-
# Possible values are: setup.bash, setup.sh, setup.zsh
63-
source /opt/ros/{DISTRO}/setup.bash
63+
64+
Replace ``.bash`` with your shell if you're not using bash.
65+
Possible values are: ``setup.bash``, ``setup.sh``, ``setup.zsh``.
6466

6567
.. group-tab:: macOS
6668

6769
.. code-block:: console
6870
69-
. ~/ros2_install/ros2-osx/setup.bash
71+
$ . ~/ros2_install/ros2-osx/setup.bash
7072
7173
.. group-tab:: Windows
7274

7375
.. code-block:: console
7476
75-
call C:\dev\ros2\local_setup.bat
77+
$ call C:\dev\ros2\local_setup.bat
7678
7779
.. note::
7880
The exact command depends on where you installed ROS 2.
@@ -89,15 +91,15 @@ If you don't want to have to source the setup file every time you open a new she
8991

9092
.. code-block:: console
9193
92-
echo "source /opt/ros/{DISTRO}/setup.bash" >> ~/.bashrc
94+
$ echo "source /opt/ros/{DISTRO}/setup.bash" >> ~/.bashrc
9395
94-
To undo this, locate your system's shell startup script and remove the appended source command.
96+
To undo this, locate your system's shell startup script and remove the appended source command.
9597

9698
.. group-tab:: macOS
9799

98100
.. code-block:: console
99101
100-
echo "source ~/ros2_install/ros2-osx/setup.bash" >> ~/.bash_profile
102+
$ echo "source ~/ros2_install/ros2-osx/setup.bash" >> ~/.bash_profile
101103
102104
To undo this, locate your system's shell startup script and remove the appended source command.
103105

@@ -109,14 +111,14 @@ If you don't want to have to source the setup file every time you open a new she
109111

110112
.. code-block:: console
111113
112-
C:\dev\ros2_{DISTRO}\local_setup.ps1
114+
$ C:\dev\ros2_{DISTRO}\local_setup.ps1
113115
114116
PowerShell will request permission to run this script every time a new shell is opened.
115117
To avoid that issue you can run:
116118

117119
.. code-block:: console
118120
119-
Unblock-File C:\dev\ros2_{DISTRO}\local_setup.ps1
121+
$ Unblock-File C:\dev\ros2_{DISTRO}\local_setup.ps1
120122
121123
To undo this, remove the new 'Microsoft.PowerShell_profile.ps1' file.
122124

@@ -132,19 +134,19 @@ If you ever have problems finding or using your ROS 2 packages, make sure that y
132134

133135
.. code-block:: console
134136
135-
printenv | grep -i ROS
137+
$ printenv | grep -i ROS
136138
137139
.. group-tab:: macOS
138140

139141
.. code-block:: console
140142
141-
printenv | grep -i ROS
143+
$ printenv | grep -i ROS
142144
143145
.. group-tab:: Windows
144146

145147
.. code-block:: console
146148
147-
set | findstr -i ROS
149+
$ set | findstr -i ROS
148150
149151
Check that variables like ``ROS_DISTRO`` and ``ROS_VERSION`` are set.
150152

@@ -170,37 +172,37 @@ Once you have determined a unique integer for your group of ROS 2 nodes, you can
170172

171173
.. code-block:: console
172174
173-
export ROS_DOMAIN_ID=<your_domain_id>
175+
$ export ROS_DOMAIN_ID=<your_domain_id>
174176
175177
To maintain this setting between shell sessions, you can add the command to your shell startup script:
176178

177179
.. code-block:: console
178180
179-
echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bashrc
181+
$ echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bashrc
180182
181183
.. group-tab:: macOS
182184

183185
.. code-block:: console
184186
185-
export ROS_DOMAIN_ID=<your_domain_id>
187+
$ export ROS_DOMAIN_ID=<your_domain_id>
186188
187189
To maintain this setting between shell sessions, you can add the command to your shell startup script:
188190

189191
.. code-block:: console
190192
191-
echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bash_profile
193+
$ echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bash_profile
192194
193195
.. group-tab:: Windows
194196

195197
.. code-block:: console
196198
197-
set ROS_DOMAIN_ID=<your_domain_id>
199+
$ set ROS_DOMAIN_ID=<your_domain_id>
198200
199201
If you want to make this permanent between shell sessions, also run:
200202

201203
.. code-block:: console
202204
203-
setx ROS_DOMAIN_ID <your_domain_id>
205+
$ setx ROS_DOMAIN_ID <your_domain_id>
204206
205207
3.2 The ``ROS_AUTOMATIC_DISCOVERY_RANGE`` variable
206208
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

source/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.rst

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ Install the turtlesim package for your ROS 2 distro:
5555

5656
.. code-block:: console
5757
58-
sudo apt update
59-
60-
sudo apt install ros-{DISTRO}-turtlesim
58+
$ sudo apt update
59+
$ sudo apt install ros-{DISTRO}-turtlesim
6160
6261
.. group-tab:: macOS
6362

@@ -67,16 +66,11 @@ Install the turtlesim package for your ROS 2 distro:
6766

6867
As long as the archive you installed ROS 2 from contains the ``ros_tutorials`` repository, you should already have turtlesim installed.
6968

70-
Check that the package is installed:
71-
72-
.. code-block:: console
73-
74-
ros2 pkg executables turtlesim
75-
76-
The above command should return a list of turtlesim's executables:
69+
To check if the package is installed, run the following command, which should return a list of turtlesim's executables:
7770

7871
.. code-block:: console
7972
73+
$ ros2 pkg executables turtlesim
8074
turtlesim draw_square
8175
turtlesim mimic
8276
turtlesim turtle_teleop_key
@@ -89,20 +83,17 @@ To start turtlesim, enter the following command in your terminal:
8983

9084
.. code-block:: console
9185
92-
ros2 run turtlesim turtlesim_node
86+
$ ros2 run turtlesim turtlesim_node
87+
[INFO] [turtlesim]: Starting turtlesim with node name /turtlesim
88+
[INFO] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]
89+
90+
Under the command, you will see messages from the node.
91+
There you can see the default turtle's name and the coordinates where it spawns.
9392

9493
The simulator window should appear, with a random turtle in the center.
9594

9695
.. image:: images/turtlesim.png
9796

98-
In the terminal, under the command, you will see messages from the node:
99-
100-
.. code-block:: console
101-
102-
[INFO] [turtlesim]: Starting turtlesim with node name /turtlesim
103-
[INFO] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]
104-
105-
There you can see the default turtle's name and the coordinates where it spawns.
10697

10798
3 Use turtlesim
10899
^^^^^^^^^^^^^^^
@@ -113,7 +104,7 @@ Now you will run a new node to control the turtle in the first node:
113104

114105
.. code-block:: console
115106
116-
ros2 run turtlesim turtle_teleop_key
107+
$ ros2 run turtlesim turtle_teleop_key
117108
118109
At this point you should have three windows open: a terminal running ``turtlesim_node``, a terminal running ``turtle_teleop_key`` and the turtlesim window.
119110
Arrange these windows so that you can see the turtlesim window, but also have the terminal running ``turtle_teleop_key`` active so that you can control the turtle in turtlesim.
@@ -130,10 +121,10 @@ You can see the nodes, and their associated topics, services, and actions, using
130121

131122
.. code-block:: console
132123
133-
ros2 node list
134-
ros2 topic list
135-
ros2 service list
136-
ros2 action list
124+
$ ros2 node list
125+
$ ros2 topic list
126+
$ ros2 service list
127+
$ ros2 action list
137128
138129
You will learn more about these concepts in the coming tutorials.
139130
Since the goal of this tutorial is only to get a general overview of turtlesim, you will use rqt to call some of the turtlesim services and interact with ``turtlesim_node``.
@@ -149,15 +140,14 @@ Open a new terminal to install ``rqt`` and its plugins:
149140

150141
.. code-block:: console
151142
152-
sudo apt update
153-
154-
sudo apt install '~nros-{DISTRO}-rqt*'
143+
$ sudo apt update
144+
$ sudo apt install '~nros-{DISTRO}-rqt*'
155145
156146
.. group-tab:: RHEL
157147

158148
.. code-block:: console
159149
160-
sudo dnf install 'ros-{DISTRO}-rqt*'
150+
$ sudo dnf install 'ros-{DISTRO}-rqt*'
161151
162152
.. group-tab:: macOS
163153

@@ -171,7 +161,7 @@ To run rqt:
171161

172162
.. code-block:: console
173163
174-
rqt
164+
$ rqt
175165
176166
5 Use rqt
177167
^^^^^^^^^
@@ -247,7 +237,7 @@ In a new terminal, source ROS 2, and run:
247237

248238
.. code-block:: console
249239
250-
ros2 run turtlesim turtle_teleop_key --ros-args --remap turtle1/cmd_vel:=turtle2/cmd_vel
240+
$ ros2 run turtlesim turtle_teleop_key --ros-args --remap turtle1/cmd_vel:=turtle2/cmd_vel
251241
252242
253243
Now, you can move ``turtle2`` when this terminal is active, and ``turtle1`` when the other terminal running ``turtle_teleop_key`` is active.

source/Tutorials/Beginner-CLI-Tools/Launching-Multiple-Nodes/Launching-Multiple-Nodes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Open a new terminal and run:
5050

5151
.. code-block:: console
5252
53-
ros2 launch turtlesim multisim.launch.py
53+
$ ros2 launch turtlesim multisim.launch.py
5454
5555
This command will run the following launch file:
5656

@@ -79,13 +79,13 @@ In the second terminal:
7979

8080
.. code-block:: console
8181
82-
ros2 topic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"
82+
$ ros2 topic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"
8383
8484
In the third terminal:
8585

8686
.. code-block:: console
8787
88-
ros2 topic pub /turtlesim2/turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: -1.8}}"
88+
$ ros2 topic pub /turtlesim2/turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: -1.8}}"
8989
9090
After running these commands, you should see something like the following:
9191

0 commit comments

Comments
 (0)