{ "cells": [ { "cell_type": "markdown", "id": "eec23018", "metadata": {}, "source": [ "# Kinematic car sensor fusion example\n", "RMM, 24 Feb 2022 (updated 23 Feb 2023)\n", "\n", "In this example we work through estimation of the state of a car changing\n", "lanes with two different sensors available: one with good longitudinal accuracy\n", "and the other with good lateral accuracy.\n", "\n", "All calculations are done in discrete time, using both the form of the Kalman\n", "filter in Theorem 7.2 and the predictor corrector form." ] }, { "cell_type": "code", "execution_count": null, "id": "107a6613", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import scipy as sp\n", "import matplotlib.pyplot as plt\n", "import control as ct\n", "import control.optimal as opt\n", "import control.flatsys as fs\n", "\n", "# Define some line styles for later use\n", "ebarstyle = {'elinewidth': 0.5, 'capsize': 2}\n", "xdstyle = {'color': 'k', 'linestyle': '--', 'linewidth': 0.5, \n", " 'marker': '+', 'markersize': 4}" ] }, { "cell_type": "markdown", "id": "ea8807a4", "metadata": {}, "source": [ "## System definition\n", "\n", "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", "