{"id":21157885,"url":"https://github.com/yhotta240/tello-python","last_synced_at":"2025-03-14T15:26:17.343Z","repository":{"id":246178512,"uuid":"820333674","full_name":"yhotta240/tello-python","owner":"yhotta240","description":"PythonでTelloドローンを操作する基本的なプログラム","archived":false,"fork":false,"pushed_at":"2024-07-02T23:02:00.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T09:08:37.087Z","etag":null,"topics":["python","tello","tellodrone"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yhotta240.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-26T09:07:48.000Z","updated_at":"2024-07-02T23:02:03.000Z","dependencies_parsed_at":"2024-06-26T10:30:08.678Z","dependency_job_id":null,"html_url":"https://github.com/yhotta240/tello-python","commit_stats":null,"previous_names":["yhotta240/tello-python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhotta240%2Ftello-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhotta240%2Ftello-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhotta240%2Ftello-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhotta240%2Ftello-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yhotta240","download_url":"https://codeload.github.com/yhotta240/tello-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243599703,"owners_count":20317143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","tello","tellodrone"],"created_at":"2024-11-20T12:11:55.033Z","updated_at":"2025-03-14T15:26:17.323Z","avatar_url":"https://github.com/yhotta240.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PythonでTelloドローンを操作する\n\n\n## はじめに\n\nTelloドローンは、その手軽さと高度な機能から、多くのドローン愛好者や開発者に人気です。本記事では、Pythonを使ってTelloドローンを操作する方法について説明します。今回は、ライブラリを極力使わずに、UDPソケットを用いて直接Telloにコマンドを送信するシンプルな方法を紹介します。\n\n## 必要なもの\n\n- Telloドローン\n- Python 3.x\n- Wi-Fi接続できるPC\n\n## Tello SDKの基本\n\nTelloドローンは、SDK（Software Development Kit）を通じてコマンドを受け取ります。これらのコマンドは、UDPプロトコルを使用して送信されます。以下は、基本的なコマンドの例です：\n\n- `command`：SDKモードを開始\n- `takeoff`：離陸\n- `land`：着陸\n- `forward x`：前進（xはセンチメートル）\n- `back x`：後退（xはセンチメートル）\n- `cw x`：時計回りに旋回（xは度）\n\n## サンプルコード\n\n### 1. ソケットの作成\n\nまず、UDPソケットを作成します。このソケットは、Telloドローンにコマンドを送信するために使用されます。\n\n```python\nimport socket\n\n# TelloのIPアドレスとポート\nTELLO_IP = '192.168.10.1'\nTELLO_PORT = 8889\n\n# コマンドを送信するためのソケットを作成\nsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\ntello_address = (TELLO_IP, TELLO_PORT)\n```\n\n### 2. コマンド送信\n\n次に、Telloドローンにコマンドを送信するための関数を定義します。\n\n```python\ndef send_command(command):\n    \"\"\"\n    Telloにコマンドを送信する関数\n    \"\"\"\n    try:\n        sock.sendto(command.encode('utf-8'), tello_address)\n        print(f\"Sending command: {command}\")\n    except Exception as e:\n        print(f\"Error sending command: {e}\")\n```\n\n### 3. レスポンス受信\n\nTelloドローンからのレスポンスを受信するための関数も定義します。\n\n```python\ndef receive_response():\n    \"\"\"\n    Telloからのレスポンスを受信する関数\n    \"\"\"\n    try:\n        response, _ = sock.recvfrom(1024)\n        print(f\"Received response: {response.decode('utf-8')}\")\n    except Exception as e:\n        print(f\"Error receiving response: {e}\")\n```\n\n### 4. メイン関数の定義\n\n最後に、ドローンの基本的な操作（離陸、前進、後退、旋回、着陸）を行うメイン関数を定義します。\n\n```python\ndef main():\n    # コマンドモードを開始\n    send_command(\"command\")\n    time.sleep(2)\n    receive_response()\n\n    # 離陸\n    send_command(\"takeoff\")\n    time.sleep(5)\n    receive_response()\n\n    # 前進（100cm）\n    send_command(\"forward 100\")\n    time.sleep(5)\n    receive_response()\n\n    # 後進（100cm）\n    send_command(\"back 100\")\n    time.sleep(5)\n    receive_response()\n\n    # 旋回（時計回りに90度）\n    send_command(\"cw 90\")\n    time.sleep(5)\n    receive_response()\n\n    # 着陸\n    send_command(\"land\")\n    time.sleep(5)\n    receive_response()\n\n    # ソケットを閉じる\n    sock.close()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## 実行手順\n\n1. Telloドローンの電源を入れ、Wi-Fiに接続します。\n2. 上記のPythonコードを実行します。\n\nこのサンプルコードでは、Telloドローンが離陸し、前進、後退、旋回、そして着陸する一連の動作を行います。各コマンドの後にレスポンスを受信しているため、コマンドが正常に送信されたかどうかを確認できます。\n\n## まとめ\n\n今回は、Pythonを使用してTelloドローンを操作するシンプルな方法を紹介しました。ライブラリを使用せずに直接コマンドを送信することで、Telloドローンの基本的な操作を理解することができます。この方法を基に、さらに高度な操作や自動化を実装することも可能です。ぜひ試してみてください。\n\n## 参考\n\nTello SDK 2.0 User Guide\n\nhttps://dl-cdn.ryzerobotics.com/downloads/Tello/Tello%20SDK%202.0%20User%20Guide.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhotta240%2Ftello-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyhotta240%2Ftello-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhotta240%2Ftello-python/lists"}