{ "cells": [ { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}0 & 0 & - v \\sin{\\left(\\theta \\right)} & 0 & 0\\\\0 & 0 & v \\cos{\\left(\\theta \\right)} & 0 & 0\\\\0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & - v \\cos{\\left(\\psi \\right)} & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[0, 0, -v*sin(theta), 0, 0],\n", "[0, 0, v*cos(theta), 0, 0],\n", "[0, 0, 0, 0, 0],\n", "[0, 0, 0, 0, 0],\n", "[0, 0, 0, -v*cos(psi), 0]])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import sympy as sp\n", "\n", "x,y,theta,psi,cte,v,w = sp.symbols(\"x y theta psi cte v w\")\n", "\n", "gs = sp.Matrix([[ sp.cos(theta)*v],\n", " [ sp.sin(theta)*v],\n", " [w],\n", " [w],\n", " [ v*sp.sin(-psi)]])\n", "\n", "state = sp.Matrix([x,y,theta,psi,cte])\n", "\n", "gs.jacobian(state)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\cos{\\left(\\theta \\right)} & 0\\\\\\sin{\\left(\\theta \\right)} & 0\\\\0 & 1\\\\0 & 1\\\\- \\sin{\\left(\\psi \\right)} & 0\\end{matrix}\\right]$" ], "text/plain": [ "Matrix([\n", "[cos(theta), 0],\n", "[sin(theta), 0],\n", "[ 0, 1],\n", "[ 0, 1],\n", "[ -sin(psi), 0]])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "state = sp.Matrix([v,w])\n", "\n", "gs.jacobian(state)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.9" } }, "nbformat": 4, "nbformat_minor": 4 }