Fix clean up other docs (#580)

* update docs

* update docs

* update docs

* update docs
This commit is contained in:
Atsushi Sakai
2021-11-27 20:10:45 +09:00
committed by GitHub
parent eb1fec748f
commit 50ba79a3f5
20 changed files with 19 additions and 1526 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 KiB

View File

@@ -1,482 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Simulation"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<style>\n",
" div#notebook-container { width: 95%; }\n",
" div#menubar-container { width: 65%; }\n",
" div#maintoolbar-container { width: 99%; }\n",
"</style>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from IPython.display import Image\n",
"Image(filename=\"figure.png\",width=600)\n",
"from IPython.display import display, HTML\n",
"\n",
"display(HTML(data=\"\"\"\n",
"<style>\n",
" div#notebook-container { width: 95%; }\n",
" div#menubar-container { width: 65%; }\n",
" div#maintoolbar-container { width: 99%; }\n",
"</style>\n",
"\"\"\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![gif](https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/AerialNavigation/rocket_powered_landing/animation.gif)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Equation generation"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import sympy as sp\n",
"import numpy as np\n",
"from IPython.display import display\n",
"sp.init_printing(use_latex='mathjax')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# parameters\n",
"# Angular moment of inertia\n",
"J_B = 1e-2 * np.diag([1., 1., 1.])\n",
"\n",
"# Gravity\n",
"g_I = np.array((-1, 0., 0.))\n",
"\n",
"# Fuel consumption\n",
"alpha_m = 0.01\n",
"\n",
"# Vector from thrust point to CoM\n",
"r_T_B = np.array([-1e-2, 0., 0.])\n",
"\n",
"\n",
"def dir_cosine(q):\n",
" return np.matrix([\n",
" [1 - 2 * (q[2] ** 2 + q[3] ** 2), 2 * (q[1] * q[2] +\n",
" q[0] * q[3]), 2 * (q[1] * q[3] - q[0] * q[2])],\n",
" [2 * (q[1] * q[2] - q[0] * q[3]), 1 - 2 *\n",
" (q[1] ** 2 + q[3] ** 2), 2 * (q[2] * q[3] + q[0] * q[1])],\n",
" [2 * (q[1] * q[3] + q[0] * q[2]), 2 * (q[2] * q[3] -\n",
" q[0] * q[1]), 1 - 2 * (q[1] ** 2 + q[2] ** 2)]\n",
" ])\n",
"\n",
"def omega(w):\n",
" return np.matrix([\n",
" [0, -w[0], -w[1], -w[2]],\n",
" [w[0], 0, w[2], -w[1]],\n",
" [w[1], -w[2], 0, w[0]],\n",
" [w[2], w[1], -w[0], 0],\n",
" ])\n",
"\n",
"def skew(v):\n",
" return np.matrix([\n",
" [0, -v[2], v[1]],\n",
" [v[2], 0, -v[0]],\n",
" [-v[1], v[0], 0]\n",
" ])\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"f = sp.zeros(14, 1)\n",
"\n",
"x = sp.Matrix(sp.symbols(\n",
" 'm rx ry rz vx vy vz q0 q1 q2 q3 wx wy wz', real=True))\n",
"u = sp.Matrix(sp.symbols('ux uy uz', real=True))\n",
"\n",
"g_I = sp.Matrix(g_I)\n",
"r_T_B = sp.Matrix(r_T_B)\n",
"J_B = sp.Matrix(J_B)\n",
"\n",
"C_B_I = dir_cosine(x[7:11, 0])\n",
"C_I_B = C_B_I.transpose()\n",
"\n",
"f[0, 0] = - alpha_m * u.norm()\n",
"f[1:4, 0] = x[4:7, 0]\n",
"f[4:7, 0] = 1 / x[0, 0] * C_I_B * u + g_I\n",
"f[7:11, 0] = 1 / 2 * omega(x[11:14, 0]) * x[7: 11, 0]\n",
"f[11:14, 0] = J_B ** -1 * \\\n",
" (skew(r_T_B) * u - skew(x[11:14, 0]) * J_B * x[11:14, 0])\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}- 0.01 \\sqrt{ux^{2} + uy^{2} + uz^{2}}\\\\vx\\\\vy\\\\vz\\\\\\frac{- 1.0 m - ux \\left(2 q_{2}^{2} + 2 q_{3}^{2} - 1\\right) - 2 uy \\left(q_{0} q_{3} - q_{1} q_{2}\\right) + 2 uz \\left(q_{0} q_{2} + q_{1} q_{3}\\right)}{m}\\\\\\frac{2 ux \\left(q_{0} q_{3} + q_{1} q_{2}\\right) - uy \\left(2 q_{1}^{2} + 2 q_{3}^{2} - 1\\right) - 2 uz \\left(q_{0} q_{1} - q_{2} q_{3}\\right)}{m}\\\\\\frac{- 2 ux \\left(q_{0} q_{2} - q_{1} q_{3}\\right) + 2 uy \\left(q_{0} q_{1} + q_{2} q_{3}\\right) - uz \\left(2 q_{1}^{2} + 2 q_{2}^{2} - 1\\right)}{m}\\\\- 0.5 q_{1} wx - 0.5 q_{2} wy - 0.5 q_{3} wz\\\\0.5 q_{0} wx + 0.5 q_{2} wz - 0.5 q_{3} wy\\\\0.5 q_{0} wy - 0.5 q_{1} wz + 0.5 q_{3} wx\\\\0.5 q_{0} wz + 0.5 q_{1} wy - 0.5 q_{2} wx\\\\0\\\\1.0 uz\\\\- 1.0 uy\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡ _________________ \n",
"⎢ 2 2 2 \n",
"⎢ -0.01⋅╲╱ ux + uy + uz \n",
"⎢ \n",
"⎢ vx \n",
"⎢ \n",
"⎢ vy \n",
"⎢ \n",
"⎢ vz \n",
"⎢ \n",
"⎢ ⎛ 2 2 ⎞ \n",
"⎢-1.0⋅m - ux⋅⎝2⋅q₂ + 2⋅q₃ - 1⎠ - 2⋅uy⋅(q₀⋅q₃ - q₁⋅q₂) + 2⋅uz⋅(q₀⋅q₂ + q₁⋅q₃)\n",
"⎢─────────────────────────────────────────────────────────────────────────────\n",
"⎢ m \n",
"⎢ \n",
"⎢ ⎛ 2 2 ⎞ \n",
"⎢ 2⋅ux⋅(q₀⋅q₃ + q₁⋅q₂) - uy⋅⎝2⋅q₁ + 2⋅q₃ - 1⎠ - 2⋅uz⋅(q₀⋅q₁ - q₂⋅q₃) \n",
"⎢ ──────────────────────────────────────────────────────────────────── \n",
"⎢ m \n",
"⎢ \n",
"⎢ ⎛ 2 2 ⎞ \n",
"⎢ -2⋅ux⋅(q₀⋅q₂ - q₁⋅q₃) + 2⋅uy⋅(q₀⋅q₁ + q₂⋅q₃) - uz⋅⎝2⋅q₁ + 2⋅q₂ - 1⎠ \n",
"⎢ ───────────────────────────────────────────────────────────────────── \n",
"⎢ m \n",
"⎢ \n",
"⎢ -0.5⋅q₁⋅wx - 0.5⋅q₂⋅wy - 0.5⋅q₃⋅wz \n",
"⎢ \n",
"⎢ 0.5⋅q₀⋅wx + 0.5⋅q₂⋅wz - 0.5⋅q₃⋅wy \n",
"⎢ \n",
"⎢ 0.5⋅q₀⋅wy - 0.5⋅q₁⋅wz + 0.5⋅q₃⋅wx \n",
"⎢ \n",
"⎢ 0.5⋅q₀⋅wz + 0.5⋅q₁⋅wy - 0.5⋅q₂⋅wx \n",
"⎢ \n",
"⎢ 0 \n",
"⎢ \n",
"⎢ 1.0⋅uz \n",
"⎢ \n",
"⎣ -1.0⋅uy \n",
"\n",
"⎤\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎥\n",
"⎦"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display(sp.simplify(f)) # f"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{array}{cccccccccccccc}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\\\frac{ux \\left(2 q_{2}^{2} + 2 q_{3}^{2} - 1\\right) + 2 uy \\left(q_{0} q_{3} - q_{1} q_{2}\\right) - 2 uz \\left(q_{0} q_{2} + q_{1} q_{3}\\right)}{m^{2}} & 0 & 0 & 0 & 0 & 0 & 0 & \\frac{2 \\left(q_{2} uz - q_{3} uy\\right)}{m} & \\frac{2 \\left(q_{2} uy + q_{3} uz\\right)}{m} & \\frac{2 \\left(q_{0} uz + q_{1} uy - 2 q_{2} ux\\right)}{m} & \\frac{2 \\left(- q_{0} uy + q_{1} uz - 2 q_{3} ux\\right)}{m} & 0 & 0 & 0\\\\\\frac{- 2 ux \\left(q_{0} q_{3} + q_{1} q_{2}\\right) + uy \\left(2 q_{1}^{2} + 2 q_{3}^{2} - 1\\right) + 2 uz \\left(q_{0} q_{1} - q_{2} q_{3}\\right)}{m^{2}} & 0 & 0 & 0 & 0 & 0 & 0 & \\frac{2 \\left(- q_{1} uz + q_{3} ux\\right)}{m} & \\frac{2 \\left(- q_{0} uz - 2 q_{1} uy + q_{2} ux\\right)}{m} & \\frac{2 \\left(q_{1} ux + q_{3} uz\\right)}{m} & \\frac{2 \\left(q_{0} ux + q_{2} uz - 2 q_{3} uy\\right)}{m} & 0 & 0 & 0\\\\\\frac{2 ux \\left(q_{0} q_{2} - q_{1} q_{3}\\right) - 2 uy \\left(q_{0} q_{1} + q_{2} q_{3}\\right) + uz \\left(2 q_{1}^{2} + 2 q_{2}^{2} - 1\\right)}{m^{2}} & 0 & 0 & 0 & 0 & 0 & 0 & \\frac{2 \\left(q_{1} uy - q_{2} ux\\right)}{m} & \\frac{2 \\left(q_{0} uy - 2 q_{1} uz + q_{3} ux\\right)}{m} & \\frac{2 \\left(- q_{0} ux - 2 q_{2} uz + q_{3} uy\\right)}{m} & \\frac{2 \\left(q_{1} ux + q_{2} uy\\right)}{m} & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & - 0.5 wx & - 0.5 wy & - 0.5 wz & - 0.5 q_{1} & - 0.5 q_{2} & - 0.5 q_{3}\\\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0.5 wx & 0 & 0.5 wz & - 0.5 wy & 0.5 q_{0} & - 0.5 q_{3} & 0.5 q_{2}\\\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0.5 wy & - 0.5 wz & 0 & 0.5 wx & 0.5 q_{3} & 0.5 q_{0} & - 0.5 q_{1}\\\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0.5 wz & 0.5 wy & - 0.5 wx & 0 & - 0.5 q_{2} & 0.5 q_{1} & 0.5 q_{0}\\\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\end{array}\\right]$$"
],
"text/plain": [
"⎡ 0 0 0 \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎢ ⎛ 2 2 ⎞ \n",
"⎢ux⋅⎝2⋅q₂ + 2⋅q₃ - 1⎠ + 2⋅uy⋅(q₀⋅q₃ - q₁⋅q₂) - 2⋅uz⋅(q₀⋅q₂ + q₁⋅q₃) \n",
"⎢──────────────────────────────────────────────────────────────────── 0 0 \n",
"⎢ 2 \n",
"⎢ m \n",
"⎢ \n",
"⎢ ⎛ 2 2 ⎞ \n",
"⎢-2⋅ux⋅(q₀⋅q₃ + q₁⋅q₂) + uy⋅⎝2⋅q₁ + 2⋅q₃ - 1⎠ + 2⋅uz⋅(q₀⋅q₁ - q₂⋅q₃) \n",
"⎢───────────────────────────────────────────────────────────────────── 0 0 \n",
"⎢ 2 \n",
"⎢ m \n",
"⎢ \n",
"⎢ ⎛ 2 2 ⎞ \n",
"⎢2⋅ux⋅(q₀⋅q₂ - q₁⋅q₃) - 2⋅uy⋅(q₀⋅q₁ + q₂⋅q₃) + uz⋅⎝2⋅q₁ + 2⋅q₂ - 1⎠ \n",
"⎢──────────────────────────────────────────────────────────────────── 0 0 \n",
"⎢ 2 \n",
"⎢ m \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎢ 0 0 0 \n",
"⎢ \n",
"⎣ 0 0 0 \n",
"\n",
"0 0 0 0 0 0 0 \n",
" \n",
"0 1 0 0 0 0 0 \n",
" \n",
"0 0 1 0 0 0 0 \n",
" \n",
"0 0 0 1 0 0 0 \n",
" \n",
" \n",
" 2⋅(q₂⋅uz - q₃⋅uy) 2⋅(q₂⋅uy + q₃⋅uz) 2⋅(q₀⋅uz + q₁⋅uy\n",
"0 0 0 0 ───────────────── ───────────────── ────────────────\n",
" m m m \n",
" \n",
" \n",
" \n",
" 2⋅(-q₁⋅uz + q₃⋅ux) 2⋅(-q₀⋅uz - 2⋅q₁⋅uy + q₂⋅ux) 2⋅(q₁⋅ux + \n",
"0 0 0 0 ────────────────── ──────────────────────────── ───────────\n",
" m m m \n",
" \n",
" \n",
" \n",
" 2⋅(q₁⋅uy - q₂⋅ux) 2⋅(q₀⋅uy - 2⋅q₁⋅uz + q₃⋅ux) 2⋅(-q₀⋅ux - 2⋅q₂\n",
"0 0 0 0 ───────────────── ─────────────────────────── ────────────────\n",
" m m m \n",
" \n",
" \n",
"0 0 0 0 0 -0.5⋅wx -0.5⋅w\n",
" \n",
"0 0 0 0 0.5⋅wx 0 0.5⋅w\n",
" \n",
"0 0 0 0 0.5⋅wy -0.5⋅wz 0 \n",
" \n",
"0 0 0 0 0.5⋅wz 0.5⋅wy -0.5⋅w\n",
" \n",
"0 0 0 0 0 0 0 \n",
" \n",
"0 0 0 0 0 0 0 \n",
" \n",
"0 0 0 0 0 0 0 \n",
"\n",
" 0 0 0 0 ⎤\n",
" ⎥\n",
" 0 0 0 0 ⎥\n",
" ⎥\n",
" 0 0 0 0 ⎥\n",
" ⎥\n",
" 0 0 0 0 ⎥\n",
" ⎥\n",
" ⎥\n",
" - 2⋅q₂⋅ux) 2⋅(-q₀⋅uy + q₁⋅uz - 2⋅q₃⋅ux) ⎥\n",
"─────────── ──────────────────────────── 0 0 0 ⎥\n",
" m ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
"q₃⋅uz) 2⋅(q₀⋅ux + q₂⋅uz - 2⋅q₃⋅uy) ⎥\n",
"────── ─────────────────────────── 0 0 0 ⎥\n",
" m ⎥\n",
" ⎥\n",
" ⎥\n",
" ⎥\n",
"⋅uz + q₃⋅uy) 2⋅(q₁⋅ux + q₂⋅uy) ⎥\n",
"──────────── ───────────────── 0 0 0 ⎥\n",
" m ⎥\n",
" ⎥\n",
" ⎥\n",
"y -0.5⋅wz -0.5⋅q₁ -0.5⋅q₂ -0.5⋅q₃⎥\n",
" ⎥\n",
"z -0.5⋅wy 0.5⋅q₀ -0.5⋅q₃ 0.5⋅q₂ ⎥\n",
" ⎥\n",
" 0.5⋅wx 0.5⋅q₃ 0.5⋅q₀ -0.5⋅q₁⎥\n",
" ⎥\n",
"x 0 -0.5⋅q₂ 0.5⋅q₁ 0.5⋅q₀ ⎥\n",
" ⎥\n",
" 0 0 0 0 ⎥\n",
" ⎥\n",
" 0 0 0 0 ⎥\n",
" ⎥\n",
" 0 0 0 0 ⎦"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display(sp.simplify(f.jacobian(x)))# A "
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$$\\left[\\begin{matrix}- \\frac{0.01 ux}{\\sqrt{ux^{2} + uy^{2} + uz^{2}}} & - \\frac{0.01 uy}{\\sqrt{ux^{2} + uy^{2} + uz^{2}}} & - \\frac{0.01 uz}{\\sqrt{ux^{2} + uy^{2} + uz^{2}}}\\\\0 & 0 & 0\\\\0 & 0 & 0\\\\0 & 0 & 0\\\\\\frac{- 2 q_{2}^{2} - 2 q_{3}^{2} + 1}{m} & \\frac{2 \\left(- q_{0} q_{3} + q_{1} q_{2}\\right)}{m} & \\frac{2 \\left(q_{0} q_{2} + q_{1} q_{3}\\right)}{m}\\\\\\frac{2 \\left(q_{0} q_{3} + q_{1} q_{2}\\right)}{m} & \\frac{- 2 q_{1}^{2} - 2 q_{3}^{2} + 1}{m} & \\frac{2 \\left(- q_{0} q_{1} + q_{2} q_{3}\\right)}{m}\\\\\\frac{2 \\left(- q_{0} q_{2} + q_{1} q_{3}\\right)}{m} & \\frac{2 \\left(q_{0} q_{1} + q_{2} q_{3}\\right)}{m} & \\frac{- 2 q_{1}^{2} - 2 q_{2}^{2} + 1}{m}\\\\0 & 0 & 0\\\\0 & 0 & 0\\\\0 & 0 & 0\\\\0 & 0 & 0\\\\0 & 0 & 0\\\\0 & 0 & 1.0\\\\0 & -1.0 & 0\\end{matrix}\\right]$$"
],
"text/plain": [
"⎡ -0.01⋅ux -0.01⋅uy -0.01⋅uz ⎤\n",
"⎢──────────────────── ──────────────────── ────────────────────⎥\n",
"⎢ _________________ _________________ _________________⎥\n",
"⎢ 2 2 2 2 2 2 2 2 2 ⎥\n",
"⎢╲╱ ux + uy + uz ╲╱ ux + uy + uz ╲╱ ux + uy + uz ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 0 ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 0 ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 0 ⎥\n",
"⎢ ⎥\n",
"⎢ 2 2 ⎥\n",
"⎢- 2⋅q₂ - 2⋅q₃ + 1 2⋅(-q₀⋅q₃ + q₁⋅q₂) 2⋅(q₀⋅q₂ + q₁⋅q₃) ⎥\n",
"⎢─────────────────── ────────────────── ───────────────── ⎥\n",
"⎢ m m m ⎥\n",
"⎢ ⎥\n",
"⎢ 2 2 ⎥\n",
"⎢ 2⋅(q₀⋅q₃ + q₁⋅q₂) - 2⋅q₁ - 2⋅q₃ + 1 2⋅(-q₀⋅q₁ + q₂⋅q₃) ⎥\n",
"⎢ ───────────────── ─────────────────── ────────────────── ⎥\n",
"⎢ m m m ⎥\n",
"⎢ ⎥\n",
"⎢ 2 2 ⎥\n",
"⎢ 2⋅(-q₀⋅q₂ + q₁⋅q₃) 2⋅(q₀⋅q₁ + q₂⋅q₃) - 2⋅q₁ - 2⋅q₂ + 1 ⎥\n",
"⎢ ────────────────── ───────────────── ─────────────────── ⎥\n",
"⎢ m m m ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 0 ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 0 ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 0 ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 0 ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 0 ⎥\n",
"⎢ ⎥\n",
"⎢ 0 0 1.0 ⎥\n",
"⎢ ⎥\n",
"⎣ 0 -1.0 0 ⎦"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sp.simplify(f.jacobian(u)) # B"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Ref\n",
"\n",
"- Python implementation of 'Successive Convexification for 6-DoF Mars Rocket Powered Landing with Free-Final-Time' paper\n",
"by Michael Szmuk and Behçet Açıkmeşe.\n",
"\n",
"- inspired by EmbersArc/SuccessiveConvexificationFreeFinalTime: Implementation of \"Successive Convexification for 6-DoF Mars Rocket Powered Landing with Free-Final-Time\" https://github.com/EmbersArc/SuccessiveConvexificationFreeFinalTime\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

File diff suppressed because one or more lines are too long

View File

@@ -1,333 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"## Model predictive speed and steering control\n",
"\n",
"![Model predictive speed and steering control](https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/model_predictive_speed_and_steer_control/animation.gif?raw=true)\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"\n",
"\n",
"code:\n",
"\n",
"[PythonRobotics/model\\_predictive\\_speed\\_and\\_steer\\_control\\.py at master · AtsushiSakai/PythonRobotics](https://github.com/AtsushiSakai/PythonRobotics/blob/master/PathTracking/model_predictive_speed_and_steer_control/model_predictive_speed_and_steer_control.py)\n",
"\n",
"This is a path tracking simulation using model predictive control (MPC).\n",
"\n",
"The MPC controller controls vehicle speed and steering base on linealized model.\n",
"\n",
"This code uses cvxpy as an optimization modeling tool.\n",
"\n",
"- [Welcome to CVXPY 1\\.0 — CVXPY 1\\.0\\.6 documentation](http://www.cvxpy.org/)"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"### MPC modeling\n",
"\n",
"State vector is:\n",
"\n",
"$$ z = [x, y, v,\\phi]$$\n",
"\n",
"x: x-position, y:y-position, v:velocity, φ: yaw angle\n",
"\n",
"Input vector is:\n",
"\n",
"$$ u = [a, \\delta]$$\n",
"\n",
"a: accellation, δ: steering angle\n",
"\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"The MPC cotroller minimize this cost function for path tracking:\n",
"\n",
"$$min\\ Q_f(z_{T,ref}-z_{T})^2+Q\\Sigma({z_{t,ref}-z_{t}})^2+R\\Sigma{u_t}^2+R_d\\Sigma({u_{t+1}-u_{t}})^2$$\n",
"\n",
"z_ref come from target path and speed."
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"subject to:\n",
"\n",
"- Linearlied vehicle model\n",
"\n",
"$$z_{t+1}=Az_t+Bu+C$$\n",
"\n",
"- Maximum steering speed\n",
"\n",
"$$|u_{t+1}-u_{t}|<du_{max}$$\n",
"\n",
"- Maximum steering angle\n",
"\n",
"$$|u_{t}|<u_{max}$$\n",
"\n",
"- Initial state\n",
"\n",
"$$z_0 = z_{0,ob}$$\n",
"\n",
"- Maximum and minimum speed\n",
"\n",
"$$v_{min} < v_t < v_{max}$$\n",
"\n",
"- Maximum and minimum input\n",
"\n",
"$$u_{min} < u_t < u_{max}$$\n",
"\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"This is implemented at \n",
"\n",
"[PythonRobotics/model\\_predictive\\_speed\\_and\\_steer\\_control\\.py at f51a73f47cb922a12659f8ce2d544c347a2a8156 · AtsushiSakai/PythonRobotics](https://github.com/AtsushiSakai/PythonRobotics/blob/f51a73f47cb922a12659f8ce2d544c347a2a8156/PathTracking/model_predictive_speed_and_steer_control/model_predictive_speed_and_steer_control.py#L247-L301)"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"### Vehicle model linearization\n",
"\n",
"\n",
"\n",
"Vehicle model is \n",
"\n",
"$$ \\dot{x} = vcos(\\phi)$$\n",
"\n",
"$$ \\dot{y} = vsin((\\phi)$$\n",
"\n",
"$$ \\dot{v} = a$$\n",
"\n",
"$$ \\dot{\\phi} = \\frac{vtan(\\delta)}{L}$$\n",
"\n",
"\n",
"\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"ODE is\n",
"\n",
"$$ \\dot{z} =\\frac{\\partial }{\\partial z} z = f(z, u) = A'z+B'u$$\n",
"\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"where\n",
"\n",
"$\\begin{equation*}\n",
"A' =\n",
"\\begin{bmatrix}\n",
"\\frac{\\partial }{\\partial x}vcos(\\phi) & \n",
"\\frac{\\partial }{\\partial y}vcos(\\phi) & \n",
"\\frac{\\partial }{\\partial v}vcos(\\phi) &\n",
"\\frac{\\partial }{\\partial \\phi}vcos(\\phi)\\\\\n",
"\\frac{\\partial }{\\partial x}vsin(\\phi) & \n",
"\\frac{\\partial }{\\partial y}vsin(\\phi) & \n",
"\\frac{\\partial }{\\partial v}vsin(\\phi) &\n",
"\\frac{\\partial }{\\partial \\phi}vsin(\\phi)\\\\\n",
"\\frac{\\partial }{\\partial x}a& \n",
"\\frac{\\partial }{\\partial y}a& \n",
"\\frac{\\partial }{\\partial v}a&\n",
"\\frac{\\partial }{\\partial \\phi}a\\\\\n",
"\\frac{\\partial }{\\partial x}\\frac{vtan(\\delta)}{L}& \n",
"\\frac{\\partial }{\\partial y}\\frac{vtan(\\delta)}{L}& \n",
"\\frac{\\partial }{\\partial v}\\frac{vtan(\\delta)}{L}&\n",
"\\frac{\\partial }{\\partial \\phi}\\frac{vtan(\\delta)}{L}\\\\\n",
"\\end{bmatrix}\n",
"\\\\\n",
" =\n",
"\\begin{bmatrix}\n",
"0 & 0 & cos(\\bar{\\phi}) & -\\bar{v}sin(\\bar{\\phi})\\\\\n",
"0 & 0 & sin(\\bar{\\phi}) & \\bar{v}cos(\\bar{\\phi}) \\\\\n",
"0 & 0 & 0 & 0 \\\\\n",
"0 & 0 &\\frac{tan(\\bar{\\delta})}{L} & 0 \\\\\n",
"\\end{bmatrix}\n",
"\\end{equation*}$\n",
"\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"$\\begin{equation*}\n",
"B' =\n",
"\\begin{bmatrix}\n",
"\\frac{\\partial }{\\partial a}vcos(\\phi) &\n",
"\\frac{\\partial }{\\partial \\delta}vcos(\\phi)\\\\\n",
"\\frac{\\partial }{\\partial a}vsin(\\phi) &\n",
"\\frac{\\partial }{\\partial \\delta}vsin(\\phi)\\\\\n",
"\\frac{\\partial }{\\partial a}a &\n",
"\\frac{\\partial }{\\partial \\delta}a\\\\\n",
"\\frac{\\partial }{\\partial a}\\frac{vtan(\\delta)}{L} &\n",
"\\frac{\\partial }{\\partial \\delta}\\frac{vtan(\\delta)}{L}\\\\\n",
"\\end{bmatrix}\n",
"\\\\\n",
" =\n",
"\\begin{bmatrix}\n",
"0 & 0 \\\\\n",
"0 & 0 \\\\\n",
"1 & 0 \\\\\n",
"0 & \\frac{\\bar{v}}{Lcos^2(\\bar{\\delta})} \\\\\n",
"\\end{bmatrix}\n",
"\\end{equation*}$\n",
"\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"You can get a discrete-time mode with Forward Euler Discretization with sampling time dt.\n",
"\n",
"$$z_{k+1}=z_k+f(z_k,u_k)dt$$\n",
"\n",
"Using first degree Tayer expantion around zbar and ubar\n",
"$$z_{k+1}=z_k+(f(\\bar{z},\\bar{u})+A'z_k+B'u_k-A'\\bar{z}-B'\\bar{u})dt$$\n",
"\n",
"$$z_{k+1}=(I + dtA')z_k+(dtB')u_k + (f(\\bar{z},\\bar{u})-A'\\bar{z}-B'\\bar{u})dt$$\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"So, \n",
"\n",
"$$z_{k+1}=Az_k+Bu_k +C$$\n",
"\n",
"where,\n",
"\n",
"$$\\begin{equation*}\n",
"A = (I + dtA')\\\\\n",
"=\n",
"\\begin{bmatrix} \n",
"1 & 0 & cos(\\bar{\\phi})dt & -\\bar{v}sin(\\bar{\\phi})dt\\\\\n",
"0 & 1 & sin(\\bar{\\phi})dt & \\bar{v}cos(\\bar{\\phi})dt \\\\\n",
"0 & 0 & 1 & 0 \\\\\n",
"0 & 0 &\\frac{tan(\\bar{\\delta})}{L}dt & 1 \\\\\n",
"\\end{bmatrix}\n",
"\\end{equation*}$$"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"$$\\begin{equation*}\n",
"B = dtB'\\\\\n",
"=\n",
"\\begin{bmatrix} \n",
"0 & 0 \\\\\n",
"0 & 0 \\\\\n",
"dt & 0 \\\\\n",
"0 & \\frac{\\bar{v}}{Lcos^2(\\bar{\\delta})}dt \\\\\n",
"\\end{bmatrix}\n",
"\\end{equation*}$$"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"$$\\begin{equation*}\n",
"C = (f(\\bar{z},\\bar{u})-A'\\bar{z}-B'\\bar{u})dt\\\\\n",
"= dt(\n",
"\\begin{bmatrix} \n",
"\\bar{v}cos(\\bar{\\phi})\\\\\n",
"\\bar{v}sin(\\bar{\\phi}) \\\\\n",
"\\bar{a}\\\\\n",
"\\frac{\\bar{v}tan(\\bar{\\delta})}{L}\\\\\n",
"\\end{bmatrix}\n",
"-\n",
"\\begin{bmatrix} \n",
"\\bar{v}cos(\\bar{\\phi})-\\bar{v}sin(\\bar{\\phi})\\bar{\\phi}\\\\\n",
"\\bar{v}sin(\\bar{\\phi})+\\bar{v}cos(\\bar{\\phi})\\bar{\\phi}\\\\\n",
"0\\\\\n",
"\\frac{\\bar{v}tan(\\bar{\\delta})}{L}\\\\\n",
"\\end{bmatrix}\n",
"-\n",
"\\begin{bmatrix} \n",
"0\\\\\n",
"0 \\\\\n",
"\\bar{a}\\\\\n",
"\\frac{\\bar{v}\\bar{\\delta}}{Lcos^2(\\bar{\\delta})}\\\\\n",
"\\end{bmatrix}\n",
")\\\\\n",
"=\n",
"\\begin{bmatrix} \n",
"\\bar{v}sin(\\bar{\\phi})\\bar{\\phi}dt\\\\\n",
"-\\bar{v}cos(\\bar{\\phi})\\bar{\\phi}dt\\\\\n",
"0\\\\\n",
"-\\frac{\\bar{v}\\bar{\\delta}}{Lcos^2(\\bar{\\delta})}dt\\\\\n",
"\\end{bmatrix}\n",
"\\end{equation*}$$"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"This equation is implemented at \n",
"\n",
"[PythonRobotics/model\\_predictive\\_speed\\_and\\_steer\\_control\\.py at eb6d1cbe6fc90c7be9210bf153b3a04f177cc138 · AtsushiSakai/PythonRobotics](https://github.com/AtsushiSakai/PythonRobotics/blob/eb6d1cbe6fc90c7be9210bf153b3a04f177cc138/PathTracking/model_predictive_speed_and_steer_control/model_predictive_speed_and_steer_control.py#L80-L102)\n"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"### Reference\n",
"\n",
"- [Vehicle Dynamics and Control \\| Rajesh Rajamani \\| Springer](http://www.springer.com/us/book/9781461414322)\n",
"\n",
"- [MPC Course Material \\- MPC Lab @ UC\\-Berkeley](http://www.mpc.berkeley.edu/mpc-course-material)\n"
],
"metadata": {}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -8,11 +8,7 @@ Drone 3d trajectory following
This is a 3d trajectory following simulation for a quadrotor.
|3|
rocket powered landing
-----------------------------
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/AerialNavigation/drone_3d_trajectory_following/animation.gif
.. include:: rocket_powered_landing.rst
.. |3| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/AerialNavigation/drone_3d_trajectory_following/animation.gif

