Skip to content

Commit a46a256

Browse files
committed
Polishes 'Tutorials' documentation.
1 parent 56ca1b7 commit a46a256

34 files changed

+479
-583
lines changed

source/Tutorials.rst

Lines changed: 67 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,81 @@
22
Tutorials
33
=========
44

5-
.. toctree::
6-
:hidden:
7-
:glob:
8-
9-
Tutorials/*
10-
5+
Basic
6+
-----
117

12-
ROS 2 Tutorials
13-
---------------
148

15-
16-
* `Installation from binary and source, all platforms <Installation>`
17-
* `Using colcon to build a custom package <Tutorials/Colcon-Tutorial>`
18-
* `Using ament mixed with catkin <Tutorials/catment>`
19-
* `Introspection with command-line tools <Tutorials/Introspection-with-command-line-tools>`
20-
* `User Interfaces with RQt <Tutorials/RQt-Overview-Usage>`
21-
* `Passing ROS arguments to nodes via the command-line <Tutorials/Node-arguments>`
22-
* `Launching/monitoring multiple nodes with Launch <Tutorials/Launch-system>`
23-
* `Working with multiple RMW implementations <Tutorials/Working-with-multiple-RMW-implementations>`
24-
* `Composing multiple nodes in a single process <Tutorials/Composition>`
25-
* `Defining custom interfaces (msg/srv) <Tutorials/Defining-custom-interfaces-(msg-srv)>`
26-
* `New features in ROS 2 interfaces (msg srv) <Tutorials/New-features-in-ROS-2-interfaces-(msg-srv)>`
27-
* `Eclipse Oxygen with ROS 2 and rviz2 <Tutorials/Eclipse-Oxygen-with-ROS-2-and-rviz2>` [community-contributed]
28-
* `Building ROS 2 on Linux with Eclipse Oxygen <Tutorials/Building-ROS-2-on-Linux-with-Eclipse-Oxygen>` [community-contributed]
29-
* `Building Realtime rt_preempt kernel for ROS 2 <Tutorials/Building-Realtime-rt_preempt-kernel-for-ROS-2>` [community-contributed]
9+
.. toctree::
10+
:maxdepth: 1
11+
12+
Tutorials/Colcon-Tutorial
13+
Tutorials/Ament-Tutorial
14+
Tutorials/catment
15+
Tutorials/Introspection-with-command-line-tools
16+
Tutorials/RQt-Overview-Usage
17+
Tutorials/RQt-Port-Plugin-Windows
18+
Tutorials/Node-arguments
19+
Tutorials/Launch-system
20+
Tutorials/Working-with-multiple-RMW-implementations
21+
Tutorials/Composition
22+
Tutorials/Rosidl-Tutorial.rst
23+
Tutorials/New-features-in-ROS-2-interfaces-(msg-srv)
24+
Tutorials/Defining-custom-interfaces-(msg-srv)
25+
Tutorials/Eclipse-Oxygen-with-ROS-2-and-rviz2
26+
Tutorials/Building-ROS-2-on-Linux-with-Eclipse-Oxygen
27+
Tutorials/Building-Realtime-rt_preempt-kernel-for-ROS-2
28+
Tutorials/Releasing-a-ROS-2-package-with-bloom
29+
3030

3131
Advanced
32-
^^^^^^^^
33-
32+
--------
3433

35-
* `Implement a custom memory allocator <Tutorials/Allocator-Template-Tutorial>`
36-
37-
Docker
38-
^^^^^^
39-
40-
41-
* `Run 2 nodes in a single docker container <Tutorials/Run-2-nodes-in-a-single-docker-container>` [community-contributed]
42-
* `Run 2 nodes in two separate docker containers <Tutorials/Run-2-nodes-in-two-separate-docker-containers>` [community-contributed]
34+
.. toctree::
35+
:maxdepth: 1
36+
37+
Tutorials/Allocator-Template-Tutorial
4338

44-
ROS 2 Demos
45-
-----------
4639

40+
Using Docker
41+
------------
4742

48-
* `Use quality-of-service settings to handle lossy networks <Tutorials/Quality-of-Service>`
49-
* `Management of nodes with managed lifecycles <Tutorials/Managed-Nodes>`
50-
* `Efficient intra-process communication <Tutorials/Intra-Process-Communication>`
51-
* `Bridge communication between ROS 1 and ROS 2 <https://github.com/ros2/ros1_bridge/blob/master/README.md>`__
52-
* `Recording and playback of topic data with rosbag using the ROS 1 bridge <Tutorials/Rosbag-with-ROS1-Bridge>`
53-
* `Turtlebot 2 demo using ROS 2 <https://github.com/ros2/turtlebot2_demo>`__
54-
* `TurtleBot 3 demo using ROS 2 <http://emanual.robotis.com/docs/en/platform/turtlebot3/applications/#ros2>`__ [community-contributed]
55-
* `Using tf2 with ROS 2 <Tutorials/tf2>`
56-
* `Write real-time safe code that uses the ROS 2 APIs <Tutorials/Real-Time-Programming>`
57-
* `Use the rclpy API to write ROS 2 programs in Python <Tutorials/Python-Programming>`
58-
* `Use the robot state publisher to publish joint states and TF <Tutorials/dummy-robot-demo>`
59-
* `Use DDS-Security <https://github.com/ros2/sros2/blob/master/README.md>`__
60-
* `Logging and logger configuration <Tutorials/Logging-and-logger-configuration>`
43+
.. toctree::
44+
:maxdepth: 1
45+
46+
Tutorials/Run-2-nodes-in-a-single-docker-container
47+
Tutorials/Run-2-nodes-in-two-separate-docker-containers
6148

62-
ROS 2 Examples
63-
--------------
49+
Demos
50+
-----
6451

52+
.. toctree::
53+
:hidden:
6554

66-
* `Python and C++ minimal examples <https://github.com/ros2/examples>`__
55+
Tutorials/Quality-of-Service
56+
Tutorials/Managed-Nodes
57+
Tutorials/Intra-Process-Communication
58+
Tutorials/Rosbag-with-ROS1-Bridge
59+
Tutorials/tf2
60+
Tutorials/Real-Time-Programming
61+
Tutorials/Python-Programming
62+
Tutorials/dummy-robot-demo
63+
Tutorials/Logging-and-logger-configuration
64+
65+
* `Use quality-of-service settings to handle lossy networks <Tutorials/Quality-of-Service>`.
66+
* `Management of nodes with managed lifecycles <Tutorials/Managed-Nodes>`.
67+
* `Efficient intra-process communication <Tutorials/Intra-Process-Communication>`.
68+
* `Bridge communication between ROS 1 and ROS 2 <https://github.com/ros2/ros1_bridge/blob/master/README.md>`__.
69+
* `Recording and playback of topic data with rosbag using the ROS 1 bridge <Tutorials/Rosbag-with-ROS1-Bridge>`.
70+
* `Turtlebot 2 demo using ROS 2 <https://github.com/ros2/turtlebot2_demo>`__.
71+
* `TurtleBot 3 demo using ROS 2 <http://emanual.robotis.com/docs/en/platform/turtlebot3/applications/#ros2>`__. [community-contributed]
72+
* `Using tf2 with ROS 2 <Tutorials/tf2>`.
73+
* `Write real-time safe code that uses the ROS 2 APIs <Tutorials/Real-Time-Programming>`.
74+
* `Use the rclpy API to write ROS 2 programs in Python <Tutorials/Python-Programming>`.
75+
* `Use the robot state publisher to publish joint states and TF <Tutorials/dummy-robot-demo>`.
76+
* `Use DDS-Security <https://github.com/ros2/sros2/blob/master/README.md>`__.
77+
* `Logging and logger configuration <Tutorials/Logging-and-logger-configuration>`.
78+
79+
Examples
80+
--------
81+
82+
* `Python and C++ minimal examples <https://github.com/ros2/examples>`__.

source/Tutorials/About-Quality-of-Service-Settings.rst

Lines changed: 0 additions & 163 deletions
This file was deleted.

source/Tutorials/Allocator-Template-Tutorial.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

2+
Implement a custom memory allocator
3+
===================================
4+
5+
.. contents:: Table of Contents
6+
:depth: 1
7+
:local:
8+
29
This tutorial will teach you how to integrate a custom allocator for publishers and subscribers so that the default heap allocator is never called while your ROS nodes are executing.
310
The code for this tutorial is available `here <https://github.com/ros2/demos/blob/master/demo_nodes_cpp/src/topics/allocator_tutorial.cpp>`__.
411

@@ -20,7 +27,7 @@ The C++11 library provides something called ``allocator_traits``. The C++11 stan
2027

2128
For example, the following declaration for a custom allocator would satisfy ``allocator_traits`` (of course, you would still need to implement the declared functions in this struct):
2229

23-
.. code-block:: bash
30+
.. code-block:: c++
2431

2532
template <class T>
2633
struct custom_allocator {
@@ -39,11 +46,11 @@ For example, the following declaration for a custom allocator would satisfy ``al
3946

4047
You could then access other functions and members of the allocator filled in by ``allocator_traits`` like so: ``std::allocator_traits<custom_allocator<T>>::construct(...)``
4148

42-
To learn about the full capabilities of ``allocator_traits``\ , see: http://en.cppreference.com/w/cpp/memory/allocator_traits
49+
To learn about the full capabilities of ``allocator_traits``, see http://en.cppreference.com/w/cpp/memory/allocator_traits .
4350

4451
However, some compilers that only have partial C++11 support, such as GCC 4.8, still require allocators to implement a lot of boilerplate code to work with standard library structures such as vectors and strings, because these structures do not use ``allocator_traits`` internally. Therefore, if you're using a compiler with partial C++11 support, your allocator will need to look more like this:
4552

46-
.. code-block:: bash
53+
.. code-block:: c++
4754

4855
template<typename T>
4956
struct pointer_traits {
@@ -95,7 +102,7 @@ Writing an example main
95102

96103
Once you have written a valid C++ allocator, you must pass it as a shared pointer to your publisher, subscriber, and executor.
97104

98-
.. code-block:: bash
105+
.. code-block:: c++
99106

100107
auto alloc = std::make_shared<MyAllocator<void>>();
101108
auto publisher = node->create_publisher<std_msgs::msg::UInt32>("allocator_example", 10, alloc);
@@ -111,13 +118,13 @@ Once you have written a valid C++ allocator, you must pass it as a shared pointe
111118

112119
You will also need to use your allocator to allocate any messages that you pass along the execution codepath.
113120

114-
.. code-block:: bash
121+
.. code-block:: c++
115122

116123
auto alloc = std::make_shared<MyAllocator<void>>();
117124

118125
Once you've instantiated the node and added the executor to the node, it's time to spin:
119126

120-
.. code-block:: bash
127+
.. code-block:: c++
121128

122129
uint32_t i = 0;
123130
while (rclcpp::ok()) {
@@ -135,7 +142,7 @@ Even though we instantiated a publisher and subscriber in the same process, we a
135142

136143
The IntraProcessManager is a class that is usually hidden from the user, but in order to pass a custom allocator to it we need to expose it by getting it from the rclcpp Context. The IntraProcessManager makes use of several standard library structures, so without a custom allocator it will call the default new.
137144

138-
.. code-block:: bash
145+
.. code-block:: c++
139146

140147
auto context = rclcpp::contexts::default_context::get_global_default_context();
141148
auto ipm_state =
@@ -155,7 +162,7 @@ The obvious thing to do would be to count the calls made to your custom allocato
155162

156163
Adding counting to the custom allocator is easy:
157164

158-
.. code-block:: bash
165+
.. code-block:: c++
159166

160167
T * allocate(size_t size, const void * = 0) {
161168
// ...
@@ -171,7 +178,7 @@ Adding counting to the custom allocator is easy:
171178

172179
You can also override the global new and delete operators:
173180

174-
.. code-block:: bash
181+
.. code-block:: c++
175182

176183
void operator delete(void * ptr) noexcept {
177184
if (ptr != nullptr) {

0 commit comments

Comments
 (0)