px4-configuration 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: px4-configuration
3
+ Version: 0.1.0
4
+ Summary: Tools and REST API for configuring PX4 from a companion computer
5
+ Author-email: Alex <bonnefond@fly4future.com>
6
+ License: BSD-3-Clause
7
+ Requires-Python: >=3.8
8
+ Requires-Dist: fastapi>=0.104.0
9
+ Requires-Dist: mavsdk==3.0.1
10
+ Requires-Dist: python-multipart>=0.0.6
11
+ Requires-Dist: sse-starlette>=1.6.5
12
+ Requires-Dist: tqdm==4.67.1
13
+ Requires-Dist: uvicorn[standard]>=0.24.0
14
+ Description-Content-Type: text/markdown
15
+
16
+ # px4-configuration
17
+
18
+ Repository that collects scripts to configure and modify PX4 from a companion Linux computer. All tooling is built on top of [MAVSDK-Python](https://github.com/mavlink/MAVSDK-Python).
19
+
20
+ ## Installation
21
+
22
+ ### Development Installation
23
+
24
+ ```bash
25
+ # Optional: create a virtual environment
26
+ python3 -m venv .venv
27
+ source .venv/bin/activate
28
+
29
+ # Install the package (installs all required dependencies)
30
+ pip install -e .
31
+ ```
32
+
33
+ ### Building a Wheel Package
34
+
35
+ To build a distributable wheel (`.whl`) file:
36
+
37
+ ```bash
38
+ # Install build tools (if not already installed)
39
+ pip install build
40
+
41
+ # Build the wheel package
42
+ python -m build --wheel
43
+
44
+ # The wheel file will be created in the dist/ directory
45
+ # Example: dist/px4_configuration-0.1.0-py3-none-any.whl
46
+ ```
47
+
48
+ To build both wheel and source distribution:
49
+
50
+ ```bash
51
+ python -m build
52
+ ```
53
+
54
+ **Installing from a built wheel:**
55
+
56
+ ```bash
57
+ # Install from the wheel file
58
+ pip install dist/px4_configuration-0.1.0-py3-none-any.whl
59
+ ```
60
+
61
+ ## Requirements
62
+
63
+ - Python 3.8+
64
+ - PX4 flight controller connected over serial (e.g. `/dev/pixhawk`)
65
+ - User added to the `dialout` group for serial access (`sudo usermod -aG dialout $USER`)
66
+
67
+ ## Scripts
68
+
69
+ _All scripts use a serial connection to talk to PX4._
70
+
71
+ - `scripts/calibrate.py` – run gyro, accel, mag, level and (future) ESC calibration
72
+ - `scripts/set-params.py` – bulk upload parameters from `.params` files in `configs/`
73
+ - `scripts/upload-sdcard-config.py` – upload files (e.g. `extras.txt`) to the PX4 SD card via MAVLink FTP
74
+ - `scripts/shell.py` – open an interactive PX4 NSH shell session over MAVLink
75
+ - `scripts/px_uploader.py` – PX4 firmware uploader (original PX4 script, unverified here)
76
+
77
+ ## REST API (FastAPI)
78
+
79
+ The companion computer can expose the same functionality through a REST API located in `px4_configuration/api/`.
80
+
81
+ ### Run the API server
82
+
83
+ ```bash
84
+ # Using the packaged console script
85
+ px4-config-api --host 0.0.0.0 --port 8000
86
+
87
+ # Or via the helper module
88
+ python run_api.py
89
+
90
+ # Or directly with uvicorn
91
+ uvicorn px4_configuration.api.main:app --host 0.0.0.0 --port 8000
92
+ ```
93
+
94
+ ### Endpoints
95
+
96
+ - `GET /api/health` – health check
97
+ - `POST /api/calibration/start` – start selected calibrations, returns Server-Sent Events (SSE) with progress
98
+ - `POST /api/params/upload` – upload a `.params` file (multipart form), SSE progress stream
99
+ - `POST /api/sdcard/upload` – upload a file (e.g. `extras.txt`) to the SD card, SSE progress stream
100
+ - `WS /api/shell/connect` – interactive PX4 shell over WebSocket
101
+
102
+ All endpoints accept optional `port` and `baudrate` (defaults `/dev/pixhawk`, `2000000`). SSE responses emit JSON payloads with keys such as `type`, `message`, `progress`, etc.
103
+
104
+ ### Calibration Message Structure
105
+
106
+ The `/api/calibration/start` endpoint returns structured JSON messages via Server-Sent Events (SSE). Each calibration type has a specific message format:
107
+
108
+ #### Accelerometer Calibration
109
+
110
+ ```json
111
+ {
112
+ "type": "accelerometer_progress",
113
+ "progress": 0.17,
114
+ "status_text": "down side result: [0.020 0.819 -9.750]",
115
+ "pending_orientations": ["back", "front", "left", "right", "up"],
116
+ "current_orientation": "down",
117
+ "current_message": "measuring",
118
+ "result": [0.020, 0.819, -9.750],
119
+ "is_complete": false
120
+ }
121
+ ```
122
+
123
+ **Fields:**
124
+ - `pending_orientations`: List of remaining orientations to measure (e.g., `["back", "front", "left", "right", "up"]`)
125
+ - `current_orientation`: Currently detected orientation being measured (e.g., `"down"`, `"left"`)
126
+ - `current_message`: Instruction type - `"hold_still"`, `"rest_detected"`, `"measuring"`, `"rotate"`, `"orientation_detected"`, `"already_completed"`, `"complete"`
127
+ - `progress`: Progress value (0.0 to 1.0)
128
+ - `result`: Measurement result array `[x, y, z]` when available
129
+ - `is_complete`: Boolean indicating completion
130
+
131
+ **Completion message:**
132
+ ```json
133
+ {
134
+ "type": "accelerometer_complete",
135
+ "message": "Accelerometer calibration finished",
136
+ "is_complete": true
137
+ }
138
+ ```
139
+
140
+ #### Magnetometer Calibration
141
+
142
+ ```json
143
+ {
144
+ "type": "magnetometer_progress",
145
+ "progress": 0.33,
146
+ "status_text": "right orientation detected",
147
+ "pending_orientations": ["back", "front", "left", "up"],
148
+ "current_orientation": "right",
149
+ "current_message": "orientation_detected",
150
+ "is_complete": false
151
+ }
152
+ ```
153
+
154
+ **Fields:**
155
+ - `pending_orientations`: List of remaining orientations to measure
156
+ - `current_orientation`: Currently detected orientation
157
+ - `current_message`: Instruction type - `"rotate"`, `"hold_still"`, `"rest_detected"`, `"motion_detected"`, `"orientation_detected"`, `"already_completed"`, `"complete"`
158
+ - `progress`: Progress value (0.0 to 1.0) that increments during rotation
159
+ - `is_complete`: Boolean indicating completion (true when progress >= 1.0)
160
+
161
+ **Completion message:**
162
+ ```json
163
+ {
164
+ "type": "magnetometer_complete",
165
+ "message": "Magnetometer calibration finished",
166
+ "is_complete": true
167
+ }
168
+ ```
169
+
170
+ #### Gyroscope Calibration
171
+
172
+ ```json
173
+ {
174
+ "type": "gyroscope_progress",
175
+ "progress": 0.5,
176
+ "status_text": null,
177
+ "current_message": "calibrating",
178
+ "is_complete": false
179
+ }
180
+ ```
181
+
182
+ **Fields:**
183
+ - `progress`: Progress value (0.0 to 1.0)
184
+ - `current_message`: `"calibrating"` during progress, `"complete"` when done
185
+ - `is_complete`: Boolean indicating completion (true when progress >= 1.0)
186
+
187
+ **Completion message:**
188
+ ```json
189
+ {
190
+ "type": "gyroscope_complete",
191
+ "message": "Gyroscope calibration finished",
192
+ "is_complete": true
193
+ }
194
+ ```
195
+
196
+ #### Level Horizon Calibration
197
+
198
+ ```json
199
+ {
200
+ "type": "horizon_progress",
201
+ "progress": 0.4,
202
+ "status_text": null,
203
+ "current_message": "calibrating",
204
+ "is_complete": false
205
+ }
206
+ ```
207
+
208
+ **Fields:**
209
+ - `progress`: Progress value (0.0 to 1.0)
210
+ - `current_message`: `"calibrating"` during progress, `"complete"` when done
211
+ - `is_complete`: Boolean indicating completion (true when progress >= 1.0)
212
+
213
+ **Completion message:**
214
+ ```json
215
+ {
216
+ "type": "horizon_complete",
217
+ "message": "Level horizon calibration finished",
218
+ "is_complete": true
219
+ }
220
+ ```
221
+
222
+ #### Status Messages
223
+
224
+ General status messages are also emitted:
225
+ ```json
226
+ {
227
+ "type": "status",
228
+ "message": "Starting accelerometer calibration..."
229
+ }
230
+ ```
231
+
232
+ ```json
233
+ {
234
+ "type": "error",
235
+ "message": "Calibration failed: <error details>"
236
+ }
237
+ ```
238
+
239
+ ```json
240
+ {
241
+ "type": "success",
242
+ "message": "All calibrations completed"
243
+ }
244
+ ```
245
+
246
+ ## Notes
247
+
248
+ - Ensure the vehicle is disarmed and stationary before running calibration or parameter uploads.
249
+ - The API and scripts require serial access; add your user to the `dialout` group if needed.
250
+ - Example parameter files and `extras.txt` live under the `configs/` directory.
251
+
252
+
@@ -0,0 +1,17 @@
1
+ px4_configuration/__init__.py,sha256=U0jqmbB8mDtIQ_ZPVjfHzoF7b9EM1TFJQRWEJ49Vk1I,334
2
+ px4_configuration/api/__init__.py,sha256=o0txTrY6RjO1ehOJGtMerrVMm0QR1E4PiutPhoKtmZo,137
3
+ px4_configuration/api/config.py,sha256=imb6qv75ye_DE4t7kbf7xbxWPvy3Yota95keVjg1c5A,562
4
+ px4_configuration/api/main.py,sha256=YkEJWPBBeXxzsHEp2CK3QNk0_yH1fHDfUkzCYbvWO6I,8347
5
+ px4_configuration/api/models.py,sha256=Wi0eWsfqd4noxSPgIN4yUnKGdoncBwkmlSvCs6HAsbE,3552
6
+ px4_configuration/api/services/__init__.py,sha256=U91RCGMiGcIQqtbnzscfNbWpFw65ZNz0DKabCPtTGMw,163
7
+ px4_configuration/api/services/calibration_service.py,sha256=yLlSd3ePe4zOrb4hdXdiwVRiZ5u1f-ACO1-eiyocFSU,4076
8
+ px4_configuration/api/services/health_service.py,sha256=3rNGRfy0GvwnQ_OMD4jU5qm-O2_YDOnfVg_AGS3Fcl4,4457
9
+ px4_configuration/api/services/param_service.py,sha256=95Ee5v3rEGjXiW2LJURTUHXqtxBl2JomV_tMcLwGjac,5201
10
+ px4_configuration/api/services/sdcard_service.py,sha256=6bnMTcaHddo8ZOsrKtl39V518MBO_Z-2fXFT4PTLT5M,2643
11
+ px4_configuration/api/services/shell_service.py,sha256=A_28vCxWyc6e-Usf3QLHqCy5Auf7tyGwqySQ5E5LO1s,2096
12
+ px4_configuration/api/utils/__init__.py,sha256=KR-_U6nAXr8V1uxsB1hCFXPxKYYEwbf096kvhhUJfFk,54
13
+ px4_configuration/api/utils/calibration_parser.py,sha256=ARn702mhz16gJV3gw0-HvFQmUSNCMbohwxTAtcs06GQ,9821
14
+ px4_configuration-0.1.0.dist-info/METADATA,sha256=UwD5N14cWtJvxQqU7QgW56l3d05KwcV6lbPp0ZJkulM,6968
15
+ px4_configuration-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ px4_configuration-0.1.0.dist-info/entry_points.txt,sha256=mBRa68p2qL9HPLE9nCruYZDtTmuDOhFIbkY_nwX-WTc,67
17
+ px4_configuration-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ px4-config-api = px4_configuration.api.main:main