From 0c03feb90593045f89a092b5af5d1897472db63b Mon Sep 17 00:00:00 2001 From: maximusron Date: Sun, 17 Sep 2023 12:08:59 +0530 Subject: [PATCH] update rich text and remove matplotlib warning for kg plot --- notebooks/kalman_CUDA_demo/run_kf.ipynb | 41 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/notebooks/kalman_CUDA_demo/run_kf.ipynb b/notebooks/kalman_CUDA_demo/run_kf.ipynb index 33f3b906..a31dab2c 100644 --- a/notebooks/kalman_CUDA_demo/run_kf.ipynb +++ b/notebooks/kalman_CUDA_demo/run_kf.ipynb @@ -146,7 +146,8 @@ "id": "d8bb436d-238b-488f-a8a8-b8e1a4a0150d", "metadata": {}, "source": [ - "### User functions to run the CUDA routines on std::vectors" + "### Defining functions to run CUDA kernels and obtain the results:\n", + "This allows us to run calls to all matrix-matrix, matrix-vector and vector-vector CUDA operations without dealing with CUDA syntax" ] }, { @@ -781,6 +782,27 @@ "}\n" ] }, + { + "cell_type": "markdown", + "id": "54fb13b2-51ca-4dda-8503-151aea8dbd68", + "metadata": {}, + "source": [ + "### Putting it all together:\n", + "We define the `run_kf` function that initialises the following:\n", + "- Number of states\n", + "- Dimensions of eacch measurement\n", + "- Time steps used $\\begin{aligned} & {dt}\\end{aligned}$\n", + "- Covariance matrices\n", + "- Passes the measurement data to $\\begin{aligned} & \\hat{x}_0^{-}\\end{aligned}$\n", + "\n", + "Then the measurements are fed into filter, and output estimated states\n", + "\n", + "The algorithm then runs by looping over the measurements:\n", + "\n", + "$\\begin{gathered} & for\\:y\\:in\\:measurements\\::\\end{gathered}$\n", + "$\\begin{gathered} & kf.update(y)\\end{gathered}$" + ] + }, { "cell_type": "code", "execution_count": 24, @@ -790,8 +812,8 @@ "source": [ "std::vector> run_kf(bool verbose) {\n", " \n", - " int n = 3; // Number of states\n", - " int m = 1; // Number of measurements\n", + " int n = 3; \n", + " int m = 1; \n", "\n", " double dt = 1.0 / 30; // Time step\n", " \n", @@ -850,7 +872,7 @@ " std::vector> gain;\n", " kf.init(0, x0);\n", "\n", - " // Feed measurements into filter, output estimated states\n", + " \n", " std::vector y(m);\n", " if(verbose) {\n", " std::cout << \"t = \" << 0 << \", \" << \"x_hat[0]: \";\n", @@ -1129,15 +1151,7 @@ "execution_count": 29, "id": "f7bcd055-7470-42c9-aad8-238ff3d3566e", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.\n" - ] - } - ], + "outputs": [], "source": [ "%%python\n", "\n", @@ -1146,7 +1160,6 @@ "plt.xlabel('Time Steps')\n", "plt.ylabel('Kalman Gain')\n", "plt.title('Kalman Gain Plot')\n", - "plt.legend()\n", "plt.savefig(\"kalman_gain_plot.jpg\")\n", " \n", "plt.yscale('symlog')\n",