Skip to content

Commit 4b43bd2

Browse files
authored
Merge pull request #2 from SpaceTime-Vision-Robotics-Laboratory/brittleru/add_python_package
Brittleru/add python package
2 parents 9b4dc47 + f836011 commit 4b43bd2

34 files changed

+436
-48
lines changed

.github/workflows/ruff_linter.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Ruff Linter
22

3-
# Controls when the workflow will run
43
on:
5-
# Triggers the workflow on push or pull request events but only for the "main" branch
64
push:
75
branches: [ "main" ]
86
pull_request:
@@ -11,9 +9,7 @@ on:
119
# Allows you to run this workflow manually from the Actions tab
1210
workflow_dispatch:
1311

14-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1512
jobs:
16-
# This workflow contains a single job called "build"
1713
build:
1814
runs-on: ubuntu-latest
1915

@@ -42,4 +38,4 @@ jobs:
4238
- name: Run Tests
4339
run: |
4440
source .venv/bin/activate
45-
pytest test/
41+
pytest tests/

.github/workflows/ubuntu.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Ubuntu
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
test:
11+
name: Python ${{ matrix.python-version }} on Ubuntu
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.10", "3.11"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install flake8 pytest
29+
python -m pip install .[dev]
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
32+
- name: Lint with flake8
33+
run: |
34+
flake8 drone_base/ --count --select=E9,F63,F7,F82 --show-source --statistics
35+
flake8 drone_base/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
36+
37+
- name: Run tests with pytest and coverage
38+
run: |
39+
pytest --cov=drone_base --cov-report=xml

