Skip to content

Commit

Permalink
updaets to notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Mar 20, 2024
1 parent fadf478 commit 7d6c9b9
Show file tree
Hide file tree
Showing 4 changed files with 381 additions and 7 deletions.
113 changes: 113 additions & 0 deletions spf/notebooks/docker.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# docker run --rm -it -p 14590-14595:14590-14595 ardupilot_spf /ardupilot/Tools/autotest/sim_vehicle.py \\\n",
"# -l 37.76509485,-122.40940127,0,0 -v rover -f rover-skid \\\n",
"# --out tcpin:0.0.0.0:14590 --out tcpin:0.0.0.0:14591 -S 1\n",
"import docker"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client = docker.from_env()\n",
"container = client.containers.run(\n",
" \"csmisko/ardupilotspf:latest\",\n",
" \"/ardupilot/Tools/autotest/sim_vehicle.py -l 37.76509485,-122.40940127,0,0 \\\n",
" -v rover -f rover-skid --out tcpin:0.0.0.0:14590 --out tcpin:0.0.0.0:14591 -S 5\",\n",
" stdin_open=True,\n",
" ports={\n",
" \"14590/tcp\": (\"127.0.0.1\", 14590),\n",
" \"14591/tcp\": (\"127.0.0.1\", 14591),\n",
" },\n",
" detach=True,\n",
" remove=True,\n",
" auto_remove=True,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"output = container.attach(stdout=True, stream=True, logs=True)\n",
"online = False\n",
"for line in output:\n",
" if \"Detected vehicle\" in line:\n",
" online = True\n",
"if not online:\n",
" raise ValueError\n",
"\n",
"# (\"ardupilot_spf\"\n",
"# image=\"ardupilot_spf\",\n",
"# auto_remove=True,\n",
"# name=\"test_postgres\",\n",
"# ports={\"14590/tcp\": (\"127.0.0.1\", 14590)},\n",
"# detach=True,\n",
"# remove=True,\n",
"# )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"container"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.containers.list()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "spf",
"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.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
21 changes: 20 additions & 1 deletion spf/notebooks/gps_boundary.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@
"source": [
"import numpy as np\n",
"\n",
"from boundaries import franklin_boundary, crissy_boundary, crissy_boundary_convex\n",
"repo_root = \"/Users/miskodzamba/Dropbox/research/gits/spf/\"\n",
"import sys\n",
"\n",
"sys.path.append(repo_root) # go to parent dir\n",
"# from boundaries import\n",
"from spf.gps.boundaries import (\n",
" franklin_boundary,\n",
" crissy_boundary,\n",
" crissy_boundary_convex,\n",
" franklin_safe,\n",
")\n",
"\n",
"from matplotlib import pyplot as plt\n",
"\n",
Expand All @@ -19,6 +29,15 @@
"plt.axis(\"equal\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"franklin_safe.mean(axis=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
94 changes: 88 additions & 6 deletions spf/notebooks/load_real_data_session_v3rx.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@
"data_root_dir = (\n",
" \"/Users/miskodzamba/Dropbox/research/spf_aux/missions/march13/rover3/second_try\"\n",
")\n",
"data_root_dir = (\n",
" \"/Users/miskodzamba/Dropbox/research/spf_aux/missions/march13/rover1/second_try\"\n",
")\n",
"# data_root_dir = \"/Users/miskodzamba/Dropbox/research/spf_aux/missions/march14/rover3\"\n",
"# data_root_dir = \"/Users/miskodzamba/Dropbox/research/spf_aux/missions/march13/roof/laptop_recording\"\n",
"\n",
"# march 17\n",
"data_root_dir = \"/Users/miskodzamba/Dropbox/research/spf_aux/missions/march17/rover3\"\n",
"# data_root_dir = \"/Users/miskodzamba/Dropbox/research/spf_aux/missions/march17/rover2/1\"\n",
"\n",
"width = 3000 # height is assumed to be same\n",
"step_size = 1\n",
"\n",
Expand All @@ -46,11 +54,73 @@
"# pick a session from the dataset\n",
"session_idx = 0 # 2**14\n",
"session1 = ds[(0, session_idx)]\n",
"session2 = session1\n",
"# session2 = ds[(1, session_idx)]\n",
"# session2 = session1\n",
"session2 = ds[(1, session_idx)]\n",
"print(ds.root_dir)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c3554a8c",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"import datetime\n",
"\n",
"z = datetime.datetime.fromtimestamp(session2[\"time_stamps\"][0]) #\n",
"# .strftime(\n",
"# \"%Y-%m-%d %H:%M:%S\"\n",
"# )\n",
"z.minute, z"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "91afc2e7",
"metadata": {},
"outputs": [],
"source": [
"z = datetime.datetime.fromtimestamp(session2[\"time_stamps\"][0]) #\n",
"z"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a14e7c90",
"metadata": {},
"outputs": [],
"source": [
"z = datetime.datetime.fromtimestamp(session2[\"time_stamps\"][0]) #\n",
"z"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "696def35",
"metadata": {},
"outputs": [],
"source": [
"z = datetime.datetime.fromtimestamp(datetime.datetime.now().timestamp())\n",
"z.strftime(\"%Y_%m_%d_%H_%M_%S\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "91dbf93c",
"metadata": {},
"outputs": [],
"source": [
"z = datetime.datetime.fromtimestamp(datetime.datetime.now().timestamp())\n",
"z.strftime(\"%Y_%m_%d_%H_%M_%S\")"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -214,6 +284,16 @@
"peaks"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "de5b3716",
"metadata": {},
"outputs": [],
"source": [
"session1.keys()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -280,12 +360,14 @@
" # )\n",
" axs[0, 1 + session_idx].set_title(f\"SDR:{session_idx} phaseRX0-phaseRX1\")\n",
" axs[0, 1 + session_idx].scatter(\n",
" np.arange(peaks_at_t_in_radians.shape[0]), peaks_at_t_in_radians[:, 0]\n",
" np.arange(peaks_at_t_in_radians.shape[0]),\n",
" peaks_at_t_in_radians[:, 0],\n",
" alpha=0.1,\n",
" )\n",
" # print(peaks_at_t_in_radians[:, 0].shape)\n",
" # axs[0, 1 + session_idx].scatter(peaks_at_t_in_radians[:, 0])\n",
" axs[0, 1 + session_idx].scatter(\n",
" np.arange(peaks_at_t_in_radians.shape[0]), peaks_at_t_in_radians[:, 1]\n",
" np.arange(peaks_at_t_in_radians.shape[0]),\n",
" peaks_at_t_in_radians[:, 1],\n",
" alpha=0.1,\n",
" )\n",
" axs[0, 1 + session_idx].set_ylim([-np.pi, +np.pi])\n",
" axs[0, 1 + session_idx].set_xlabel(\"Time\")\n",
Expand Down
Loading

0 comments on commit 7d6c9b9

Please sign in to comment.