View File

@@ -1,3 +1,5 @@
Rocket powered landing
-----------------------------
Simulation
~~~~~~~~~~
@@ -32,8 +34,6 @@ Simulation
.. figure:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/AerialNavigation/rocket_powered_landing/animation.gif
:alt: gif
gif
Equation generation
~~~~~~~~~~~~~~~~~~~
@@ -145,8 +145,8 @@ Equation generation
Ref
~~~
References
~~~~~~~~~~
- Python implementation of Successive Convexification for 6-DoF Mars
Rocket Powered Landing with Free-Final-Time paper by Michael Szmuk

View File

@@ -3,7 +3,7 @@
Arm Navigation
==============
.. include:: Planar_Two_Link_IK.rst
.. include:: planar_two_link_ik.rst
N joint arm to point control
@@ -14,9 +14,9 @@ N joint arm to a point control simulation.
This is a interactive simulation.
You can set the goal position of the end effector with left-click on the
ploting area.
plotting area.
|n_joints_arm|
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/ArmNavigation/n_joint_arm_to_point_control/animation.gif
In this simulation N = 10, however, you can change it.
@@ -25,7 +25,4 @@ Arm navigation with obstacle avoidance
Arm navigation with obstacle avoidance simulation.
|obstacle|
.. |n_joints_arm| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/ArmNavigation/n_joint_arm_to_point_control/animation.gif
.. |obstacle| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/ArmNavigation/arm_obstacle_navigation/animation.gif
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/ArmNavigation/arm_obstacle_navigation/animation.gif