LICENSE

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
Academic Free License ("AFL") v. 3.0
2+
3+
This Academic Free License (the "License") applies to any original work of
4+
authorship (the "Original Work") whose owner (the "Licensor") has placed the
5+
following licensing notice adjacent to the copyright notice for the Original
6+
Work:
7+
8+
Licensed under the Academic Free License version 3.0
9+
10+
1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free,
11+
non-exclusive, sublicensable license, for the duration of the copyright, to do
12+
the following:
13+
14+
a) to reproduce the Original Work in copies, either alone or as part of a
15+
collective work;
16+
17+
b) to translate, adapt, alter, transform, modify, or arrange the Original
18+
Work, thereby creating derivative works ("Derivative Works") based upon the
19+
Original Work;
20+
21+
c) to distribute or communicate copies of the Original Work and Derivative
22+
Works to the public, under any license of your choice that does not
23+
contradict the terms and conditions, including Licensor's reserved rights
24+
and remedies, in this Academic Free License;
25+
26+
d) to perform the Original Work publicly; and
27+
28+
e) to display the Original Work publicly.
29+
30+
2) Grant of Patent License. Licensor grants You a worldwide, royalty-free,
31+
non-exclusive, sublicensable license, under patent claims owned or controlled
32+
by the Licensor that are embodied in the Original Work as furnished by the
33+
Licensor, for the duration of the patents, to make, use, sell, offer for sale,
34+
have made, and import the Original Work and Derivative Works.
35+
36+
3) Grant of Source Code License. The term "Source Code" means the preferred
37+
form of the Original Work for making modifications to it and all available
38+
documentation describing how to modify the Original Work. Licensor agrees to
39+
provide a machine-readable copy of the Source Code of the Original Work along
40+
with each copy of the Original Work that Licensor distributes. Licensor
41+
reserves the right to satisfy this obligation by placing a machine-readable
42+
copy of the Source Code in an information repository reasonably calculated to
43+
permit inexpensive and convenient access by You for as long as Licensor
44+
continues to distribute the Original Work.
45+
46+
4) Exclusions From License Grant. Neither the names of Licensor, nor the names
47+
of any contributors to the Original Work, nor any of their trademarks or
48+
service marks, may be used to endorse or promote products derived from this
49+
Original Work without express prior permission of the Licensor. Except as
50+
expressly stated herein, nothing in this License grants any license to
51+
Licensor's trademarks, copyrights, patents, trade secrets or any other
52+
intellectual property. No patent license is granted to make, use, sell, offer
53+
for sale, have made, or import embodiments of any patent claims other than the
54+
licensed claims defined in Section 2. No license is granted to the trademarks
55+
of Licensor even if such marks are included in the Original Work. Nothing in
56+
this License shall be interpreted to prohibit Licensor from licensing under
57+
terms different from this License any Original Work that Licensor otherwise
58+
would have a right to license.
59+
60+
5) External Deployment. The term "External Deployment" means the use,
61+
distribution, or communication of the Original Work or Derivative Works in any
62+
way such that the Original Work or Derivative Works may be used by anyone
63+
other than You, whether those works are distributed or communicated to those
64+
persons or made available as an application intended for use over a network.
65+
As an express condition for the grants of license hereunder, You must treat
66+
any External Deployment by You of the Original Work or a Derivative Work as a
67+
distribution under section 1(c).
68+
69+
6) Attribution Rights. You must retain, in the Source Code of any Derivative
70+
Works that You create, all copyright, patent, or trademark notices from the
71+
Source Code of the Original Work, as well as any notices of licensing and any
72+
descriptive text identified therein as an "Attribution Notice." You must cause
73+
the Source Code for any Derivative Works that You create to carry a prominent
74+
Attribution Notice reasonably calculated to inform recipients that You have
75+
modified the Original Work.
76+
77+
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that
78+
the copyright in and to the Original Work and the patent rights granted herein
79+
by Licensor are owned by the Licensor or are sublicensed to You under the
80+
terms of this License with the permission of the contributor(s) of those
81+
copyrights and patent rights. Except as expressly stated in the immediately
82+
preceding sentence, the Original Work is provided under this License on an "AS
83+
IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without
84+
limitation, the warranties of non-infringement, merchantability or fitness for
85+
a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK
86+
IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this
87+
License. No license to the Original Work is granted by this License except
88+
under this disclaimer.
89+
90+
8) Limitation of Liability. Under no circumstances and under no legal theory,
91+
whether in tort (including negligence), contract, or otherwise, shall the
92+
Licensor be liable to anyone for any indirect, special, incidental, or
93+
consequential damages of any character arising as a result of this License or
94+
the use of the Original Work including, without limitation, damages for loss
95+
of goodwill, work stoppage, computer failure or malfunction, or any and all
96+
other commercial damages or losses. This limitation of liability shall not
97+
apply to the extent applicable law prohibits such limitation.
98+
99+
9) Acceptance and Termination. If, at any time, You expressly assented to this
100+
License, that assent indicates your clear and irrevocable acceptance of this
101+
License and all of its terms and conditions. If You distribute or communicate
102+
copies of the Original Work or a Derivative Work, You must make a reasonable
103+
effort under the circumstances to obtain the express assent of recipients to
104+
the terms of this License. This License conditions your rights to undertake
105+
the activities listed in Section 1, including your right to create Derivative
106+
Works based upon the Original Work, and doing so without honoring these terms
107+
and conditions is prohibited by copyright law and international treaty.
108+
Nothing in this License is intended to affect copyright exceptions and
109+
limitations (including "fair use" or "fair dealing"). This License shall
110+
terminate immediately and You may no longer exercise any of the rights granted
111+
to You by this License upon your failure to honor the conditions in Section
112+
1(c).
113+
114+
10) Termination for Patent Action. This License shall terminate automatically
115+
and You may no longer exercise any of the rights granted to You by this
116+
License as of the date You commence an action, including a cross-claim or
117+
counterclaim, against Licensor or any licensee alleging that the Original Work
118+
infringes a patent. This termination provision shall not apply for an action
119+
alleging patent infringement by combinations of the Original Work with other
120+
software or hardware.
121+
122+
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this
123+
License may be brought only in the courts of a jurisdiction wherein the
124+
Licensor resides or in which Licensor conducts its primary business, and under
125+
the laws of that jurisdiction excluding its conflict-of-law provisions. The
126+
application of the United Nations Convention on Contracts for the
127+
International Sale of Goods is expressly excluded. Any use of the Original
128+
Work outside the scope of this License or after its termination shall be
129+
subject to the requirements and penalties of copyright or patent law in the
130+
appropriate jurisdiction. This section shall survive the termination of this
131+
License.
132+
133+
12) Attorneys' Fees. In any action to enforce the terms of this License or
134+
seeking damages relating thereto, the prevailing party shall be entitled to
135+
recover its costs and expenses, including, without limitation, reasonable
136+
attorneys' fees and costs incurred in connection with such action, including
137+
any appeal of such action. This section shall survive the termination of this
138+
License.
139+
140+
13) Miscellaneous. If any provision of this License is held to be
141+
unenforceable, such provision shall be reformed only to the extent necessary
142+
to make it enforceable.
143+
144+
14) Definition of "You" in This License. "You" throughout this License,
145+
whether in upper or lower case, means an individual or a legal entity
146+
exercising rights under, and complying with all of the terms of, this License.
147+
For legal entities, "You" includes any entity that controls, is controlled by,
148+
or is under common control with you. For purposes of this definition,
149+
"control" means (i) the power, direct or indirect, to cause the direction or
150+
management of such entity, whether by contract or otherwise, or (ii) ownership
151+
of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
152+
ownership of such entity.
153+
154+
15) Right to Use. You may use the Original Work in all ways not otherwise
155+
restricted or conditioned by this License or by law, and Licensor promises not
156+
to interfere with or be responsible for such uses by You.
157+
158+
16) Modification of This License. This License is Copyright © 2005 Lawrence
159+
Rosen. Permission is granted to copy, distribute, or communicate this License
160+
without modification. Nothing in this License permits You to modify this
161+
License as applied to the Original Work or to Derivative Works. However, You
162+
may modify the text of this License and copy, distribute or communicate your
163+
modified version (the "Modified License") and apply it to other original works
164+
of authorship subject to the following conditions: (i) You may not indicate in
165+
any way that your Modified License is the "Academic Free License" or "AFL" and
166+
you may not use those names in the name of your Modified License; (ii) You
167+
must replace the notice specified in the first paragraph above with the notice
168+
"Licensed under <insert your license name here>" or with a notice of your own
169+
that is not confusingly similar to the notice in this License; and (iii) You
170+
may not claim that your original works are open source software unless your
171+
Modified License has been approved by Open Source Initiative (OSI) and You
172+
comply with its license review and certification process.

