124 lines
3.0 KiB
Plaintext
124 lines
3.0 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"c:\\Users\\admin\\Projects\\autopilot\\visualization.py:113: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.\n",
|
|
" plt.tight_layout()\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"from pathlib import Path\n",
|
|
"from PIL import Image\n",
|
|
"import numpy as np\n",
|
|
"from autopilot import AutoPilot\n",
|
|
"from visualization import VisualizationManager\n",
|
|
"\n",
|
|
"vzm = VisualizationManager()\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"<autopilot.PilotCommand at 0x2696e2decd0>"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"autopilot = AutoPilot([(0, 0), (1500, 1000)], [], vzm)\n",
|
|
"imgs = [Image.open(Path('images') / f'photo_{i}.png') for i in range(10)]\n",
|
|
"autopilot.handle(imgs[0])\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\n",
|
|
" [Pilot] translate: -0.28939364297583925 8.879763334079307\n",
|
|
" [Pilot] Drone Position: (8.87, 0.58)\n",
|
|
" [Pilot] Angle: 5.6°\n",
|
|
" [Pilot] Target Index: 0\n",
|
|
" [Pilot] Target Position: (0, 0)\n",
|
|
" [Pilot] Distance: 0.0\n",
|
|
"0.1 50.0\n",
|
|
"\n",
|
|
" [Pilot] translate: -4.194654791266826 51.7432078133843\n",
|
|
" [Pilot] Drone Position: (60.43, 6.60)\n",
|
|
" [Pilot] Angle: 11.3°\n",
|
|
" [Pilot] Target Index: 1\n",
|
|
" [Pilot] Target Position: (1500, 1000)\n",
|
|
" [Pilot] Distance: 1795.0821692652123\n",
|
|
"0.1 50.0\n",
|
|
"\n",
|
|
" [Pilot] translate: -4.752188299516379 51.16691704857423\n",
|
|
" [Pilot] Drone Position: (110.73, 17.12)\n",
|
|
" [Pilot] Angle: 17.1°\n",
|
|
" [Pilot] Target Index: 1\n",
|
|
" [Pilot] Target Position: (1500, 1000)\n",
|
|
" [Pilot] Distance: 1749.0606665752869\n",
|
|
"0.1 50.0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"for i in range(1, 4):\n",
|
|
" print()\n",
|
|
" command = autopilot.handle(imgs[i])\n",
|
|
" print(command.dangle, command.velocity)\n",
|
|
" vzm.pause(0.5)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv",
|
|
"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.0"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|