View File

@@ -5,14 +5,11 @@ Two joint arm to point control
.. figure:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/ArmNavigation/two_joint_arm_to_point_control/animation.gif
:alt: TwoJointArmToPointControl
TwoJointArmToPointControl
This is two joint arm to a point control simulation.
This is a interactive simulation.
You can set the goal position of the end effector with left-click on the
ploting area.
You can set the goal position of the end effector with left-click on the plotting area.
Inverse Kinematics for a Planar Two-Link Robotic Arm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -337,13 +337,13 @@ A sample code of Bezier path planning.
It is based on 4 control points Beier path.
|Bezier1|
.. image:: https://github.com/AtsushiSakai/PythonRobotics/raw/master/docs/modules/path_planning/Bezier_path_planning/Figure_1.png?raw=True
If you change the offset distance from start and end point,
You can get different Beizer course:
|Bezier2|
.. image:: https://github.com/AtsushiSakai/PythonRobotics/raw/master/docs/modules/path_planning/Bezier_path_planning/Figure_2.png?raw=True
Ref:
@@ -439,7 +439,6 @@ Ref:
.. |B-Spline| image:: https://github.com/AtsushiSakai/PythonRobotics/raw/master/PathPlanning/BSplinePath/Figure_1.png?raw=True
.. |eta3| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/Eta3SplinePath/animation.gif
.. |Bezier1| image:: https://github.com/AtsushiSakai/PythonRobotics/raw/master/PathPlanning/BezierPath/Figure_1.png?raw=True
.. |Bezier2| image:: https://github.com/AtsushiSakai/PythonRobotics/raw/master/PathPlanning/BezierPath/Figure_2.png?raw=True
.. |2| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/QuinticPolynomialsPlanner/animation.gif
.. |dubins| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/DubinsPath/animation.gif?raw=True
.. |RSPlanning| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/ReedsSheppPath/animation.gif?raw=true

