|
1 | | -# Contributing to PX4 Firmware |
| 1 | +# Contributing to PX4-Autopilot |
2 | 2 |
|
3 | | -We follow the [Github flow](https://guides.github.com/introduction/flow/) development model. |
| 3 | +We follow the [GitHub flow](https://guides.github.com/introduction/flow/) development model. |
4 | 4 |
|
5 | | -### Fork the project, then clone your repo |
| 5 | +## Fork the project, then clone your repo |
6 | 6 |
|
7 | | -First [fork and clone](https://help.github.com/articles/fork-a-repo) the project project. |
| 7 | +First [fork and clone](https://help.github.com/articles/fork-a-repo) the project. |
8 | 8 |
|
9 | | -### Create a feature branch |
| 9 | +## Create a feature branch |
10 | 10 |
|
11 | | -*Always* branch off main for new features. |
| 11 | +Always branch off `main` for new features. |
12 | 12 |
|
13 | 13 | ``` |
14 | 14 | git checkout -b mydescriptivebranchname |
15 | 15 | ``` |
16 | 16 |
|
17 | | -### Edit and build the code |
| 17 | +## Edit and build the code |
18 | 18 |
|
19 | 19 | The [developer guide](https://docs.px4.io/main/en/development/development.html) explains how to set up the development environment on Mac OS, Linux or Windows. Please take note of our [coding style](https://docs.px4.io/main/en/contribute/code.html) when editing files. |
20 | 20 |
|
21 | | -### Commit your changes |
| 21 | +## Commit message convention |
22 | 22 |
|
23 | | -Always write descriptive commit messages and add a fixes or relates note to them with an [issue number](https://github.com/px4/Firmware/issues) (Github will link these then conveniently) |
| 23 | +PX4 uses [conventional commits](https://www.conventionalcommits.org/) for all commit messages and PR titles. |
24 | 24 |
|
25 | | -**Example:** |
| 25 | +### Format |
26 | 26 |
|
27 | 27 | ``` |
28 | | -Change how the attitude controller works |
| 28 | +type(scope): short description of the change |
| 29 | +``` |
| 30 | + |
| 31 | +| Part | Rule | |
| 32 | +|------|------| |
| 33 | +| **type** | Category of change (see types table below) | |
| 34 | +| **scope** | The module, driver, board, or area of PX4 affected | |
| 35 | +| **`!`** (optional) | Append before `:` to mark a breaking change | |
| 36 | +| **description** | What the change does, at least 5 characters, written in imperative form | |
| 37 | + |
| 38 | +### Types |
| 39 | + |
| 40 | +| Type | Description | |
| 41 | +|------|-------------| |
| 42 | +| `feat` | A new feature | |
| 43 | +| `fix` | A bug fix | |
| 44 | +| `docs` | Documentation only changes | |
| 45 | +| `style` | Formatting, whitespace, no code change | |
| 46 | +| `refactor` | Code change that neither fixes a bug nor adds a feature | |
| 47 | +| `perf` | Performance improvement | |
| 48 | +| `test` | Adding or correcting tests | |
| 49 | +| `build` | Build system or external dependencies | |
| 50 | +| `ci` | CI configuration files and scripts | |
| 51 | +| `chore` | Other changes that don't modify src or test files | |
| 52 | +| `revert` | Reverts a previous commit | |
| 53 | + |
| 54 | +### Scopes |
| 55 | + |
| 56 | +The scope identifies which part of PX4 is affected. Common scopes: |
| 57 | + |
| 58 | +| Scope | Area | |
| 59 | +|-------|------| |
| 60 | +| `ekf2` | Extended Kalman Filter (state estimation) | |
| 61 | +| `mavlink` | MAVLink messaging protocol | |
| 62 | +| `commander` | Commander and mode management | |
| 63 | +| `navigator` | Mission, RTL, Land, and other navigation modes | |
| 64 | +| `sensors` | Sensor drivers and processing | |
| 65 | +| `drivers` | Hardware drivers | |
| 66 | +| `boards/px4_fmu-v6x` | Board-specific changes (use the board name) | |
| 67 | +| `mc_att_control` | Multicopter attitude control | |
| 68 | +| `mc_pos_control` | Multicopter position control | |
| 69 | +| `fw_att_control` | Fixed-wing attitude control | |
| 70 | +| `vtol` | VTOL-specific logic | |
| 71 | +| `actuators` | Mixer and actuator output | |
| 72 | +| `battery` | Battery monitoring and estimation | |
| 73 | +| `logger` | On-board logging | |
| 74 | +| `param` | Parameter system | |
| 75 | +| `simulation` | SITL, Gazebo, SIH | |
| 76 | +| `ci` | Continuous integration and workflows | |
| 77 | +| `docs` | Documentation | |
| 78 | +| `build` | CMake, toolchain, build system | |
| 79 | +| `uorb` | Inter-module messaging | |
| 80 | + |
| 81 | +For changes spanning multiple subsystems, use the primary one affected. Look at the directory path of the files you changed to find the right scope: `src/modules/ekf2/` uses `ekf2`, `src/drivers/imu/` uses `drivers/imu`, `.github/workflows/` uses `ci`. |
| 82 | + |
| 83 | +### Breaking changes |
| 84 | + |
| 85 | +Append `!` before the colon to indicate a breaking change: |
| 86 | + |
| 87 | +``` |
| 88 | +feat(ekf2)!: remove deprecated height fusion API |
| 89 | +``` |
| 90 | + |
| 91 | +### Good commit messages |
| 92 | + |
| 93 | +``` |
| 94 | +feat(ekf2): add height fusion timeout |
| 95 | +fix(mavlink): correct BATTERY_STATUS_V2 parsing |
| 96 | +refactor(navigator): simplify RTL altitude logic |
| 97 | +ci(workflows): migrate to reusable workflows |
| 98 | +docs(ekf2): update tuning guide |
| 99 | +feat(boards/px4_fmu-v6x)!: remove deprecated driver API |
| 100 | +perf(mc_rate_control): reduce loop latency |
| 101 | +``` |
| 102 | + |
| 103 | +### Commits to avoid |
| 104 | + |
| 105 | +These will be flagged by CI and should be squashed or reworded before merging: |
| 106 | + |
| 107 | +``` |
| 108 | +fix # too vague, no type or scope |
| 109 | +update # too vague, no type or scope |
| 110 | +ekf2: fix something # missing type prefix |
| 111 | +apply suggestions from code review # squash into parent commit |
| 112 | +do make format # squash into parent commit |
| 113 | +WIP: trying something # not ready for main |
| 114 | +oops # not descriptive |
| 115 | +``` |
| 116 | + |
| 117 | +### PR titles |
| 118 | + |
| 119 | +The PR title follows the same `type(scope): description` format. This is enforced by CI and is especially important because the PR title becomes the commit message when a PR is squash-merged. |
| 120 | + |
| 121 | +### Merge policy |
| 122 | + |
| 123 | +Commits should be atomic and independently revertable. Squash at reviewer discretion for obvious cases (multiple WIP commits, messy review-response history). When your commits are clean and logical, they will be preserved as individual commits on `main`. |
| 124 | + |
| 125 | +### Cleaning up commits |
| 126 | + |
| 127 | +If CI flags your commit messages, you can fix them with an interactive rebase: |
29 | 128 |
|
30 | | -- Fixes rate feed forward |
31 | | -- Allows a local body rate override |
| 129 | +```bash |
| 130 | +# Squash all commits into one: |
| 131 | +git rebase -i HEAD~N # replace N with the number of commits |
| 132 | +# mark all commits except the first as 'squash' or 'fixup' |
| 133 | +# reword the remaining commit to follow the format |
| 134 | +git push --force-with-lease |
32 | 135 |
|
33 | | -Fixes issue #123 |
| 136 | +# Or reword specific commits: |
| 137 | +git rebase -i HEAD~N |
| 138 | +# mark the bad commits as 'reword' |
| 139 | +git push --force-with-lease |
34 | 140 | ``` |
35 | 141 |
|
36 | | -### Test your changes |
| 142 | +## Test your changes |
37 | 143 |
|
38 | | -Since we care about safety, we will regularly ask you for test results. Best is to do a test flight (or bench test where it applies) and upload the logfile from it (on the microSD card in the logs directory) to Google Drive or Dropbox and share the link. |
| 144 | +Since we care about safety, we will regularly ask you for test results. Best is to do a test flight (or bench test where it applies) and upload the log file from it (on the microSD card in the logs directory) to Google Drive or Dropbox and share the link. |
39 | 145 |
|
40 | | -### Push your changes |
| 146 | +## Push your changes |
41 | 147 |
|
42 | | -Push changes to your repo and send a [pull request](https://github.com/PX4/Firmware/compare/). |
| 148 | +Push changes to your repo and send a [pull request](https://github.com/PX4/PX4-Autopilot/compare/). |
43 | 149 |
|
44 | 150 | Make sure to provide some testing feedback and if possible the link to a flight log file. Upload flight log files to [Flight Review](http://logs.px4.io) and link the resulting report. |
0 commit comments