Skip to content

Commit 7c787a7

Browse files
committed
Adjusting and to balance the explanation properly.
1 parent f340aa5 commit 7c787a7

2 files changed

Lines changed: 42 additions & 25 deletions

File tree

docs/source/action_servers.rst

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,23 @@ Overview
7474
This will be the file structure for the :code:`Action` tutorial. Highlighted are the main files for the :code:`ActionServer` and :code:`ActionClient`.
7575

7676
.. code-block:: console
77-
78-
TODO
79-
80-
Before we start exploring the elements of the package, let us
77+
:emphasize-lines: 5
78+
79+
python_package_that_uses_the_actions/
80+
|-- package.xml
81+
|-- python_package_that_uses_the_actions
82+
| |-- __init__.py
83+
| `-- move_straight_in_2d_action_server_node.py
84+
|-- resource
85+
| `-- python_package_that_uses_the_actions
86+
|-- setup.cfg
87+
|-- setup.py
88+
`-- test
89+
|-- test_copyright.py
90+
|-- test_flake8.py
91+
`-- test_pep257.py
92+
93+
Before we start exploring the elements of the package, let us do the following.
8194

8295
#. Create the Node with an :code:`ActionServer`.
8396
#. Create the Node with an :code:`ActionClient`.
@@ -126,12 +139,7 @@ in the action file description, therefore we populate it as needed.
126139
:emphasize-lines: 1, 7, 12, 18, 24, 30, 32
127140

128141
The other methods are to support the important aspects of the action server. The :code:`get_distance` method will compute
129-
the Euclidean distance between :code:`current_position` and :code:`desired_position`. The distance :math:`d` will be calculated
130-
from the terms :math:`x`, :math:`x_d`, :math:`y`, and :math:`y_d`, as follows.
131-
132-
.. math::
133-
134-
d = \sqrt{(x-x_d)^2 + (y-y_d)^2}.
142+
the Euclidean distance between :code:`current_position` and :code:`desired_position`.
135143

136144
This is represented by the following piece of code.
137145

@@ -140,14 +148,7 @@ This is represented by the following piece of code.
140148
:lines: 53-64
141149
:emphasize-lines: 1, 12
142150

143-
The action server will update the :code:`current_position` based on a simple constant speed motion of the point. This
144-
can be mathematically described as follows.
145-
146-
.. math::
147-
148-
p(k+1) = p(k) - s\left(\frac{p - p_d}{d}\right),
149-
150-
where in the :math:`k`\-ith iteration :math:`p(k+1)` represents the next position, :math:`p(k)` the current position, and :math:`s \in \mathbb{R}` is the desired speed.
151+
The action server will update the :code:`current_position` based on a simple constant speed motion of the point.
151152
This is represented by the following piece of code.
152153

153154
.. literalinclude:: ../../ros2_tutorial_workspace/src/python_package_that_uses_the_actions/python_package_that_uses_the_actions/move_straight_in_2d_action_server_node.py

docs/source/actions.rst

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ What about a mixture of messages and services? That is where actions come into p
1111

1212
We use actions by creating an :code:`ActionServer`. The :code:`ActionServer` called by one or more :code:`ActionClient`\s.
1313

14-
Similarly to a service, each action should only have a single :code:`ActionServer` that will receive a :code:`Goal` and provide a :code:`Result`.
15-
It will also provide :code:`Feedback` through a suitable topic. It can be argued that the main difference between a service
16-
and an action is the capability of providing feedback while the action is performed. A service, in contrast, only outputs
17-
a single, final result of the service call.
14+
Similarly to a service, each action should only have a single :code:`ActionServer` that will receive a goal (with a :code:`Request`) and provide
15+
a :code:`Result`. It will also provide :code:`Feedback` through a suitable topic. It can be argued that the main difference
16+
between a service and an action is the capability of providing feedback while the action is performed. A service, in contrast,
17+
only outputs a single, final result of the service call.
1818

1919
Objective
2020
---------
@@ -25,14 +25,30 @@ robot that moves in 2D space and whose orientation is not important. Let it have
2525

2626
.. math::
2727
28-
\boldsymbol{p}(k) =\begin{bmatrix}x(k) \\ y(k)\end{bmatrix}
28+
\mathbb{R}^2 \ni \boldsymbol{p}(k) =\begin{bmatrix}x(k) \\ y(k)\end{bmatrix}
2929
3030
and a desired position given by
3131

3232
.. math::
3333
34-
\boldsymbol{p}_d =\begin{bmatrix}x_d \\ y_d\end{bmatrix}.
34+
\mathbb{R}^2 \ni \boldsymbol{p}_d =\begin{bmatrix}x_d \\ y_d\end{bmatrix}.
3535
3636
Suppose that we want to design an action server that takes this robot-like object from its current position :math:`\boldsymbol{p}` and moves it
3737
towards the goal :math:`\boldsymbol{p}_d` with a speed :math:`s \in \mathbb{R}`. As feedback, it gives us the distance :math:`d \in \mathbb{R}` between the current
38-
position and the desired position.
38+
position and the desired position.
39+
40+
The distance :math:`d \in \mathbb{R}` will be calculated
41+
from the terms :math:`x`, :math:`x_d`, :math:`y`, and :math:`y_d`, as follows.
42+
43+
.. math::
44+
45+
d = \sqrt{(x-x_d)^2 + (y-y_d)^2}.
46+
47+
The action server will update the position :math:`\boldsymbol{p}(k)` based on a simple constant speed motion of the point.
48+
This can be mathematically described as follows.
49+
50+
.. math::
51+
52+
\boldsymbol{p}(k+1) = \boldsymbol{p}(k) - s\left(\frac{\boldsymbol{p} - \boldsymbol{p}_d}{d}\right),
53+
54+
where in the :math:`k`\-ith iteration :math:`\boldsymbol{p}(k+1)` represents the next position, :math:`\boldsymbol{p}(k)` the current position, and :math:`s \in \mathbb{R}` is the desired speed.

0 commit comments

Comments
 (0)