Skip to content

Commit 1280ace

Browse files
Fix format to show contents properly (AtsushiSakai#608)
* Fix format to show contents properly Lots of contents were not displayed correctly. I empty lines and :math: labels and fixed it. * Rewrote one subscript as _{rho} This is just a try to see if subscript renders properly. * Added a gif animation for move to pose robot * Added gif; Removed png * Added the into * Changed Param. Def. style to bold text * Added algorithm logic and math * Update docs/modules/control/move_to_a_pose_control/move_to_a_pose_control.rst Co-authored-by: Atsushi Sakai <[email protected]> * Update docs/modules/control/move_to_a_pose_control/move_to_a_pose_control.rst Co-authored-by: Atsushi Sakai <[email protected]> * Changed Eqs 1 and 2 color to black * Added cross-reference labels for Equations 1 and 2 Co-authored-by: Atsushi Sakai <[email protected]>
1 parent 7c3dbb0 commit 1280ace

File tree

1 file changed

+84
-24
lines changed

1 file changed

+84
-24
lines changed

docs/modules/control/move_to_a_pose_control/move_to_a_pose_control.rst

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,111 @@
1-
Move to a pose control
1+
Position Control of non-Holonomic Systems
2+
-----------------------------------------
3+
4+
This section explains the logic of a position controller for systems with constraint (non-Holonomic system).
5+
6+
The position control of a 1-DOF (Degree of Freedom) system is quite straightforward. We only need to compute a position error and multiply it with a proportional gain to create a command. The actuator of the system takes this command and drive the system to the target position. This controller can be easily extended to higher dimensions (e.g., using Kp_x and Kp_y gains for a 2D position control). In these systems, the number of control commands is equal to the number of degrees of freedom (Holonomic system).
7+
8+
To describe the configuration of a car on a 2D plane, we need three DOFs (i.e., x, y, and theta). But to drive a car we only need two control commands (theta_engine and theta_steering_wheel). This difference is because of a constraint between the x and y DOFs. The relationship between the delta_x and delta_y is governed by the theta_steering_wheel.
9+
10+
Note that a car is normally a non-Holonomic system but if the road is slippery, the car turns into a Holonomic system and thus it needs three independent commands to be controlled.
11+
12+
Move to a Pose Control
213
----------------------
314

4-
This is a simulation of moving to a pose control.
15+
In this section, we present the logic of PathFinderController that drives a car from a start pose (x, y, theta) to a goal pose. A simulation of moving to a pose control is presented below.
516

617
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/move_to_pose/animation.gif
718

819

20+
921
PathFinderController class
1022
~~~~~~~~~~~~~~~~~~~~~~~~~~
1123

1224
Constructor
1325
~~~~~~~~~~~
1426

1527
.. code-block:: ipython3
28+
1629
PathFinderController(Kp_rho, Kp_alpha, Kp_beta)
1730
1831
Constructs an instantiate of the PathFinderController for navigating a 3-DOF wheeled robot on a 2D plane.
1932

2033
Parameters:
21-
- Kp_rho: The linear velocity gain to translate the robot along a line towards the goal
22-
- Kp_alpha: The angular velocity gain to rotate the robot towards the goal
23-
- Kp_beta: The offset angular velocity gain accounting for smooth merging to the goal angle (i.e., it helps the robot heading to be parallel to the target angle.)
34+
35+
- | **Kp_rho** : The linear velocity gain to translate the robot along a line towards the goal
36+
- | **Kp_alpha** : The angular velocity gain to rotate the robot towards the goal
37+
- | **Kp_beta** : The offset angular velocity gain accounting for smooth merging to the goal angle (i.e., it helps the robot heading to be parallel to the target angle.)
2438

2539

2640
Member function(s)
2741
~~~~~~~~~~~~~~~~~~
2842

2943
.. code-block:: ipython3
44+
3045
calc_control_command(x_diff, y_diff, theta, theta_goal)
3146
3247
Returns the control command for the linear and angular velocities as well as the distance to goal
3348

3449
Parameters:
35-
- x_diff : The position of target with respect to current robot position in x direction
36-
- y_diff : The position of target with respect to current robot position in y direction
37-
- theta : The current heading angle of robot with respect to x axis
38-
- theta_goal : The target angle of robot with respect to x axis
50+
51+
- | **x_diff** : The position of target with respect to current robot position in x direction
52+
- | **y_diff** : The position of target with respect to current robot position in y direction
53+
- | **theta** : The current heading angle of robot with respect to x axis
54+
- | **theta_goal** : The target angle of robot with respect to x axis
3955

4056
Returns:
41-
- rho : The distance between the robot and the goal position
42-
- v : Command linear velocity
43-
- w : Command angular velocity
57+
58+
- | **rho** : The distance between the robot and the goal position
59+
- | **v** : Command linear velocity
60+
- | **w** : Command angular velocity
61+
62+
How does the Algorithm Work
63+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
64+
The distance between the robot and the goal position, :math:`\rho`, is computed as
65+
66+
.. math::
67+
\rho = \sqrt{(x_{robot} - x_{target})^2 + (y_{robot} - y_{target})^2}.
68+
69+
The distance :math:`\rho` is used to determine the robot speed. The idea is to slow down the robot as it gets closer to the target.
70+
71+
.. math::
72+
v = K_P{_\rho} \times \rho\qquad
73+
:label: eq1
74+
75+
Note that for your applications, you need to tune the speed gain, :math:`K_P{_\rho}` to a proper value.
76+
77+
To turn the robot and align its heading, :math:`\theta`, toward the target position (not orientation), :math:`\rho \vec{u}`, we need to compute the angle difference :math:`\alpha`.
78+
79+
.. math::
80+
\alpha = (\arctan2(y_{diff}, x_{diff}) - \theta + \pi) mod (2\pi) - \pi
81+
82+
The term :math:`mod(2\pi)` is used to map the angle to :math:`[-\pi, \pi)` range.
83+
84+
Lastly to correct the orientation of the robot, we need to compute the orientation error, :math:`\beta`, of the robot.
85+
86+
.. math::
87+
\beta = (\theta_{goal} - \theta - \alpha + \pi) mod (2\pi) - \pi
88+
89+
Note that to cancel out the effect of :math:`\alpha` when the robot is at the vicinity of the target, the term
90+
91+
:math:`-\alpha` is included.
92+
93+
The final angular speed command is given by
94+
95+
.. math::
96+
\omega = K_P{_\alpha} \alpha - K_P{_\beta} \beta\qquad
97+
:label: eq2
98+
99+
The linear and angular speeds (Equations :eq:`eq1` and :eq:`eq2`) are the output of the algorithm.
44100

45101
Move to a Pose Robot (Class)
46102
----------------------------
47103
This program (move_to_pose_robot.py) provides a Robot class to define different robots with different specifications.
48104
Using this class, you can simulate different robots simultaneously and compare the effect of your parameter settings.
49105

50-
.. image:: https://user-images.githubusercontent.com/93126501/145834505-a8df8311-5445-413f-a96f-00460d47991c.png
51-
52-
Note: A gif animation will be added soon.
106+
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/Control/move_to_pos_robot_class/animation.gif
53107

54-
Note: The robot Class is based on PathFinderController class in 'the move_to_pose.py'.
108+
Note: The robot class is based on PathFinderController class in 'the move_to_pose.py'.
55109

56110
Robot Class
57111
~~~~~~~~~~~
@@ -60,36 +114,42 @@ Constructor
60114
~~~~~~~~~~~
61115

62116
.. code-block:: ipython3
117+
63118
Robot(name, color, max_linear_speed, max_angular_speed, path_finder_controller)
64119
65120
Constructs an instantiate of the 3-DOF wheeled Robot navigating on a 2D plane
66121

67122
Parameters:
68-
- name : (string) The name of the robot
69-
- color : (string) The color of the robot
70-
- max_linear_speed : (float) The maximum linear speed that the robot can go
71-
- max_angular_speed : (float) The maximum angular speed that the robot can rotate about its vertical axis
72-
- path_finder_controller : (PathFinderController) A configurable controller to finds the path and calculates command linear and angular velocities.
123+
124+
- | **name** : (string) The name of the robot
125+
- | **color** : (string) The color of the robot
126+
- | **max_linear_speed** : (float) The maximum linear speed that the robot can go
127+
- | **max_angular_speed** : (float) The maximum angular speed that the robot can rotate about its vertical axis
128+
- | **path_finder_controller** : (PathFinderController) A configurable controller to finds the path and calculates command linear and angular velocities.
73129

74130
Member function(s)
75131
~~~~~~~~~~~~~~~~~~
76132

77133
.. code-block:: ipython3
134+
78135
set_start_target_poses(pose_start, pose_target)
79136
80137
Sets the start and target positions of the robot.
81138

82139
Parameters:
83-
- pose_start : (Pose) Start postion of the robot (see the Pose class)
84-
- pose_target : (Pose) Target postion of the robot (see the Pose class)
140+
141+
- | **pose_start** : (Pose) Start postion of the robot (see the Pose class)
142+
- | **pose_target** : (Pose) Target postion of the robot (see the Pose class)
85143

86144
.. code-block:: ipython3
145+
87146
move(dt)
88147
89148
Move the robot for one time step increment
90149

91150
Parameters:
92-
- dt: <float> time increment
151+
152+
- | **dt** : <float> time increment
93153

94154
See Also
95155
--------

0 commit comments

Comments
 (0)