README.md

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,114 @@
11
# Drone Base Framework
22

3+
[![Ubuntu](https://github.com/SpaceTime-Vision-Robotics-Laboratory/drone-base/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/SpaceTime-Vision-Robotics-Laboratory/drone-base/actions/workflows/ubuntu.yml)
4+
[![Ruff Linter](https://github.com/SpaceTime-Vision-Robotics-Laboratory/drone-base/actions/workflows/ruff_linter.yml/badge.svg)](https://github.com/SpaceTime-Vision-Robotics-Laboratory/drone-base/actions/workflows/ruff_linter.yml)
5+
6+
[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/)
7+
[![License: AFL-3.0](https://img.shields.io/badge/License-AFL3.0-yellow.svg)](https://opensource.org/license/afl-3-0-php)
8+
39
A modular base framework for building drone control systems using Anafi Parrot drones.
410

511
It is designed to be used as a git submodule in drone software projects.
612

713
### Features
14+
815
- Abstraction over drone states, control and streaming.
916
- Extensible for integrating custom modules
1017
- Lightweight and focused on real-time.
1118

19+
## Installation
20+
1221
### Submodule Installation
22+
1323
To include this framework in your project:
24+
1425
```bash
1526
git submodule add git@github.com:SpaceTime-Vision-Robotics-Laboratory/drone-base.git
1627
git submodule update --init --recursive
1728
```
1829

1930
To clone a project that already includes this as a submodule:
31+
2032
```bash
2133
git clone --recurse-submodules <LINK TO YOUR PROJECT>
2234
```
2335

36+
**Note:** We recommend placing it under `external/` or `libs/` for better structure.
37+
38+
Don't forget to update the submodule often:
39+
40+
```bash
41+
git submodule update --remote external/drone_base
42+
```
43+
44+
**Note:** PyCharm users should mark the **drone_base** directory as sources root for the submodule for
45+
intellisense to work.
46+
47+
To install it via pip you can:
48+
49+
```bash
50+
python -m pip install -e ./external/drone_base
51+
```
52+
2453
### Setup as standalone
54+
2555
Install the packages from the [requirements.txt](requirements.txt).
2656

57+
Can then install it via pip with:
58+
59+
```bash
60+
python -m pip install -e .
61+
```
62+
63+
## Getting started
64+
65+
### Movement Keys
66+
67+
| Key | Action |
68+
|-----|-----------------|
69+
| i | Move forward |
70+
| k | Move backward |
71+
| j | Move right |
72+
| l | Move left |
73+
| o | Rotate right |
74+
| u | Rotate left |
75+
| n | Increase height |
76+
| m | Decrease height |
77+
78+
### Command Keys
79+
80+
| Key | Action |
81+
|-----|--------------------------------------------|
82+
| q | Stop the drone |
83+
| t | Start take off |
84+
| y | Land the drone |
85+
| p | Take a photo |
86+
| z | Reset the gimbal camera position |
87+
| x | Tilt the gimbal camera position 30 degrees |
88+
| c | Tilt the gimbal camera position 90 degrees |
89+
90+
## Example of usages:
91+
92+
Run the example [controller](examples/display_only_controller.py) that only displays the video stream from the drone and
93+
has keyboard control.
2794

28-
### Examples
29-
Run the example [controller](examples/display_only_controller.py) that only displays the video stream from the drone and has keyboard control.
3095
```bash
3196
python -m examples.display_only_controller
3297
```
3398

34-
Run the [video to frame](main/stream/saving/frames_to_video.py) to create a video from the frames generated
99+
Run the [video to frame](drone_base/stream/saving/frames_to_video.py) to create a video from the frames generated
35100
from the video stream of a mission:
101+
36102
```bash
37-
python -m main.stream.saving.frames_to_video
103+
python -m drone_base.stream.saving.frames_to_video
38104
```
39105

106+
## License
107+
108+
This project is licensed under the Academic Free License v3.0 - see the [LICENSE](LICENSE) file for details.
109+
110+
## Acknowledgments
111+
112+
- [Parrot Olympe SDK](https://developer.parrot.com/docs/olympe/index.html#)
113+
- [Parrot Sphinx](https://developer.parrot.com/docs/sphinx/index.html)
114+
- Space Time Vision Robotics Laboratory

drone_base/__init__.py

Whitespace-only changes.

drone_base/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.1.1"

drone_base/config/__init__.py

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ def __post_init__(self):
4848
raise ValueError(f"Time step must be positive, got \"{dt_value}\" instead")
4949
for attr in ("x", "y", "z", "z_rot"):
5050
value = getattr(self, attr)
51-
if not (0 <= value <= 100): # noqa: PLR2004
51+
if not (0 <= value <= 100): # noqa: PLR2004
5252
raise ValueError(f"{attr} must be between [0, 100], got \"{value}\" instead")

0 commit comments

Comments
 (0)