mpc_python_learn/notebooks/3.1-better-track.ipynb

354 lines
132 KiB
Plaintext
Raw Normal View History

2021-04-20 23:26:38 +08:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"thanks to -> https://stackoverflow.com/questions/49558464/shrink-polygon-using-corner-coordinates"
]
},
{
"cell_type": "code",
"execution_count": 1,
2024-10-23 17:34:26 +08:00
"metadata": {
"ExecuteTime": {
"end_time": "2024-10-23T09:28:36.727289Z",
"start_time": "2024-10-23T09:28:36.365530Z"
}
},
2021-04-20 23:26:38 +08:00
"outputs": [
{
"data": {
2024-10-23 17:34:26 +08:00
"text/plain": "(np.float64(-0.8500000000000001),\n np.float64(6.85),\n np.float64(-1.3744678440936948),\n np.float64(11.065450849718747))"
2021-04-20 23:26:38 +08:00
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2024-10-23 17:34:26 +08:00
"text/plain": "<Figure size 1500x1000 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAABLkAAAMtCAYAAABza6MWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABI/UlEQVR4nO3de3zcdZ3o//e0Sdv0ll7TBGm1XBVcroKA7uKKUhe61HrOYUU8ygKrx7IICmcV0SOwaOVxtOACuw+V+/pAYEsLKF5gwaOwqPV4oSz1x70HhJS0tun9kqTz+6M0vWTaJu3M9zufmefzn1w6yeczyaeT5JX3TArFYrEYAAAAAJCwQXlvAAAAAAD2lcgFAAAAQPJELgAAAACSJ3IBAAAAkDyRCwAAAIDkiVwAAAAAJE/kAgAAACB5IhcAAAAAyRO5AAAAAEheQ94b2JUVK1ZEd3d33tuoORMnToylS5fmvQ1qnHNGVpw1suKskRVnjSw4Z2TFWaNcGhoaYuzYsXu+XAZ72Svd3d3R1dWV9zZqSqFQiIgtH9tisZjzbqh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UA5ELAEiaaa7dM8UFANQLkQsASJ5prl0zxQUA1AuRCwBInmmu0kxxAQD1ROQCAGqCaa6+THEBAPVE5AIAaoJprh2Z4gIA6o3IBQDUDNNc25jiAgDqjcgFANQM01xbmOICAOqRyAUA1BTTXKa4AID6JHIBADWl3qe5THEBAPVK5AIAak49T3OZ4gIA6pXIBQD
2021-04-20 23:26:38 +08:00
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
2022-08-02 16:33:49 +08:00
"\n",
2021-04-20 23:26:38 +08:00
"plt.style.use(\"ggplot\")\n",
"\n",
2022-08-02 16:33:49 +08:00
"\n",
2021-04-20 23:26:38 +08:00
"def shrink_polygon(coords, shrink_value_x, shrink_value_y):\n",
2022-08-02 16:33:49 +08:00
" \"\"\" \"\"\"\n",
"\n",
2021-04-20 23:26:38 +08:00
" def det(a, b):\n",
2022-08-02 16:33:49 +08:00
" return a[0] * b[1] - a[1] * b[0]\n",
2021-04-20 23:26:38 +08:00
"\n",
" def line_intersection(line1, line2):\n",
" xdiff = (line1[0][0] - line1[1][0], line2[0][0] - line2[1][0])\n",
2022-08-02 16:33:49 +08:00
" ydiff = (line1[0][1] - line1[1][1], line2[0][1] - line2[1][1]) # Typo was here\n",
2021-04-20 23:26:38 +08:00
"\n",
" div = det(xdiff, ydiff)\n",
" if div == 0:\n",
2022-08-02 16:33:49 +08:00
" raise Exception(\"lines do not intersect\")\n",
2021-04-20 23:26:38 +08:00
"\n",
" d = (det(*line1), det(*line2))\n",
" x = det(d, xdiff) / div\n",
" y = det(d, ydiff) / div\n",
" return x, y\n",
"\n",
" # how much the coordinates are moved as an absolute value\n",
2022-08-02 16:33:49 +08:00
" # shrink_value_x = 2\n",
" # shrink_value_y = 2\n",
2021-04-20 23:26:38 +08:00
"\n",
" # coords must be clockwise\n",
2022-08-02 16:33:49 +08:00
" # coords = [(0, 0), (0, 100), (20, 100), (30, 60), (40, 100), (60, 100), (60, 0), (40, 10), (40, 40), (20, 40), (20, 10)]\n",
"\n",
" lines = [[coords[i - 1], coords[i]] for i in range(len(coords))]\n",
2021-04-20 23:26:38 +08:00
"\n",
" new_lines = []\n",
" for i in lines:\n",
" dx = i[1][0] - i[0][0]\n",
" dy = i[1][1] - i[0][1]\n",
"\n",
" # this is to take into account slopes\n",
2022-08-02 16:33:49 +08:00
" factor = 1 / (dx * dx + dy * dy) ** 0.5\n",
" new_dx = dy * shrink_value_x * factor\n",
" new_dy = dx * shrink_value_y * factor\n",
2021-04-20 23:26:38 +08:00
"\n",
2022-08-02 16:33:49 +08:00
" new_lines.append(\n",
" [(i[0][0] + new_dx, i[0][1] - new_dy), (i[1][0] + new_dx, i[1][1] - new_dy)]\n",
" )\n",
2021-04-20 23:26:38 +08:00
"\n",
" # find position of intersection of all the lines\n",
" new_coords = []\n",
" for i in range(len(new_lines)):\n",
2022-08-02 16:33:49 +08:00
" new_coords.append((line_intersection(new_lines[i - 1], new_lines[i])))\n",
"\n",
2021-04-20 23:26:38 +08:00
" return new_coords\n",
"\n",
2022-08-02 16:33:49 +08:00
"\n",
"# must be clockwise!\n",
"coords = [\n",
" (0, 0),\n",
" (0, 10),\n",
" (2, 10),\n",
" (3, 8),\n",
" (4, 10),\n",
" (6, 10),\n",
" (6, 0),\n",
" (4, 1),\n",
" (4, 4),\n",
" (2, 4),\n",
" (2, 1),\n",
"]\n",
2021-04-20 23:26:38 +08:00
"\n",
"# how much the coordinates are moved as an absolute value\n",
2022-08-02 16:33:49 +08:00
"SHIFT = 0.5 # [m]\n",
2021-04-20 23:26:38 +08:00
"\n",
2022-08-02 16:33:49 +08:00
"up = shrink_polygon(coords, -SHIFT, -SHIFT)\n",
"lo = shrink_polygon(coords, SHIFT, SHIFT)\n",
2021-04-20 23:26:38 +08:00
"\n",
"\"\"\"\n",
"the last point is out of order for my needs\n",
"\"\"\"\n",
2022-08-02 16:33:49 +08:00
"\n",
"\n",
2021-04-20 23:26:38 +08:00
"def rotate(l, n):\n",
" return l[n:] + l[:n]\n",
"\n",
2022-08-02 16:33:49 +08:00
"\n",
"up = rotate(up, 1)\n",
"lo = rotate(lo, 1)\n",
2021-04-20 23:26:38 +08:00
"\n",
"a = np.array(up)\n",
"b = np.array(coords)\n",
"c = np.array(lo)\n",
"\n",
2022-08-02 16:33:49 +08:00
"plt.figure(figsize=(15, 10))\n",
"plt.plot(a[:, 0], a[:, 1], \"b-\")\n",
"plt.plot(b[:, 0], b[:, 1], \"r-\")\n",
"plt.plot(c[:, 0], c[:, 1], \"g-\")\n",
2021-04-20 23:26:38 +08:00
"plt.axis(\"equal\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"now these edges can be used to compute the path as before! Plus outer and inner track"
]
},
{
"cell_type": "code",
2024-10-23 17:34:26 +08:00
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2024-10-23T09:28:51.991289Z",
"start_time": "2024-10-23T09:28:51.987250Z"
}
},
2021-04-20 23:26:38 +08:00
"outputs": [],
"source": [
"from scipy.interpolate import interp1d\n",
"from scipy.signal import savgol_filter\n",
2022-08-02 16:33:49 +08:00
"\n",
"\n",
"def compute_path_from_wp(start_xp, start_yp, step=0.1, smooth_factor=7):\n",
2021-04-20 23:26:38 +08:00
" \"\"\"\n",
" Computes a reference path given a set of waypoints\n",
" \"\"\"\n",
2022-08-02 16:33:49 +08:00
"\n",
" final_xp = []\n",
" final_yp = []\n",
" delta = step # [m]\n",
"\n",
" for idx in range(len(start_xp) - 1):\n",
" section_len = np.sum(\n",
" np.sqrt(\n",
" np.power(np.diff(start_xp[idx : idx + 2]), 2)\n",
" + np.power(np.diff(start_yp[idx : idx + 2]), 2)\n",
" )\n",
" )\n",
"\n",
" interp_range = np.linspace(0, 1, np.floor(section_len / delta).astype(int))\n",
"\n",
" fx = interp1d(np.linspace(0, 1, 2), start_xp[idx : idx + 2], kind=1)\n",
" fy = interp1d(np.linspace(0, 1, 2), start_yp[idx : idx + 2], kind=1)\n",
"\n",
2021-04-20 23:26:38 +08:00
" # watch out to duplicate points!\n",
2022-08-02 16:33:49 +08:00
" final_xp = np.append(final_xp, fx(interp_range)[1:])\n",
" final_yp = np.append(final_yp, fy(interp_range)[1:])\n",
"\n",
2021-04-20 23:26:38 +08:00
" \"\"\"this smoothens up corners\"\"\"\n",
2022-08-02 16:33:49 +08:00
" window_size = smooth_factor # Smoothening filter window\n",
2021-04-20 23:26:38 +08:00
" final_xp = savgol_filter(final_xp, window_size, 1)\n",
" final_yp = savgol_filter(final_yp, window_size, 1)\n",
2022-08-02 16:33:49 +08:00
"\n",
2021-04-20 23:26:38 +08:00
" dx = np.append(0, np.diff(final_xp))\n",
" dy = np.append(0, np.diff(final_yp))\n",
" theta = np.arctan2(dy, dx)\n",
"\n",
2022-08-02 16:33:49 +08:00
" return np.vstack((final_xp, final_yp, theta))"
2021-04-20 23:26:38 +08:00
]
},
{
"cell_type": "code",
2024-10-23 17:34:26 +08:00
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2024-10-23T09:28:52.737070Z",
"start_time": "2024-10-23T09:28:52.653026Z"
}
},
2021-04-20 23:26:38 +08:00
"outputs": [
{
"data": {
2024-10-23 17:34:26 +08:00
"text/plain": "Text(0.5, 0, 'x')"
2021-04-20 23:26:38 +08:00
},
2024-10-23 17:34:26 +08:00
"execution_count": 4,
2021-04-20 23:26:38 +08:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2024-10-23 17:34:26 +08:00
"text/plain": "<Figure size 1500x1000 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAABM4AAANCCAYAAACeXIB4AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACf1klEQVR4nOzdeXxU1f3/8fdMJiQhCYQZsuOCgnusa2vdcCmRUvtzqV+7EOvSupeqYNp+a/1q1W+tRbHWLu7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+Z44SxcUqeOklFd9zj9dd8q1Qd7dGXX65Qv396j75ZK374Q+lUMjrbgFZ2/DlL0uSCv75T4XWr/e4NwAAJ1A4AwD4Qv7bb0uSNh50kLcdARzQv88+WvfJ0sMRN92kvCVLPO6RP5XeeKMiy5YpXlWljp/8hCXayHmJmhrFP0mBjbz7rse9AQA4gb9OAAC+EHnnHUlS/957e9wTwBkbGhrUM2GCQj09GnX55VJ/v9dd8pVhL72kknvvlSR13HyzrJEjPe4R4Az7dSz/k9c1AEBuo3AGAPBeb68iS5dKkvoonCEoQiF1zJihRGmphr3+ukruuMPrHvlGqKtLZdOmSZK6pkxR7/HHe9wjwDn261jkk5nUAIDcRuEMAOC5yHvvKRSPKzFihBLV1V53B3BMorZWa3/4Q0lS6S23sHTrEyP+938V+eAD9Y8Zo3X/8z9edwdwVP8++0hixhkABAWFMwCA5yLvvSdJ6h8/no3BETjdZ56pnhNPVGjjRpXOmOF1dzyXt2y
2021-04-20 23:26:38 +08:00
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2022-08-02 16:33:49 +08:00
"track = compute_path_from_wp(b[:, 0], b[:, 1])\n",
"track_lower = compute_path_from_wp(c[:, 0], c[:, 1])\n",
"track_upper = compute_path_from_wp(a[:, 0], a[:, 1])\n",
2021-04-20 23:26:38 +08:00
"\n",
2022-08-02 16:33:49 +08:00
"plt.figure(figsize=(15, 10))\n",
2021-04-20 23:26:38 +08:00
"\n",
2022-08-02 16:33:49 +08:00
"plt.plot(track[0, :], track[1, :], \"b+\")\n",
"plt.plot(track_lower[0, :], track_lower[1, :], \"g-\")\n",
"plt.plot(track_upper[0, :], track_upper[1, :], \"r-\")\n",
2021-04-20 23:26:38 +08:00
"plt.axis(\"equal\")\n",
2022-08-02 16:33:49 +08:00
"plt.ylabel(\"y\")\n",
"plt.xlabel(\"x\")"
2021-04-20 23:26:38 +08:00
]
},
{
"cell_type": "code",
2024-10-23 17:34:26 +08:00
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2024-10-23T09:28:54.589399Z",
"start_time": "2024-10-23T09:28:54.532313Z"
}
},
2021-04-20 23:26:38 +08:00
"outputs": [
{
"data": {
2024-10-23 17:34:26 +08:00
"text/plain": "[<matplotlib.lines.Line2D at 0x1369457f0>]"
2021-04-20 23:26:38 +08:00
},
2024-10-23 17:34:26 +08:00
"execution_count": 5,
2021-04-20 23:26:38 +08:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2024-10-23 17:34:26 +08:00
"text/plain": "<Figure size 640x480 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAGdCAYAAADnrPLBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACDcklEQVR4nO29eZxjZZ3v/zknSyWpVFVSe7qW7q6mm3VYFAWEexkX1PG2Mj0ioI7IIPycoS9XvZdR+THowMhgOzPijDLjAoq0V4YWaWWQGRnhJyOIqKC00NBtd1V1LZ3ak6pKJalKcs7vj5PnZN9OzvIk9X2/Xv3qquTkPM9zTirPJ99VkGVZBkEQBEEQRIMiWj0BgiAIgiCIeiAxQxAEQRBEQ0NihiAIgiCIhobEDEEQBEEQDQ2JGYIgCIIgGhoSMwRBEARBNDQkZgiCIAiCaGhIzBAEQRAE0dCQmCEIgiAIoqEhMUMQBEEQRENjt3oCZhIKhZBMJnU/b09PD+bn53U/Ly/Q+hqfZl8jra/xafY10vq0Ybfb4ff7Kx+n+8gck0wmkUgkdD2nIAjquZuxzRWtr/Fp9jXS+hqfZl8jrc94yM1EEARBEERDQ2KGIAiCIIiGhsQMQRAEQRANDYkZgiAIgiAaGhIzBEEQBEE0NCRmCIIgCIJoaEjMEARBEATR0JCYIQiCIAiioSExQxAEQRBEQ0NihiAIgiCIhobEDEEQBEEQDQ2JGYIgCIIgGppN1WiSIAiCMJbXll7DgaMHkJSTV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1rUQBcUqLwty3fc9FFIsO52dUsG5UiM
2021-04-20 23:26:38 +08:00
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2022-08-02 16:33:49 +08:00
"plt.plot(np.degrees(track[2, :]), \"b-\")\n",
"plt.plot(np.degrees(track_lower[2, :]), \"g-\")\n",
"plt.plot(np.degrees(track_upper[2, :]), \"r-\")"
2021-04-20 23:26:38 +08:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"probably smarter to to save this in a file and load it in a notebook, so I dont have to carry over the code..."
]
},
{
"cell_type": "code",
2024-10-23 17:34:26 +08:00
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2024-10-23T09:29:05.534206Z",
"start_time": "2024-10-23T09:29:05.527716Z"
}
},
2021-04-20 23:26:38 +08:00
"outputs": [],
"source": [
2022-08-02 16:33:49 +08:00
"with open(\"tracks/test.npy\", \"wb\") as f:\n",
2021-04-20 23:26:38 +08:00
" np.save(f, track)\n",
" np.save(f, track_lower)\n",
" np.save(f, track_upper)\n",
"\n",
2022-08-02 16:33:49 +08:00
"with open(\"tracks/test.npy\", \"rb\") as f:\n",
2021-04-20 23:26:38 +08:00
" a = np.load(f)\n",
" b = np.load(f)\n",
2022-08-02 16:33:49 +08:00
" c = np.load(f)"
2021-04-20 23:26:38 +08:00
]
},
{
"cell_type": "code",
2024-10-23 17:34:26 +08:00
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"end_time": "2024-10-23T09:29:06.705696Z",
"start_time": "2024-10-23T09:29:06.699962Z"
}
},
2021-04-20 23:26:38 +08:00
"outputs": [],
"source": [
2022-08-02 16:33:49 +08:00
"# matches perfectly!\n",
"# plt.plot(np.degrees(a[2,:]),\"b-\")\n",
"# plt.plot(np.degrees(b[2,:]),\"g-\")\n",
"# plt.plot(np.degrees(c[2,:]),\"r-\")"
2021-04-20 23:26:38 +08:00
]
},
{
"cell_type": "code",
2024-10-23 17:34:26 +08:00
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"end_time": "2024-10-23T09:29:07.582893Z",
"start_time": "2024-10-23T09:29:07.568518Z"
}
},
2021-04-20 23:26:38 +08:00
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
2024-10-23 17:34:26 +08:00
"name": "python3",
2021-04-20 23:26:38 +08:00
"language": "python",
2024-10-23 17:34:26 +08:00
"display_name": "Python 3 (ipykernel)"
2021-04-20 23:26:38 +08:00
},
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}