Skip to content

Commit

Permalink
update rich text and remove matplotlib warning for kg plot
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronj0 committed Sep 17, 2023
1 parent f9e22c3 commit 0c03feb
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions notebooks/kalman_CUDA_demo/run_kf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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,
Expand All @@ -790,8 +812,8 @@
"source": [
"std::vector<std::vector<double>> 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",
Expand Down Expand Up @@ -850,7 +872,7 @@
" std::vector<std::vector<double>> gain;\n",
" kf.init(0, x0);\n",
"\n",
" // Feed measurements into filter, output estimated states\n",
" \n",
" std::vector<double> y(m);\n",
" if(verbose) {\n",
" std::cout << \"t = \" << 0 << \", \" << \"x_hat[0]: \";\n",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 0c03feb

Please sign in to comment.