Modified 2018-06-24 by Andrea Censi
Obtaining a mathematical model of the Duckiebot is important in order to (a) understand its behavior and (b) design a controller to obtain desired behaviors and performances, robustly.
The Duckiebot uses an actuator (DC motor) for each wheel. By applying different torques to the wheels a Duckiebot can turn, go straight (same torque to both wheels) or stay still (no torque to both wheels). This driving configuration is referred to as differential drive.
In this section we will derive the model of a differential drive wheeled robot. The Duckiebot model will receive voltages as input (to the DC motors) and produce a configuration, or pose, as output. The pose describes unequivocally the position and orientation of the Duckiebot with respect to some Newtonian “world” frame.
Different methods can be followed to obtain the Duckiebot model, namely the Lagrangian or Newton-Euler, we choose to describe the latter as it arguably provides a clearer physical insight. Showing the equivalence of these formulations is an interesting exercises that the interested reader can take as a challenge. A useful resource for modeling of a Duckiebot may be found here [10].
Requires:k:reference_frames (inertial, body), k:intro-transformations (Cartesian, polar)
Suggested: k:intro-ODEs-to-LTIsys
k:diff-drive-robot-model
Modified 2018-06-24 by Andrea Censi
TODO: relabel inertial frame -> local frame; $(\cdot)^I \rightarrow (\cdot)^L$
The following was marked as "todo".
TODO: relabel inertial frame -> local frame; $(\cdot)^I \rightarrow (\cdot)^L$
File book/learning_materials/71_duckiebot_modeling/10_basic_car_modeling-kin-and-dyn.md.
File book/learning_materials/71_duckiebot_modeling/10_basic_car_modeling-kin-and-dyn.md
in repo duckietown/docs-learning_materials branch master18 commit d4c2a61a
last modified by Andrea Censi on 2018-06-24 17:48:00
create_notes_from_elements
in module mcdp_docs.task_markers
.We first briefly recapitulate on the reference frames that we will use to model the Duckiebot, with the intent of introducing the notation used throughout this chapter. It is important to note that we restrict the current analysis to the plane, so all of the following in defined in $\reals^2$.
To describe the behavior of a Duckiebot three reference frames will be used:
A “world” frame: a right handed fixed reference system with origin in some arbitrary point $O$. We will indicate variables expressed in this frame with a superscript $W$, e.g., $X^W$, unless there is no risk of ambiguity, in which case no superscript will be used.
An “inertial” frame: a fixed reference system parallel to the “world” frame, that spans the plane on which the Duckiebot moves. We will denote its axis as $\{X_I, Y_I\}$, and it will have origin in point $A=(x_A, y_A)$, i.e., the midpoint of the robot’s wheel axle. We will indicate variables expressed in this frame with a superscript $I$, e.g., $X^I$, unless there is no risk of ambiguity, in which case no superscript will be used.
A body (or “robot”) frame: a local reference frame fixed with respect to the robot, centered in $A$ as well. The $x$ axis points in the direction of the front of the robot, and the $y$ axis lies along the axis between the wheels, so to form a right handed reference system. We denote the robot body frame with $\{X_R, X_R\}$. The same superscript convention as above will be used. The wheels will have radius $R$.
The robot is assumed to be a rigid body, symmetric, and $X_r$ coincides with axis of symmetry. Moreover, the wheels are considered identical and at the same distance, $L$, from the axle midpoint $A$.
Moreover:
The center of mass $C^W = (x_c, y_c)$ of the robot is on the $x_r$ axis, at a distance $c$ from $A$, i.e., ($C^R = (c, 0)$);
$X^r$ forms an orientation angle $\theta$ with the local horizontal plane.
These notations are summarized in Figure 1.2.
Modified 2018-06-22 by Andrea Censi
We briefly recapitulate on a few transformations that we will use throughout this chapter.
Let $\avec{x^I} = [x^I, y^I]$ be a vector represented in the inertial frame and $\avec{X^I} = [x^I, y^I, 1]^T$ be its augmented version. It is possible to express such vector in the world frame through a translation:
\begin{align} \label{eq:mod-translation-i2w}\tag{11} \avec{X^W}= \amat{T}\avec{X^R}, \end{align}
where the translation matrix $\amat{T}$ is defined as:
\begin{align} \amat{T} = \left[ \begin{array}{ccc} 1 & 0 & x_A \\ 0 & 1 & y_A \\ 0 & 0 & 1 \end{array} \right] \left[\begin{array}{c} x^I \\ y^I \\ 1 \end{array} \right]. \end{align}
In the Euclidian space, each translation preserves distances (norms), i.e., is an isometry. So, for example, a velocity expressed in the inertial frame will have the same magnitude as that velocity expressed in the world frame.
Let $\avec{x^R} = [x^R, y^R]^T$ be a vector represented in the robot frame and $\avec{X^R} = [x^R, y^R, 1]^T$ its augmented version. It is possible to express such vector in the inertial frame through a rotation:
\begin{align} \label{eq:mod-rotation-r2i}\tag{12} \avec{X^I}= \amat{R}(\theta)\avec{X^R}, \end{align}
where $\amat{R}(\theta) \in SO(2)$ is an orthogonal rotation matrix:
\begin{align} \label{eq:mod-rot-mat}\tag{13} \amat{R}(\theta) = \left[ \begin{array}{ccc} \cos\theta & -\sin \theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{array} \right]. \end{align}
The orthogonality condition implies that $\amat{R}^T(\theta)\amat{R}(\theta) = \amat{R}(\theta)\amat{R}^T(\theta) = \amat{I}$, hence: $$ \label{eq:mod-orthogonality-cond}\tag{1} \amat{R}^T(\theta) = \amat{R}^{-1}(\theta), $$ which is quite nice.
A corollary of \eqref{eq:mod-translation-i2w} and \eqref{eq:mod-rotation-r2i} is that the translations and rotations can be combined in a single transformation, because $\avec{X^W} = \amat{T}\avec{X^I} = \amat{T} \amat{R}(\theta)\avec{X^R}$. The combined transformation matrix is given by:
\begin{align} \label{eq:mod-rototranslation-mat}\tag{14} \amat{T} \amat{R}(\theta) = \left[ \begin{array}{ccc} \cos\theta & -\sin \theta & x_A \\sin\theta & \cos\theta & y_A \\ 0 & 0 & 1 \end{array} \right]. \end{align}
Modified 2018-06-22 by Andrea Censi
While kinematics studies the properties of motions of geometric (i.e., massless) points, dynamical modeling takes into account the actual material distribution of the system. Once mass comes into play, motion is the result of the equilibrium of external forces and torques with inertial reactions. While different approaches can be used to derive these equations, namely the Lagrangian or Newtonian approaches (former based on energy considerations, latter on equilibrium of generalized forces), we choose to follow the Newtonian one here for it grants, arguably, a more explicit physical intuition of the problem. Obviously both methods lead to the same results when the same hypothesis are made.
For starters, recalling that $C^r = (c, 0)$ is the center of mass of the robot, we define the relevant notations:
$(v_u, v_w)$ | Longitudinal and lateral velocities of $C$, robot frame |
$(a_u, a_w)$ | Longitudinal and lateral accelerations of $C$, robot frame |
$(F_{u_R}, F_{u_L})$ | Longitudinal forces exerted on the vehicle by the right and left wheels |
$(F_{w_R}, F_{w_L})$ | Lateral forces exerted on the vehicle by the right and left wheels |
$(\tau_R, \tau_L)$ | Torques acting on right and left wheel |
$\theta$, $\omega = \dot \theta$ | Vehicle orientation and angular velocity |
$M$ | Vehicle mass |
$J$ | Vehicle yaw moment of inertia with respect to the center of mass $C$ |
Figure 1.4 summarizes these notations.
Before deriving the dynamic model of the robot, it is useful to recall some elements of polar coordinates kinematics.
Modified 2018-06-22 by Andrea Censi
Let $\avec{r}(t)$ identify a point in the space from the inertial frame at distance $r(t)$ from the $A$.
You might want to refresh Euler formula to convince yourself about the following.
\begin{align} \label{eq:mod-polar-kin-deriv}\tag{15} \avec{r}(t) &= r(t) e^{j\theta(t)} \\ \avec{\dot r}(t) &= v_u(t) e^{j\theta(t)} + v_w(t) e^{j(\theta(t)+\frac{\pi}{2})} \\ \avec{\ddot r}(t) &= a_u(t) e^{j\theta(t)} + a_w(t) e^{j(\theta(t)+\frac{\pi}{2})}, \end{align}
with:
\begin{align} \label{eq:mod-polar-kin-coeff}\tag{16} v_u(t) &= \dot r(t)\\ v_w(t) &= r (t) \dot \theta (t)\\ a_u(t) &= \dot v_u - v_w \dot \theta (t) = \ddot r(t) - r \dot \theta^2(t)\\ a_w(t) &= \dot v_w + v_u \dot \theta (t) = 2 \dot r (t) \dot \theta (t) + r(t) \ddot \theta (t). \end{align}
Keeping \eqref{eq:mod-polar-kin-deriv} and \eqref{eq:mod-polar-kin-coeff} in mind, it is useful to note (for later use) that, letting $\avec{r}(t)$ identify the position of the center of mass $C$ in the inertial frame:
\begin{align} \label{eq:mod-C-world-pos}\tag{17} \left\{ \begin{array}{ll} x_C^W(t) &= x_A(t) + r(t) \cos\theta(t) \\ y_C^W(t) &= y_A(t) + r(t) \sin\theta(t) \end{array} \right., \end{align}
and therefore:
\begin{align} \label{eq:mod-A-dot-polar}\tag{18} \left\{ \begin{array}{ll} \dot x^I_A(t) &= x^W_C(t) - v_u(t) \cos\theta(t) + v_w(t) \sin\theta(t)\\ \dot y^I_A(t) &= y^W_C(t) - v_u(t) \sin\theta(t) - v_w(t) \cos\theta(t) \end{array} \right.. \end{align}
Modified 2018-06-22 by Andrea Censi
The next step, and definitely the most critical, is writing the free body diagram of the problem (Figure 1.4). In this analysis the only forces acting on the robot are those applied from the wheels to the vehicle’s chassis. It is important to note that the third passive wheel (omnidirectional or caster) is not being taken into account.
Modified 2018-06-22 by Andrea Censi
We derive the dynamic model by imposing the simultaneous equilibrium of forces along the longitudinal and lateral directions in the robot frame with the respective inertial forces, and of the moments around the vertical axis (coming out of the.. screen) passing through the center of mass of the robotic vehicle.
\begin{align} \label{eq:mod-dyn-equilibria}\tag{19} Ma_u(t) &= F_{u_L}+F_{u_R} \\ Ma_w(t) &= F_{w_L}+F_{w_R} \\ \ddot{\theta}(t) &= \frac{L}{J}(F_{u_R}-F_{u_L}) + \frac{c}{J}(F_{w_R}+F_{w_L}). \end{align}
By substituting the \eqref{eq:mod-polar-kin-coeff} in \eqref{eq:mod-dyn-equilibria}, the equilibrium equations are expressed in terms of accelerations of the center of mass in the robot frame:
\begin{align} \dot{v}_u(t) &= v_w(t) \dot{\theta}(t) + \frac{F_{u_L}+F_{u_R}}{M} \label{eq:mod-dyn-equilibria2a}\tag{20} \\ \dot{v}_w(t) &= -v_u(t) \dot{\theta}(t)+\frac{F_{w_L}+F_{w_R}}{M} \label{eq:mod-dyn-equilibria2b}\tag{21} \\ \ddot{\theta}(t) &= \frac{L}{J}(F_{u_R}-F_{u_L}) - \frac{c}{J}(F_{w_R}+F_{w_L}). \label{eq:mod-dyn-equilibria2c}\tag{22} \end{align}
This is a general dynamic model (in the sense of no kinematic constraints) of a differential drive robot under the geometric assumptions listed above. It is noted that it is a coupled and nonlinear model, not exactly a best case scenario (we like linear things, because there are plenty of tools to handle them). When using the general dynamic model above, it makes sense to associate the general kinematic model as well, given by:
\begin{align} \label{eq:mod-gen-kin-mod}\tag{23} \dot{x}_A(t) &= v_u(t) \cos\theta(t) - (v_w(t)-c \dot \theta)\sin\theta(t) \\ \dot{y}_A(t) &= v_u(t) \sin\theta(t) + (v_w(t)-c \dot \theta)\sin\theta(t). \end{align}
the above \eqref{eq:mod-gen-kin-mod} can be obtained by recalling on one side that translations are isometric transformations, and on the other side that:
\begin{align} \label{eq:mod-xCW}\tag{24} \left\{ \begin{array}{ll} x_A(t) &= x^W_C(t) - c \cos\theta(t) \\ y_A(t) &= y^W_C(t) - c \sin\theta(t) \end{array} \right. \end{align}
\begin{align} \label{eq:mod-xCI}\tag{25} \left\{ \begin{array}{ll} x_C^I(t) &= v_u(t) \cos\theta(t) - v_w(t) \sin\theta(t) \\ y_C^I(t) &= v_u(t) \sin\theta(t) + v_w(t) \cos\theta(t) \end{array} \right. \end{align}
Equation \eqref{eq:mod-gen-kin-mod} can be rewritten as: $$ \label{eq:mod-gen-kin-mod-better}\tag{2} \avec{v_A^I} = \amat{R}(\theta) \avec{v_A^R} $$, where: $$ \label{eq:mod-v_A^R}\tag{3} \avec{v_A^R} = [v_u(t), v_w(t) - c\dot\theta(t)]^T. $$
In order to simplify the model, we proceed to impose some kinematic constraints.
Modified 2018-06-24 by Andrea Censi
In this section we derive the kinematic model of a differential drive mobile platform under the assumptions of (a) no lateral slipping and (b) pure rolling of the wheels. We refer to these two assumptions as kinematic constraints.
Modified 2018-06-22 by Andrea Censi
The kinematic constraints are derived from two assumptions:
By inverting \eqref{eq:mod-rotation-r2i}, this constraint can be expressed through the inertial frame variables, yielding:
$$ \label{eq:mod-no-lat-slip-constraint-i}\tag{5} \dot y_A(t) \cos \theta(t) -\dot x_A(t) \sin \theta(t) = 0. $$
Imposing \eqref{eq:mod-no-lat-slip-constraint-i} on \eqref{eq:mod-A-dot-polar} results in:
$$ \label{eq:mod-no-lat-slip-constraint-v_w}\tag{6} v_w(t) = \dot y_C^I(t) \cos\theta(t) - \dot x_C^I(t) \sin\theta(t), $$
and by recalling that $C^R = (c,0)$:
$$ \label{eq:mod-no-lat-slip-constraint-C}\tag{7} \dot y_C^I(t) \cos\theta(t) - \dot x_C^I(t) \sin\theta(t) = c\dot\theta(t). $$
Hence, we obtain the strongest expression of this constraint:
$$ \label{eq:mod-no-lat-slip-final}\tag{8} v_w(t) = c\dot\theta(t), $$
and therefore:
$$ \label{eq:mod-no-lat-slip-final-dot}\tag{9} \dot v_w(t) = c\ddot\theta(t). $$
a simpler way of deriving \eqref{eq:mod-no-lat-slip-final-dot} is noticing, from \eqref{eq:mod-v_A^R}, that $\dot y_A^R = v_w(t) - c\dot\theta(t)$.
\begin{align} \label{eq:mod-pure-rolling}\tag{26} \left\{ \begin{array}{ll} v_{P,r} &= R \dot \varphi_{r} \\ v_{P,l} &= R \dot \varphi_{l} \end{array} \right.. \end{align}
Another notable consequence of this assumption is that, always in the robot frame, the full power of the motor can be translated into a propelling force for the vehicle in the longitudinal direction. Or, more simply, it allows to write:
$$ \label{eq:mod-force-and-torque}\tag{10} F_{u, (\cdot)}(t)R = \tau_{(\cdot)}(t), $$
where $\tau_{(\cdot)}(t)$ is the torque exerted by each motor on its wheel $(\cdot) = {l,r}$.
Modified 2018-06-22 by Andrea Censi
In a differential drive robot, controlling the wheels at different speeds generates a rolling motion of rate $\omega = \dot \theta$. In a rotating field there always is a fixed point, the center of instantaneous curvature (ICC), and all points at distance $d$ from it will have a velocity given by $\omega d$, and direction orthogonal to that of the line connecting the ICC and the wheels (i.e., the axle). Therefore, by looking at Figure 1.2, we can write:
\begin{align} \label{eq:mod-kin-1}\tag{27} \left\{ \begin{array}{l} \dot \theta (d-L) &= v_l \\ \dot \theta (d+L) &= v_r \end{array} \right., \end{align}
from which:
\begin{align} \label{eq:mod-kin-2}\tag{28} \left\{ \begin{array}{l} d &= L \frac{v_r + v_l}{v_r - v_l} \\ \dot \theta &= \frac{v_r - v_l}{2L} \end{array} \right.. \end{align}
A few observations stem from \eqref{eq:mod-kin-2}:
Moreover, a differential drive robot cannot move in the direction of the ICC, it is a singularity.
By recalling the no lateral slipping motion \eqref{eq:mod-no-lat-slip-constraint-r} hypothesis and the pure rolling constraint \eqref{eq:mod-pure-rolling}, and noticing that the translational velocity of $A$ in the robot frame is $v_A = \dot \theta d = (v_r+v_l)/2$ we can write:
\begin{align} \label{eq:mod-kin-3}\tag{29} \left\{ \begin{array}{l} \dot x_A^R &= R (\dot \varphi_R +\dot \varphi_L)/2 \\ \dot y_A^R &= 0 \\ \dot \theta &= \omega = R(\dot \varphi_R - \dot \varphi_L)/(2L) \end{array} \right., \end{align}
which in more compact yields the simplified forward kinematics in the robot frame:
\begin{align} \label{eq:mod-forward-kinematics-robot-frame}\tag{30} \left[ \begin{array}{c} \dot x_A^R \\ \dot y_A^R \\ \dot \theta \end{array} \right] = \left[ \begin{array}{cc} \frac{R}{2} & \frac{R}{2} \\ 0 & 0 \\ \frac{R}{2L} & -\frac{R}{2L} \\ \end{array} \right] \left[ \begin{array}{c} \dot \varphi_R \\ \dot \varphi_L \end{array} \right]. \end{align}
Finally, by using \eqref{eq:mod-rot-mat}, we can recast \eqref{eq:mod-forward-kinematics-robot-frame} in the inertial frame.
The simplified forward kinematics model of a differential drive vehicle is given by: \begin{align} \label{eq:mod-forward-kinematics-inertial-frame}\tag{31} \displaystyle \avec{\dot q}^I = \amat{R}(\theta) \left[ \begin{array}{c} \dot x_A^r \\ \dot y_A^r \\ \dot \theta \end{array} \right] = \left[ \begin{array}{cc} \frac{R}{2} \cos \theta & \frac{R}{2} \cos \theta \\ \frac{R}{2} \sin \theta & \frac{R}{2} \sin \theta \\ \frac{R}{2L} & -\frac{R}{2L} \\ \end{array} \right] \left[ \begin{array}{c} \dot \varphi_R \\ \dot \varphi_L \end{array} \right] = \left[ \begin{array}{cc} \cos \theta & 0 \\ \sin \theta & 0 \\ 0 & 1 \\ \end{array} \right] \left[ \begin{array}{c} v_A \\ \omega \end{array} \right]. \end{align}
Modified 2018-06-22 by Andrea Censi
By implementing the kinematic constraints formulations derived above, i.e., the no lateral slipping (\eqref{eq:mod-no-lat-slip-final-dot}) and pure rolling (\eqref{eq:mod-force-and-torque}) in the general dynamic model, it is straightforward to obtain:
\begin{align} \label{eq:mod-dyn-model-a}\tag{32} \dot{v}_u (t) &= c \dot \theta^2(t) + \frac{1}{RM} (\tau_R(t)+\tau_L(t)) \\ \dot v_w(t) &= c \dot\theta(t) \\ \ddot \theta &= - \frac{Mc}{Mc^2+J} \dot\theta(t)v_u(t) + \frac{L}{R(Mc^2+J)}(\tau_R(t)-\tau_L(t)) \end{align}
Modified 2018-06-22 by Andrea Censi
The equations governing the behavior of a DC motor are driven by an input armature voltage $V(t)$:
\begin{align} V(t) &= Ri(t) + L \frac{di}{dt} + e(t) \\ e(t) &= K_b \dot\varphi(t) \\ \tau_m(t) &= K_t i(t) \\ \tau(t) &= N \tau_m(t), \end{align}
where $(K_b, K_t)$ are the back emf and torque constants respectively and $N$ is the gear ratio ($N=1$ in the Duckiebot).
Figure 1.8 shows a diagram of a typical DC motor.
Having a relation between the applied voltage and torque, in addition to the dynamic and kinematic models of a differential drive robot, allows us to determine all possible state variables of interest.
torque disturbances acting on the wheels, such as the effects of friction, can be modeled as additive terms (of sign opposite to $\tau$) in the DC motor equations.
Modified 2018-06-22 by Andrea Censi
In this chapter we derived a model for a differential drive robot. Although several simplifying assumption were made, e.g., rigid body motion, symmetry, pure rolling and no lateral slipping - still the model is nonlinear.
Regardless, we now have a sequence of descriptive tools that receive as input the voltage signal sent by the controller, and produce as output any of the state variables, e.g., the position, velocity and orientation of the robot with respect to a fixed inertial frame.
Several outstanding questions remain. For example, we need to determine what is the best representation for our robotic platform - polar coordinates, Cartesian with respect to an arbitrary reference point? Or maybe there is a better choice?
Finally, the above model assumes the knowledge of a number of constants that are characteristic of the robot’s geometry, materials, and the DC motors. Without the knowledge of those constant the model could be completely off. Determination of these parameters in a measurement driven way, i.e., the “system identification” of the robot’s plant, is subject of the odometry class.
No questions found. You can ask a question on the website.