|
38 | 38 | --- |
39 | 39 |
|
40 | 40 | ## 1.1 Installing and Sourcing ROS 2 |
41 | | -* Two types of installation - [Binary](https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html) (recommended) or [Source](https://docs.ros.org/en/foxy/Installation/Ubuntu-Development-Setup.html). |
42 | | -* Live USB has ROS 2 Foxy Binary - Verify : |
43 | | - `ll /opt/ros/foxy`. |
44 | | -* Source ROS 2 to use commands, libraries, packages etc..: |
45 | | -`source /opt/ros/foxy/setup.bash` |
46 | | -* Source your local workspace as needed (which source ROS as well): |
| 41 | +* Two types of installation - [Binary](https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html) (recommended) or [Source](https://docs.ros.org/en/foxy/Installation/Ubuntu-Development-Setup.html). |
| 42 | +* Live USB has ROS 2 Foxy Binary - Verify : |
| 43 | + `ll /opt/ros/foxy`. |
| 44 | +* Source ROS 2 to use commands, libraries, packages etc..: |
| 45 | +`source /opt/ros/foxy/setup.bash` |
| 46 | +* Source your local workspace as needed (which source ROS as well): |
47 | 47 | `source /path/to/ws/install/local_setup.bash` |
48 | 48 |
|
49 | 49 | --- |
50 | | - |
| 50 | + |
51 | 51 | ## 1.2 Aliasing |
52 | | -* Aliases are custom defined abbreviations for commands. |
53 | | -* Simply type |
54 | | -`source_foxy` (or any string you wish) |
55 | | -instead of |
| 52 | +* Aliases are custom defined abbreviations for commands. |
| 53 | +* Simply type |
| 54 | +`source_foxy` (or any string you wish) |
| 55 | +instead of |
56 | 56 | `source /opt/ros/foxy/setup.bash` (or any command you wish) |
57 | 57 | * See cheat sheet for syntax. |
58 | 58 |
|
|
62 | 62 |
|
63 | 63 | ## 1.3 ROS_DOMAIN_ID |
64 | 64 |
|
65 | | -* Environment variable |
| 65 | +* Environment variable |
66 | 66 | * Unique identifier number for each machine |
67 | 67 | * Physically separates network |
68 | 68 | * Stop ROS 2 node interference |
|
84 | 84 | --- |
85 | 85 |
|
86 | 86 | ## 2.1 Basic command structure |
87 | | - |
| 87 | + |
88 | 88 |
|
89 | 89 | We only explore default packages that come with the binary for simplicity. |
90 | 90 |
|
91 | 91 | * All ROS 2 commands follow this syntax : |
92 | | -`ros2 <main_command> <sub_command> <<arguments>>` |
| 92 | +`ros2 <main_command> <sub_command> <<arguments>>` |
93 | 93 |
|
94 | | -* Examples : |
95 | | -`ros2 pkg list` |
| 94 | +* Examples : |
| 95 | +`ros2 pkg list` |
96 | 96 | `ros2 pkg executables` |
97 | 97 |
|
98 | | -Use tab completion to either complete a command, or to see a list of available options. |
| 98 | +Use tab completion to either complete a command, or to see a list of available options. |
99 | 99 | * Example: `ros2 ` *tab* *tab* - List all ROS 2 commands. |
100 | | -* `ros2 pkg ` *tab* *tab* - List of sub-commands for `pkg`. |
101 | | -* `-h` at almost any point to get a brief help description. |
102 | | -`ros2 -h` |
103 | | -`ros2 pkg -h` |
104 | | -`ros2 pkg executable -h` |
| 100 | +* `ros2 pkg ` *tab* *tab* - List of sub-commands for `pkg`. |
| 101 | +* `-h` at almost any point to get a brief help description. |
| 102 | +`ros2 -h` |
| 103 | +`ros2 pkg -h` |
| 104 | +`ros2 pkg executable -h` |
105 | 105 |
|
106 | 106 | --- |
107 | 107 | class: center, middle |
|
111 | 111 | --- |
112 | 112 |
|
113 | 113 | ## 3.1 Publisher |
114 | | - |
115 | 114 |
|
116 | | -The most basic example of ROS - a *Publisher/Subscriber* pair |
117 | 115 |
|
118 | | -* Remember to source ROS 2 |
119 | | -* Command `run` to run an executable within a package (C++ compiled object/Python script): |
| 116 | +The most basic example of ROS - a *Publisher/Subscriber* pair |
| 117 | + |
| 118 | +* Remember to source ROS 2 |
| 119 | +* Command `run` to run an executable within a package (C++ compiled object/Python script): |
120 | 120 |
|
121 | | -`ros2 run <package_name> <executable_name> <<optional_command_line_arguments>>` |
| 121 | +`ros2 run <package_name> <executable_name> <<optional_command_line_arguments>>` |
122 | 122 |
|
123 | | -* Try the example publisher node packaged with ROS 2. |
124 | | -* We first need to find out what the name of the package is. |
125 | | -* Run the package listing command with a filter: |
126 | | -`ros2 pkg list | grep demo` |
127 | | -* Next find the available executables we could use by running : |
128 | | -`ros2 pkg executables demo_nodes_cpp` |
129 | | -* Run one of these executables - the publisher: |
130 | | -`ros2 run demo_nodes_cpp talker` |
| 123 | +* Try the example publisher node packaged with ROS 2. |
| 124 | +* We first need to find out what the name of the package is. |
| 125 | +* Run the package listing command with a filter: |
| 126 | +`ros2 pkg list | grep demo` |
| 127 | +* Next find the available executables we could use by running : |
| 128 | +`ros2 pkg executables demo_nodes_cpp` |
| 129 | +* Run one of these executables - the publisher: |
| 130 | +`ros2 run demo_nodes_cpp talker` |
131 | 131 |
|
132 | | -Observe the state of the ROS 2 runtime system so far... |
| 132 | +Observe the state of the ROS 2 runtime system so far... |
133 | 133 |
|
134 | 134 | --- |
135 | 135 |
|
136 | 136 | ## 3.2 Introspection - Publisher |
137 | 137 |
|
138 | 138 | ### Nodes |
139 | | -* To look at what nodes are currently running: |
140 | | -`ros2 node list` |
141 | | -* To see more info about a node: |
142 | | -`ros2 node info <node_name>` |
| 139 | +* To look at what nodes are currently running: |
| 140 | +`ros2 node list` |
| 141 | +* To see more info about a node: |
| 142 | +`ros2 node info <node_name>` |
143 | 143 |
|
144 | 144 | ### Topics |
145 | | -* To see currently running topics and their message types: |
146 | | -`ros2 topic list -t` |
147 | | -* To get more info about a topic (Foxy: Verbose output): |
| 145 | +* To see currently running topics and their message types: |
| 146 | +`ros2 topic list -t` |
| 147 | +* To get more info about a topic (Foxy: Verbose output): |
148 | 148 | `ros2 topic info -v <topic_name>`<!-- Thanks AWS!!--> |
149 | | -* To see what is being published on a topic: |
| 149 | +* To see what is being published on a topic: |
150 | 150 | `ros2 topic echo <topic_name>` |
151 | 151 |
|
152 | 152 | --- |
153 | 153 |
|
154 | 154 | ## 3.3 Subscriber |
155 | 155 |
|
156 | | -* Start a subscriber that listens to this topic: |
157 | | -`ros2 run demo_nodes_cpp listener` |
| 156 | +* Start a subscriber that listens to this topic: |
| 157 | +`ros2 run demo_nodes_cpp listener` |
158 | 158 |
|
159 | 159 | * The subscriber echoes on the terminal what it hears over the topic. |
160 | 160 |
|
161 | 161 | * Check the running nodes and topics again to see the update. |
162 | 162 |
|
163 | 163 | --- |
164 | | - |
| 164 | + |
165 | 165 | ## 3.4 Introspection - Terminal Publisher |
166 | 166 |
|
167 | | -* Publishers can also be created from the terminal. |
168 | | -`ros2 topic pub <topic_nam> <msg_type> "{<field1_key>: <field1_value>, <field2_key>: <field2_value>, ...}"` |
169 | | -* The message type must be properly understood first. |
170 | | -`ros2 topic list -t` |
171 | | -* The message type of `/topic` is `std_msgs/msg/String` |
172 | | -* For more info: `ros2 interface show std_msgs/msg/String` |
| 167 | +* Publishers can also be created from the terminal. |
| 168 | +`ros2 topic pub <topic_nam> <msg_type> "{<field1_key>: <field1_value>, <field2_key>: <field2_value>, ...}"` |
| 169 | +* The message type must be properly understood first. |
| 170 | +`ros2 topic list -t` |
| 171 | +* The message type of `/topic` is `std_msgs/msg/String` |
| 172 | +* For more info: `ros2 interface show std_msgs/msg/String` |
173 | 173 | * It has only one field - `data` - of the type `string`. |
174 | | -* The message body is a dictionary type, with key-value pairs for the message fields. |
175 | | -* Use `ros2 interface proto std_msgs/msg/String` to get an example of the dictionary to use. |
176 | | -> NOTE THAT SPACING IS VERY IMPORTANT!! |
| 174 | +* The message body is a dictionary type, with key-value pairs for the message fields. |
| 175 | +* Use `ros2 interface proto std_msgs/msg/String` to get an example of the dictionary to use. |
| 176 | +> NOTE THAT SPACING IS VERY IMPORTANT!! |
177 | 177 | * To spawn a publisher over `/topic` with a rate of 10 Hz: |
178 | 178 | `ros2 topic pub -r10 /topic std_msgs/msg/String "data: "Hello""` |
179 | 179 |
|
180 | 180 | --- |
181 | 181 |
|
182 | 182 | ## 3.5 Launch files |
183 | 183 |
|
184 | | -* A way to start many nodes from a single starting point: |
| 184 | +* A way to start many nodes from a single starting point: |
185 | 185 |
|
186 | | -`ros2 launch <package_name> <launch_file_name.launch> <<optional_command_line_arguments>>` |
| 186 | +`ros2 launch <package_name> <launch_file_name.launch> <<optional_command_line_arguments>>` |
187 | 187 |
|
188 | | -* To run both the Subscriber and Publisher from one point: |
189 | | -`ros2 launch demo_nodes_cpp talker_listener.launch.py` |
| 188 | +* To run both the Subscriber and Publisher from one point: |
| 189 | +`ros2 launch demo_nodes_cpp talker_listener.launch.py` |
190 | 190 |
|
191 | | -* Use introspection to verify results and compare. |
| 191 | +* Use introspection to verify results and compare. |
192 | 192 |
|
193 | 193 | --- |
194 | 194 | class: center, middle |
|
200 | 200 |
|
201 | 201 | ## 4.1 Introduction - Services |
202 | 202 |
|
203 | | -* Useful for making short but guaranteed transfer of messages between nodes. |
| 203 | +* Useful for making short but guaranteed transfer of messages between nodes. |
204 | 204 | * It involves two entities - a Server that provides the service and a Client that consumes this service. |
205 | | -* Start these just just like a typical node: |
206 | | -`ros2 run demo_nodes_cpp add_two_ints_server` |
207 | | -`ros2 run demo_nodes_cpp add_two_ints_client` |
| 205 | +* Start these just just like a typical node: |
| 206 | +`ros2 run demo_nodes_cpp add_two_ints_server` |
| 207 | +`ros2 run demo_nodes_cpp add_two_ints_client` |
208 | 208 |
|
209 | 209 | * A Topic streams data whereas a Service makes one exchange per call. |
210 | 210 |
|
211 | 211 | --- |
212 | 212 |
|
213 | 213 | ## 4.2 Introspection - Services |
214 | 214 |
|
215 | | -* List the services offered by servers: |
| 215 | +* List the services offered by servers: |
216 | 216 | `ros2 service list -t` |
217 | | -* Service offered by the demo server - *add_two_ints* |
| 217 | +* Service offered by the demo server - *add_two_ints* |
218 | 218 | * We invoked this service by running a client node |
219 | | -* You can also do this via the CLI. |
| 219 | +* You can also do this via the CLI. |
220 | 220 |
|
221 | 221 | Syntax: `ros2 service call <service_name> <service_type_name> "{<field1_key>: <field1_value>, <field2_key>: <field2_value>, ...}"` |
222 | 222 |
|
223 | | -* To understand the service type: |
224 | | -`ros2 interface list -s` (-s for services. Also, -m, -a) |
| 223 | +* To understand the service type: |
| 224 | +`ros2 interface list -s` (-s for services. Also, -m, -a) |
225 | 225 | `ros2 interface show <service_type_name>` |
226 | 226 |
|
227 | 227 | Example: `ros2 service call /add_two_ints example_interfaces/srv/AddTwoInts "{a: 5, b: 6}"` |
228 | 228 | > NOTE THAT SPACING IS VERY IMPORTANT!! |
229 | 229 |
|
230 | | - |
| 230 | + |
231 | 231 | --- |
232 | 232 | class: center, middle |
233 | 233 | name: main_title |
|
242 | 242 | * Useful for longer tasks that need a feedback & involves an action server and an action client. |
243 | 243 | * Interface has 3 parts - goal, feedback and result. |
244 | 244 | * Typical sequence - Publish a goal, observe feedback & receive result when execution is completed/aborted |
245 | | -* Use the `ros2 action [..]` commands to interact. (New in ROS 2) |
| 245 | +* Use the `ros2 action [..]` commands to interact. (New in ROS 2) |
246 | 246 | * Similar to `ros2 topic [..]` |
247 | 247 |
|
248 | 248 |
|
|
261 | 261 | class: center, middle |
262 | 262 | name: main_title |
263 | 263 |
|
264 | | - # 6. Tools |
| 264 | + # 6. Tools |
265 | 265 |
|
266 | 266 | --- |
267 | 267 |
|
268 | | -## 6.1 Tools - RQT |
| 268 | +## 6.1 Tools - RQT |
269 | 269 |
|
270 | 270 | * QT Based ROS GUI tool. |
271 | | -* Offers plugins for many purposes: |
272 | | - * Node graph monitor, |
273 | | - * Service caller/type viewer, |
274 | | - * Topic publisher/listener/type viewer, |
275 | | - * Image view, |
| 271 | +* Offers plugins for many purposes: |
| 272 | + * Node graph monitor, |
| 273 | + * Service caller/type viewer, |
| 274 | + * Topic publisher/listener/type viewer, |
| 275 | + * Image view, |
276 | 276 | * Plot etc.... |
277 | 277 | * Similar to ROS 1, but few plugins still missing |
278 | 278 | * `rqt &` to launch default main window (`&` ->detached process) |
279 | | -or |
| 279 | +or |
280 | 280 | `ros2 run rqt_<plugin> rqt_<plugin>` to launch a specific plugin |
281 | 281 | * Load a plugin : `Plugins -> <Library> -> <Plugin>` |
282 | 282 | * Example to monitor node graph `Plugins -> Introspection -> Node Graph` |
|
0 commit comments