{ "cells": [ { "cell_type": "markdown", "id": "meaning-hypothetical", "metadata": {}, "source": [ "## Differential Flatness\n", "\n", "##### Richard M. Murray, 13 Nov 2021 (updated 27 Nov 2022)\n", "\n", "This notebook contains an example of using differential flatness as a mechanism for trajectory generation for a nonlinear control system. A differentially flat system is defined by creating an object using the `FlatSystem` class, which has member functions for mapping the system state and input into and out of flat coordinates. The `point_to_point()` function can be used to create a trajectory between two endpoints, written in terms of a set of basis functions defined using the `BasisFamil`y class. The resulting trajectory is return as a `SystemTrajectory` object and can be evaluated using the `eval()` member function. " ] }, { "cell_type": "code", "execution_count": null, "id": "historic-barbados", "metadata": {}, "outputs": [], "source": [ "# Import the packages needed for the examples included in this notebook\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import control as ct\n", "import control.flatsys as fs\n", "import control.optimal as opt\n", "import time" ] }, { "cell_type": "markdown", "id": "309d3272", "metadata": {}, "source": [ "## Example: bicycle model\n", "\n", "To illustrate the methods of generating trajectories using differential flatness, we make use of a simple model for a vehicle navigating in the plane, known as the \"bicycle model\". The kinematics of this vehicle can be written in terms of the contact point $(x, y)$ and the angle $\\theta$ of the vehicle with respect to the horizontal axis:\n", "\n", "
![]() | \n",
" \n", "$$\n", "\\begin{aligned}\n", " \\dot x &= \\cos\\theta\\, v \\\\\n", " \\dot y &= \\sin\\theta\\, v \\\\\n", " \\dot\\theta &= \\frac{v}{l} \\tan \\delta\n", "\\end{aligned}\n", "$$\n", " | \n", "