diff --git a/Localization/Kalmanfilter_basics_2.ipynb b/Localization/Kalmanfilter_basics_2.ipynb index 813d240e..ac3101d5 100644 --- a/Localization/Kalmanfilter_basics_2.ipynb +++ b/Localization/Kalmanfilter_basics_2.ipynb @@ -11,7 +11,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - " ### Probabilistic Generative Laws\n", + "### Probabilistic Generative Laws\n", " \n", "#### 1st Law:\n", "The belief representing the state $x_{t}$, is conditioned on all past states, measurements and controls. This can be shown mathematically by the conditional probability shown below:\n", diff --git a/PathTracking/model_predictive_speed_and_steer_control/Model_predictive_speed_and_steering_control.ipynb b/PathTracking/model_predictive_speed_and_steer_control/Model_predictive_speed_and_steering_control.ipynb index ad4c4b96..6024621c 100644 --- a/PathTracking/model_predictive_speed_and_steer_control/Model_predictive_speed_and_steering_control.ipynb +++ b/PathTracking/model_predictive_speed_and_steer_control/Model_predictive_speed_and_steering_control.ipynb @@ -128,7 +128,7 @@ "source": [ "where\n", "\n", - "$$\\begin{equation*}\n", + "\\begin{equation*}\n", "A' =\n", "\\begin{bmatrix}\n", "\\frac{\\partial }{\\partial x}vcos(\\phi) & \n", @@ -156,7 +156,7 @@ "0 & 0 & 0 & 0 \\\\\n", "0 & 0 &\\frac{tan(\\bar{\\delta})}{L} & 0 \\\\\n", "\\end{bmatrix}\n", - "\\end{equation*}$$\n", + "\\end{equation*}\n", "\n" ] }, @@ -164,7 +164,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "$$\\begin{equation*}\n", + "\\begin{equation*}\n", "B' =\n", "\\begin{bmatrix}\n", "\\frac{\\partial }{\\partial a}vcos(\\phi) &\n", @@ -184,7 +184,7 @@ "1 & 0 \\\\\n", "0 & \\frac{\\bar{v}}{Lcos^2(\\bar{\\delta})} \\\\\n", "\\end{bmatrix}\n", - "\\end{equation*}$$\n", + "\\end{equation*}\n", "\n" ] }, @@ -212,7 +212,7 @@ "\n", "where,\n", "\n", - "$$\\begin{equation*}\n", + "\\begin{equation*}\n", "A = (I + dtA')\\\\\n", "=\n", "\\begin{bmatrix} \n", @@ -221,14 +221,14 @@ "0 & 0 & 1 & 0 \\\\\n", "0 & 0 &\\frac{tan(\\bar{\\delta})}{L}dt & 1 \\\\\n", "\\end{bmatrix}\n", - "\\end{equation*}$$" + "\\end{equation*}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "$$\\begin{equation*}\n", + "\\begin{equation*}\n", "B = dtB'\\\\\n", "=\n", "\\begin{bmatrix} \n", @@ -237,14 +237,14 @@ "dt & 0 \\\\\n", "0 & \\frac{\\bar{v}}{Lcos^2(\\bar{\\delta})}dt \\\\\n", "\\end{bmatrix}\n", - "\\end{equation*}$$" + "\\end{equation*}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "$$\\begin{equation*}\n", + "\\begin{equation*}\n", "C = (f(\\bar{z},\\bar{u})-A'\\bar{z}-B'\\bar{u})dt\\\\\n", "= dt(\n", "\\begin{bmatrix} \n", @@ -275,7 +275,7 @@ "0\\\\\n", "-\\frac{\\bar{v}\\bar{\\delta}}{Lcos^2(\\bar{\\delta})}dt\\\\\n", "\\end{bmatrix}\n", - "\\end{equation*}$$" + "\\end{equation*}" ] }, { diff --git a/docs/modules/Kalmanfilter_basics_2.rst b/docs/modules/Kalmanfilter_basics_2.rst index e6cfafc6..9ae6fc5b 100644 --- a/docs/modules/Kalmanfilter_basics_2.rst +++ b/docs/modules/Kalmanfilter_basics_2.rst @@ -2,7 +2,8 @@ KF Basics - Part 2 ------------------ -### Probabilistic Generative Laws +Probabilistic Generative Laws +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1st Law: ^^^^^^^^ diff --git a/docs/modules/Model_predictive_speed_and_steering_control.rst b/docs/modules/Model_predictive_speed_and_steering_control.rst index 9cf57433..fc2725a1 100644 --- a/docs/modules/Model_predictive_speed_and_steering_control.rst +++ b/docs/modules/Model_predictive_speed_and_steering_control.rst @@ -94,61 +94,57 @@ ODE is where -.. math:: +:raw-latex:`\begin{equation*} +A' = +\begin{bmatrix} +\frac{\partial }{\partial x}vcos(\phi) & +\frac{\partial }{\partial y}vcos(\phi) & +\frac{\partial }{\partial v}vcos(\phi) & +\frac{\partial }{\partial \phi}vcos(\phi)\\ +\frac{\partial }{\partial x}vsin(\phi) & +\frac{\partial }{\partial y}vsin(\phi) & +\frac{\partial }{\partial v}vsin(\phi) & +\frac{\partial }{\partial \phi}vsin(\phi)\\ +\frac{\partial }{\partial x}a& +\frac{\partial }{\partial y}a& +\frac{\partial }{\partial v}a& +\frac{\partial }{\partial \phi}a\\ +\frac{\partial }{\partial x}\frac{vtan(\delta)}{L}& +\frac{\partial }{\partial y}\frac{vtan(\delta)}{L}& +\frac{\partial }{\partial v}\frac{vtan(\delta)}{L}& +\frac{\partial }{\partial \phi}\frac{vtan(\delta)}{L}\\ +\end{bmatrix} +\\ + = +\begin{bmatrix} +0 & 0 & cos(\bar{\phi}) & -\bar{v}sin(\bar{\phi})\\ +0 & 0 & sin(\bar{\phi}) & \bar{v}cos(\bar{\phi}) \\ +0 & 0 & 0 & 0 \\ +0 & 0 &\frac{tan(\bar{\delta})}{L} & 0 \\ +\end{bmatrix} +\end{equation*}` - \begin{equation*} - A' = - \begin{bmatrix} - \frac{\partial }{\partial x}vcos(\phi) & - \frac{\partial }{\partial y}vcos(\phi) & - \frac{\partial }{\partial v}vcos(\phi) & - \frac{\partial }{\partial \phi}vcos(\phi)\\ - \frac{\partial }{\partial x}vsin(\phi) & - \frac{\partial }{\partial y}vsin(\phi) & - \frac{\partial }{\partial v}vsin(\phi) & - \frac{\partial }{\partial \phi}vsin(\phi)\\ - \frac{\partial }{\partial x}a& - \frac{\partial }{\partial y}a& - \frac{\partial }{\partial v}a& - \frac{\partial }{\partial \phi}a\\ - \frac{\partial }{\partial x}\frac{vtan(\delta)}{L}& - \frac{\partial }{\partial y}\frac{vtan(\delta)}{L}& - \frac{\partial }{\partial v}\frac{vtan(\delta)}{L}& - \frac{\partial }{\partial \phi}\frac{vtan(\delta)}{L}\\ - \end{bmatrix} - \\ -  = - \begin{bmatrix} - 0 & 0 & cos(\bar{\phi}) & -\bar{v}sin(\bar{\phi})\\ - 0 & 0 & sin(\bar{\phi}) & \bar{v}cos(\bar{\phi}) \\ - 0 & 0 & 0 & 0 \\ - 0 & 0 &\frac{tan(\bar{\delta})}{L} & 0 \\ - \end{bmatrix} - \end{equation*} - -.. math:: - - \begin{equation*} - B' = - \begin{bmatrix} - \frac{\partial }{\partial a}vcos(\phi) & - \frac{\partial }{\partial \delta}vcos(\phi)\\ - \frac{\partial }{\partial a}vsin(\phi) & - \frac{\partial }{\partial \delta}vsin(\phi)\\ - \frac{\partial }{\partial a}a & - \frac{\partial }{\partial \delta}a\\ - \frac{\partial }{\partial a}\frac{vtan(\delta)}{L} & - \frac{\partial }{\partial \delta}\frac{vtan(\delta)}{L}\\ - \end{bmatrix} - \\ -  = - \begin{bmatrix} - 0 & 0 \\ - 0 & 0 \\ - 1 & 0 \\ - 0 & \frac{\bar{v}}{Lcos^2(\bar{\delta})} \\ - \end{bmatrix} - \end{equation*} +:raw-latex:`\begin{equation*} +B' = +\begin{bmatrix} +\frac{\partial }{\partial a}vcos(\phi) & +\frac{\partial }{\partial \delta}vcos(\phi)\\ +\frac{\partial }{\partial a}vsin(\phi) & +\frac{\partial }{\partial \delta}vsin(\phi)\\ +\frac{\partial }{\partial a}a & +\frac{\partial }{\partial \delta}a\\ +\frac{\partial }{\partial a}\frac{vtan(\delta)}{L} & +\frac{\partial }{\partial \delta}\frac{vtan(\delta)}{L}\\ +\end{bmatrix} +\\ + = +\begin{bmatrix} +0 & 0 \\ +0 & 0 \\ +1 & 0 \\ +0 & \frac{\bar{v}}{Lcos^2(\bar{\delta})} \\ +\end{bmatrix} +\end{equation*}` You can get a discrete-time mode with Forward Euler Discretization with sampling time dt. @@ -167,66 +163,60 @@ So, where, -.. math:: +:raw-latex:`\begin{equation*} +A = (I + dtA')\\ += +\begin{bmatrix} +1 & 0 & cos(\bar{\phi})dt & -\bar{v}sin(\bar{\phi})dt\\ +0 & 1 & sin(\bar{\phi})dt & \bar{v}cos(\bar{\phi})dt \\ +0 & 0 & 1 & 0 \\ +0 & 0 &\frac{tan(\bar{\delta})}{L}dt & 1 \\ +\end{bmatrix} +\end{equation*}` - \begin{equation*} - A = (I + dtA')\\ - = - \begin{bmatrix} - 1 & 0 & cos(\bar{\phi})dt & -\bar{v}sin(\bar{\phi})dt\\ - 0 & 1 & sin(\bar{\phi})dt & \bar{v}cos(\bar{\phi})dt \\ - 0 & 0 & 1 & 0 \\ - 0 & 0 &\frac{tan(\bar{\delta})}{L}dt & 1 \\ - \end{bmatrix} - \end{equation*} +:raw-latex:`\begin{equation*} +B = dtB'\\ += +\begin{bmatrix} +0 & 0 \\ +0 & 0 \\ +dt & 0 \\ +0 & \frac{\bar{v}}{Lcos^2(\bar{\delta})}dt \\ +\end{bmatrix} +\end{equation*}` -.. math:: - - \begin{equation*} - B = dtB'\\ - = - \begin{bmatrix} - 0 & 0 \\ - 0 & 0 \\ - dt & 0 \\ - 0 & \frac{\bar{v}}{Lcos^2(\bar{\delta})}dt \\ - \end{bmatrix} - \end{equation*} - -.. math:: - - \begin{equation*} - C = (f(\bar{z},\bar{u})-A'\bar{z}-B'\bar{u})dt\\ - = dt( - \begin{bmatrix} - \bar{v}cos(\bar{\phi})\\ - \bar{v}sin(\bar{\phi}) \\ - \bar{a}\\ - \frac{\bar{v}tan(\bar{\delta})}{L}\\ - \end{bmatrix} - - - \begin{bmatrix} - \bar{v}cos(\bar{\phi})-\bar{v}sin(\bar{\phi})\bar{\phi}\\ - \bar{v}sin(\bar{\phi})+\bar{v}cos(\bar{\phi})\bar{\phi}\\ - 0\\ - \frac{\bar{v}tan(\bar{\delta})}{L}\\ - \end{bmatrix} - - - \begin{bmatrix} - 0\\ - 0 \\ - \bar{a}\\ - \frac{\bar{v}\bar{\delta}}{Lcos^2(\bar{\delta})}\\ - \end{bmatrix} - )\\ - = - \begin{bmatrix} - \bar{v}sin(\bar{\phi})\bar{\phi}dt\\ - -\bar{v}cos(\bar{\phi})\bar{\phi}dt\\ - 0\\ - -\frac{\bar{v}\bar{\delta}}{Lcos^2(\bar{\delta})}dt\\ - \end{bmatrix} - \end{equation*} +:raw-latex:`\begin{equation*} +C = (f(\bar{z},\bar{u})-A'\bar{z}-B'\bar{u})dt\\ += dt( +\begin{bmatrix} +\bar{v}cos(\bar{\phi})\\ +\bar{v}sin(\bar{\phi}) \\ +\bar{a}\\ +\frac{\bar{v}tan(\bar{\delta})}{L}\\ +\end{bmatrix} +- +\begin{bmatrix} +\bar{v}cos(\bar{\phi})-\bar{v}sin(\bar{\phi})\bar{\phi}\\ +\bar{v}sin(\bar{\phi})+\bar{v}cos(\bar{\phi})\bar{\phi}\\ +0\\ +\frac{\bar{v}tan(\bar{\delta})}{L}\\ +\end{bmatrix} +- +\begin{bmatrix} +0\\ +0 \\ +\bar{a}\\ +\frac{\bar{v}\bar{\delta}}{Lcos^2(\bar{\delta})}\\ +\end{bmatrix} +)\\ += +\begin{bmatrix} +\bar{v}sin(\bar{\phi})\bar{\phi}dt\\ +-\bar{v}cos(\bar{\phi})\bar{\phi}dt\\ +0\\ +-\frac{\bar{v}\bar{\delta}}{Lcos^2(\bar{\delta})}dt\\ +\end{bmatrix} +\end{equation*}` This equation is implemented at