View File

@@ -15,7 +15,7 @@ AtsushiSakai/PythonRobotics <https://github.com/AtsushiSakai/PythonRobotics/blob
This is a path tracking simulation using model predictive control (MPC).
The MPC controller controls vehicle speed and steering base on
linealized model.
linearized model.
This code uses cvxpy as an optimization modeling tool.

View File

@@ -2,60 +2,21 @@
Nonlinear Model Predictive Control with C-GMRES
-----------------------------------------------
.. code-block:: ipython3
from IPython.display import Image
Image(filename="Figure_4.png",width=600)
.. image:: cgmres_nmpc_files/cgmres_nmpc_1_0.png
:width: 600px
.. code-block:: ipython3
Image(filename="Figure_1.png",width=600)
.. image:: cgmres_nmpc_files/cgmres_nmpc_2_0.png
:width: 600px
.. code-block:: ipython3
Image(filename="Figure_2.png",width=600)
.. image:: cgmres_nmpc_files/cgmres_nmpc_3_0.png
:width: 600px
.. code-block:: ipython3
Image(filename="Figure_3.png",width=600)
.. image:: cgmres_nmpc_files/cgmres_nmpc_4_0.png
:width: 600px
.. figure:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/cgmres_nmpc/animation.gif
:alt: gif
gif
Mathematical Formulation
~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -8,7 +8,7 @@ move to a pose control
This is a simulation of moving to a pose control
|2|
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/move_to_pose/animation.gif
Ref:
@@ -21,7 +21,7 @@ Pure pursuit tracking
Path tracking simulation with pure pursuit steering control and PID
speed control.
|3|
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/pure_pursuit/animation.gif
The red line is a target course, the green cross means the target point
for pure pursuit control, the blue line is the tracking.
@@ -37,7 +37,7 @@ Stanley control
Path tracking simulation with Stanley steering control and PID speed
control.
|4|
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/stanley_controller/animation.gif
Ref:
@@ -53,7 +53,7 @@ Rear wheel feedback control
Path tracking simulation with rear wheel feedback steering control and
PID speed control.
|5|
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/rear_wheel_feedback/animation.gif
Ref:
@@ -68,7 +68,7 @@ Linearquadratic regulator (LQR) steering control
Path tracking simulation with LQR steering control and PID speed
control.
|6|
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/lqr_steer_control/animation.gif
Ref:
@@ -82,7 +82,7 @@ Linearquadratic regulator (LQR) speed and steering control
Path tracking simulation with LQR speed and steering control.
|7|
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/lqr_speed_steer_control/animation.gif
Ref:
@@ -92,16 +92,5 @@ Ref:
.. include:: Model_predictive_speed_and_steering_control.rst
Ref:
- `notebook <https://github.com/AtsushiSakai/PythonRobotics/blob/master/PathTracking/model_predictive_speed_and_steer_control/model_predictive_speed_and_steer_control.ipynb>`__
.. include:: cgmres_nmpc.rst
.. |2| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/move_to_pose/animation.gif
.. |3| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/pure_pursuit/animation.gif
.. |4| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/stanley_controller/animation.gif
.. |5| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/rear_wheel_feedback/animation.gif
.. |6| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/lqr_steer_control/animation.gif
.. |7| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathTracking/lqr_speed_steer_control/animation.gif