{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from tinyphysics import TinyPhysicsModel, TinyPhysicsSimulator, CONTROL_START_IDX\n", "from controllers import pid\n", "from matplotlib import pyplot as plt\n", "import seaborn as sns\n", "\n", "sns.set_theme()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def plot_rollout(sim):\n", " fig, ax = plt.subplots(figsize=(10, 5))\n", " ax.plot(sim.target_lataccel_history, label=\"Target Lateral Acceleration\", alpha=0.5)\n", " ax.plot(sim.current_lataccel_history, label=\"Actual Lateral Acceleration\", alpha=0.5)\n", " ax.legend()\n", " ax.set_xlabel(\"Step\")\n", " ax.set_ylabel(\"Lateral Acceleration\")\n", " ax.set_title(\"Rollout\")\n", " plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model = TinyPhysicsModel(\"./models/tinyphysics.onnx\", debug=True)\n", "controller = pid.Controller()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim = TinyPhysicsSimulator(model, \"./data/00000.csv\", controller=controller, debug=False)\n", "sim.rollout()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot_rollout(sim)" ] } ], "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.11.4" } }, "nbformat": 4, "nbformat_minor": 2 }