Skip to content

Commit 4ec1586

Browse files
committed
IMPROVEMENT: update the architecture document
1 parent 01c3505 commit 4ec1586

File tree

2 files changed

+168
-64
lines changed

2 files changed

+168
-64
lines changed

ARCHITECTURE.md

Lines changed: 144 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,156 @@
1-
# Software architecture
1+
# Development guide
22
<!--
33
SPDX-FileCopyrightText: 2024 Amilcar do Carmo Lucas <[email protected]>
44
55
SPDX-License-Identifier: GPL-3.0-or-later
66
-->
77

8-
Before we decided on a software architecture or programming language or toolkit we gathered software requirements as presented below.
9-
10-
## Software requirements
11-
12-
The goal of this software is to automate some of the tasks involved in configuring and tuning an ArduPilot-based vehicle.
13-
The method it follows is explained in the [How to methodically tune any ArduCopter](https://ardupilot.github.io/MethodicConfigurator/TUNING_GUIDE_ArduCopter).
14-
This list of functionalities provides a comprehensive overview of the software's capabilities and can serve as a starting point for further development and refinement.
15-
16-
### 1. Parameter Configuration Management
17-
18-
- The software must allow users to view and manage drone parameters.
19-
- Users should be able to select an intermediate parameter file from a list of available files.
20-
- The software must display a table of parameters with columns for the parameter name, current value, new value, unit, upload to flight controller, and change reason.
8+
The goal *ArduPilot methodic Configurator* software is to automate some of the tasks involved in configuring and tuning ArduPilot-based vehicles.
9+
To develop the software the [standard V-Model software development method](https://en.wikipedia.org/wiki/V-model_(software_development)) was first used.
10+
It was augmented with [DevOps](https://en.wikipedia.org/wiki/DevOps) and [CI/CD automation](https://en.wikipedia.org/wiki/CI/CD) practices at a later stage.
11+
12+
## V-model
13+
14+
### Requirements analysis
15+
16+
We collected and analyzed the needs of the ArduPilot users:
17+
18+
- guidelines on how to correctly build the vehicle, many users are not aware of the hardware basics.
19+
- a non-trial and error approach to set the [1300 ArduPilot parameters](https://ardupilot.org/copter/docs/parameters.html)
20+
- a clear sequence of steps to take to configure the vehicle
21+
- a way to save and load the configuration for later use
22+
- a way to document how decisions where made during the configuration process
23+
- to be able to not repeat errors
24+
- to be able to reproduce the configuration on another similar bit different vehicle
25+
- to understand why decisions where made and their implications
26+
27+
Then we developed, documented and tested the *clear sequence of steps to take to configure the vehicle* in the
28+
[How to methodically tune any ArduCopter](https://ardupilot.github.io/MethodicConfigurator/TUNING_GUIDE_ArduCopter) guide.
29+
Once that was mostly done we proceeded with *system design* the next step of the V-model.
30+
31+
### System design
32+
33+
To automate the steps and processes in the [How to methodically tune any ArduCopter](https://ardupilot.github.io/MethodicConfigurator/TUNING_GUIDE_ArduCopter) guide
34+
the following system design requirements were derived:
35+
36+
#### 1. Parameter Configuration Management
37+
38+
- The software must allow users to view parameter values
39+
- The software must allow users to change parameter values
40+
- For each step in the configuration sequence there must be a "partial/intermediate" parameter file
41+
- The "partial/intermediate" parameter files must have meaningful names
42+
- The sequence of the "partial/intermediate" parameter files must be clear
43+
- Users should be able to upload all parameters from a "partial/intermediate" parameter file to the flight controller and advance to the next intermediate parameter file.
44+
- Users should be able to upload a subset of parameters from a "partial/intermediate" parameter file to the flight controller and advance to the next intermediate parameter file.
45+
- Users should be able to select a "partial/intermediate" parameter file from a list of available files and select the one to be used.
46+
- The software must display a table of parameters with columns for:
47+
- the parameter name,
48+
- current value,
49+
- new value,
50+
- unit,
51+
- upload to flight controller,
52+
- and change reason.
2153
- The software must validate the new parameter values and handle out-of-bounds values gracefully, reverting to the old value if the user chooses not to use the new value.
2254
- The software must save parameter changes to both the flight controller and the intermediate parameter files
2355

24-
### 2. Communication Protocols
56+
#### 2. Communication Protocols
2557

26-
- The software must support communication with the drone's flight controller using MAVlink and FTP over MAVLink protocols.
27-
- The software must handle the encoding and decoding of messages according to the specified protocols.
28-
- The software must allow users to tune drone parameters.
29-
- Users should be able to upload selected parameters to the flight controller and advance to the next intermediate parameter file.
30-
- The software must provide a mechanism to reset the ArduPilot if required by the changes made to the parameters.
31-
- The software must make sure the parameter change communication worked by re-downloading and validating that the parameter changed on the vehicle.
58+
- The software must support communication with the drone's flight controller using [MAVlink](https://mavlink.io/en/).
59+
- Use either [parameter protocol](https://mavlink.io/en/services/parameter.html) or [FTP-over-MAVLink](https://mavlink.io/en/services/ftp.html) protocols.
60+
- The software must automatically reset the ArduPilot if required by the changes made to the parameters.
61+
- parameters ending in "_TYPE", "_EN", "_ENABLE", "SID_AXIS" require a reset after being changed
62+
- The software must automatically validate if the parameter was correctly uploaded to the flight controller
63+
- It must re-upload any parameters that failed to be uploaded correctly
64+
- The software must manage the connection to the flight controller, including establishing, maintaining, and closing the connection.
65+
- Users should be able to reconnect to the flight controller if the connection is lost.
3266

33-
### 4. User Interface
67+
#### 3. User Interface
3468

3569
- The software must provide a user-friendly interface with clear navigation and controls.
3670
- The interface must be responsive and adapt to different screen sizes and resolutions.
3771
- Users should be able to toggle between showing only changed parameters and showing all parameters.
38-
- The software must provide feedback to the user, such as success or error messages, when performing actions like uploading parameters to the flight controller.
3972
- Users should be able to skip to the next parameter file without uploading changes.
4073
- The software must ensure that all changes made to entry widgets are processed before proceeding with other actions, such as uploading parameters to the flight controller.
4174
- Read-only parameters are displayed in red, Sensor Calibrations are displayed in yellow and non-existing parameters in blue
4275
- Users should be able to edit the new value for each parameter directly in the table.
4376
- Users should be able to edit the reason changed for each parameter directly in the table.
44-
- The software must provide tooltips for each parameter to explain their purpose and usage.
77+
- The software must perform efficiently, with minimal lag or delay in response to user actions.
4578

46-
### 5. Documentation and Help
79+
#### 4. Documentation and Help
4780

4881
- The software must include comprehensive documentation and help resources.
49-
- Users should be able to access a blog post or other resources for more information on the software and its usage.
82+
- The software must provide tooltips for each GUI widget.
83+
- The software must provide tooltips for each parameter to explain their purpose and usage.
84+
- Users should be able to access the blog post and other resources for more information on the software and its usage.
5085

51-
### 6. Error Handling and Logging
86+
#### 5. Error Handling and Logging
5287

88+
- The software must provide feedback to the user, such as success or error messages, after each action.
5389
- The software must handle errors gracefully and provide clear error messages to the user.
54-
- The software must log events and errors for debugging and auditing purposes.
55-
56-
### 7. Connection Management
90+
- The software must log events and errors for debugging and auditing purposes to the console.
5791

58-
- The software must manage the connection to the flight controller, including establishing, maintaining, and closing the connection.
59-
- Users should be able to reconnect to the flight controller if the connection is lost.
60-
61-
### 8. Parameter File Management
92+
#### 6. Parameter File Management
6293

6394
- The software must support the loading and parsing of parameter files.
64-
- Users should be able to navigate through different parameter files and select the one to be used.
6595
- Comments are first-class citizens and are preserved when reading/writing files
6696
- The software must write at the end of the configuration the following summary files:
6797
- Complete flight controller *reason changed* annotated parameters in `complete.param` file
6898
- Non-default, read-only *reason changed* annotated parameters in, `non-default_read-only.param` file
6999
- Non-default, writable calibrations *reason changed* annotated parameters in `non-default_writable_calibrations.param` file
70100
- Non-default, writable non-calibrations *reason changed* annotated parameters in `non-default_writable_non-calibrations.param` file
71101

72-
### 9. Customization and Extensibility
102+
#### 7. Customization and Extensibility
73103

74104
- The software must be extensible to support new drone models and parameter configurations.
75105
- Users should be able to customize the software's behavior through configuration files:
76106
- `configuration_steps_ArduCopter.json`, `configuration_steps_ArduPlane.json`, etc
77107
- `vehicle_components.json`
78108
- intermediate parameter files (`*.param`)
109+
110+
#### 8. Automation of development processes
111+
112+
- As many of the development processes should be automated as possible
79113
- Development should use industry best practices:
114+
- Use git as version control and host the project on [ArduPilot GitHub repository](https://github.com/ArduPilot/MethodicConfigurator)
115+
- Start with a V-Model development until feature completeness, then switch to DevOps ASAP.
80116
- [Test-driven development](https://en.wikipedia.org/wiki/Test-driven_development) (TDD)
81117
- [DevOps](https://en.wikipedia.org/wiki/DevOps)
118+
- [CI/CD automation](https://en.wikipedia.org/wiki/CI/CD)
119+
- git pre-commit hooks for code linting and other code quality checks
82120

83-
### 10. Performance and Efficiency
121+
### The Software architecture
84122

85-
- The software must perform efficiently, with minimal lag or delay in response to user actions.
86-
- The software must be optimized for performance, especially when handling large numbers of parameters.
123+
We decided to use python as programming language, and the following libraries and frameworks:
87124

88-
## The Software architecture
125+
- [pymavlink](https://github.com/ArduPilot/pymavlink) for the flight controller communication
126+
- [tkinter](https://docs.python.org/3/library/tkinter.html) for the graphical user interface
127+
- `po` files to translate the software to other languages
89128

90-
To satisfy the software requirements described above the following software architecture was developed:
129+
To satisfy the system design requirements described above the following software architecture was developed:
91130

92131
It consists of four main components:
93132

94133
1. the application itself does the command line parsing and starts the other processes
95-
1. [`ardupilot_methodic_configurator.py`](MethodicConfigurator/ardupilot_methodic_configurator.py)
96-
2. [`common_arguments.py`](MethodicConfigurator/common_arguments.py)
97-
3. [`version.py`](MethodicConfigurator/version.py)
134+
1. [`__main__.py`](ardupilot_methodic_configurator/__main__.py)
135+
2. [`common_arguments.py`](ardupilot_methodic_configurator/common_arguments.py)
136+
3. [`__init.py__`](ardupilot_methodic_configurator/__init__.py)
98137
2. the local filesystem backend does file I/O on the local file system. Operates mostly on parameter files and metadata/documentation files
99-
1. [`backend_filesystem.py`](MethodicConfigurator/backend_filesystem.py)
100-
2. [`backend_filesystem_vehicle_components.py`](MethodicConfigurator/backend_filesystem_vehicle_components.py)
101-
3. [`backend_filesystem_configuration_steps.py`](MethodicConfigurator/backend_filesystem_configuration_steps.py)
138+
1. [`backend_filesystem.py`](ardupilot_methodic_configurator/backend_filesystem.py)
139+
2. [`backend_filesystem_vehicle_components.py`](ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py)
140+
3. [`backend_filesystem_configuration_steps.py`](ardupilot_methodic_configurator/backend_filesystem_configuration_steps.py)
102141
3. the flight controller backend communicates with the flight controller
103-
1. [`backend_flight_controller.py`](MethodicConfigurator/backend_flight_controller.py)
104-
2. [`backend_mavftp.py`](MethodicConfigurator/backend_mavftp.py)
105-
3. [`param_ftp.py`](MethodicConfigurator/param_ftp.py)
106-
4. [`battery_cell_voltages.py`](MethodicConfigurator/battery_cell_voltages.py)
142+
1. [`backend_flight_controller.py`](ardupilot_methodic_configurator/backend_flight_controller.py)
143+
2. [`backend_mavftp.py`](ardupilot_methodic_configurator/backend_mavftp.py)
144+
3. [`param_ftp.py`](ardupilot_methodic_configurator/param_ftp.py)
145+
4. [`battery_cell_voltages.py`](ardupilot_methodic_configurator/battery_cell_voltages.py)
107146
4. the tkinter frontend, which is the GUI the user interacts with
108-
1. [`frontend_tkinter_base.py`](MethodicConfigurator/frontend_tkinter_base.py)
109-
2. [`frontend_tkinter_connection_selection.py`](MethodicConfigurator/frontend_tkinter_connection_selection.py)
110-
3. [`frontend_tkinter_directory_selection.py`](MethodicConfigurator/frontend_tkinter_directory_selection.py)
111-
4. [`frontend_tkinter_component_editor.py`](MethodicConfigurator/frontend_tkinter_component_editor.py)
112-
5. [`frontend_tkinter_component_editor_base.py`](MethodicConfigurator/frontend_tkinter_component_editor_base.py)
113-
6. [`frontend_tkinter_parameter_editor.py`](MethodicConfigurator/frontend_tkinter_parameter_editor.py)
114-
7. [`frontend_tkinter_parameter_editor_table.py`](MethodicConfigurator/frontend_tkinter_parameter_editor_table.py)
147+
1. [`frontend_tkinter_base.py`](ardupilot_methodic_configurator/frontend_tkinter_base.py)
148+
2. [`frontend_tkinter_connection_selection.py`](ardupilot_methodic_configurator/frontend_tkinter_connection_selection.py)
149+
3. [`frontend_tkinter_directory_selection.py`](ardupilot_methodic_configurator/frontend_tkinter_directory_selection.py)
150+
4. [`frontend_tkinter_component_editor.py`](ardupilot_methodic_configurator/frontend_tkinter_component_editor.py)
151+
5. [`frontend_tkinter_component_editor_base.py`](ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py)
152+
6. [`frontend_tkinter_parameter_editor.py`](ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py)
153+
7. [`frontend_tkinter_parameter_editor_table.py`](ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_table.py)
115154

116155
![Software Architecture diagram](images/Architecture.drawio.png)
117156

@@ -121,16 +160,57 @@ They can also be exchanged, for instance, [tkinter-frontend](https://docs.python
121160
In the future, we might port the entire application into a client-based web application.
122161
That way the users would not need to install the software and will always use the latest version.
123162

163+
### Module design
164+
165+
To assure code quality we decided to use Microsoft VS code with a [lot of extensions](SetupDeveloperPc.bat) to lint the code as you type.
166+
We use git [pre-commit](https://pre-commit.com/) hooks to [check the code](.pre-commit-config.yaml) before it is committed to the repository.
167+
168+
### Unit testing
169+
170+
We use [unittest](https://docs.python.org/3/library/unittest.html) to write unit tests for the code.
171+
The tests are easy to run on the command line or in VS code. Tests and coverage report are run automatically in the github CI pipeline.
172+
173+
### Integration testing
174+
175+
The four different sub-applications are first tested independently.
176+
177+
- flight controller connection GUI
178+
- vehicle configuration directory selection GUI
179+
- vehicle component editor GUI
180+
- parameter editor and uploader GUI
181+
182+
Only after each one performs 100% as expected, they are integrated and tested together.
183+
This speeds up the development process.
184+
185+
### System testing
186+
187+
Here the integrated application was tested against the system requirements defined above.
188+
The tests were conducted on windows and linux machines using multiple different flight controllers and firmware versions.
189+
The software is automatically build and distributed using the github CD pipeline.
190+
191+
### Acceptance testing
192+
193+
The software was tested by multiple users with different skill levels, languages, flight controller and backgrounds.
194+
The feedback was used to improve the user interface and user experience.
195+
The software is ready for production use since November 2024.
196+
197+
## DevOps
198+
199+
The software is feature complete and stable with a user base of hundreds of users, we switched from the V-Model to DevOps development process on November 2024.
200+
This provides faster response to requirements changes and additions.
201+
124202
## Adding a translation
125203

126-
To add a new translation language to the Ardupilot Methodic Configurator, follow the steps below. This process involves creating a new language folder in the locale directory and generating the necessary translation files. You will use the `create_pot_file.py` script to extract the strings that need translation and create a `.pot` file, which serves as a template for the translation.
204+
To add a new translation language to the Ardupilot Methodic Configurator, follow the steps below.
205+
This process involves creating a new language folder in the locale directory and generating the necessary translation files.
206+
You will use the `create_pot_file.py` script to extract the strings that need translation and create a `.pot` file, which serves as a template for the translation.
127207

128208
### 1. Set Up Your Locale Directory
129209

130210
Navigate to the `locale` directory inside your project:
131211

132212
```bash
133-
cd MethodicConfigurator/locale
213+
cd ardupilot_methodic_configurator/locale
134214
```
135215

136216
### 2. Create a New Language Directory
@@ -158,7 +238,7 @@ Ensure you are in the root directory of your project, and execute the following
158238
python create_pot_file.py
159239
```
160240

161-
This will create a file named `MethodicConfigurator.pot` inside the `MethodicConfigurator/locale` directory.
241+
This will create a file named `ardupilot_methodic_configurator.pot` inside the `ardupilot_methodic_configurator/locale` directory.
162242

163243
### 4. Create a New PO File
164244

@@ -167,7 +247,7 @@ Inside your newly created language directory, create a new `.po` file using the
167247
```bash
168248
cd de
169249
mkdir LC_MESSAGES
170-
cp ../MethodicConfigurator.pot LC_MESSAGES/MethodicConfigurator.po
250+
cp ../ardupilot_methodic_configurator.pot LC_MESSAGES/ardupilot_methodic_configurator.po
171251
```
172252

173253
### 5. Bulk translate the strings (optional)
@@ -188,7 +268,7 @@ python insert_translations.py --lang-code=de
188268

189269
### 6. Translate the Strings
190270

191-
Open the `MethodicConfigurator.po` file in a text editor or a specialist translation tool (e.g., [Poedit](https://poedit.net/)). You will see the extracted strings, which you can begin translating.
271+
Open the `ardupilot_methodic_configurator.po` file in a text editor or a specialist translation tool (e.g., [Poedit](https://poedit.net/)). You will see the extracted strings, which you can begin translating.
192272

193273
Each entry will look like this:
194274

@@ -216,7 +296,7 @@ Make sure you have `msgfmt` installed, which is part of the *GNU gettext* packag
216296

217297
### 8. Test the New Language
218298

219-
Now add the language to the end of the `LANGUAGE_CHOICES` array in the `MethodicConfigurator/internationalization.py` file.
299+
Now add the language to the end of the `LANGUAGE_CHOICES` array in the `ardupilot_methodic_configurator/internationalization.py` file.
220300

221301
```python
222302
LANGUAGE_CHOICES = ['en', 'zh_CN', 'pt', 'de']

0 commit comments

Comments
 (0)