Source Code Management
Last updated
Last updated
The PX4 project uses a three-branch Git branching model:
is by default unstable and sees rapid development.
has been thoroughly tested. It's intended for flight testers.
points to the last release.
We try to retain a and avoid the . However, due to the global team and fast moving development we might resort to merges at times.
To contribute new functionality, , then the repository, , add your , and finally . Changes will be merged when they pass our tests.
All code contributions have to be under the permissive and all code must not impose any further constraints on the use.
PX4 uses the , with the following (minimal) modifications:
:::note Not all PX4 source code matches the style guide, but any new code that you write should do so — in both new and existing files. If you update an existing file you are not required to make the whole file comply with the style guide, just the code you've modified. :::
Tabs are used for indentation (equivalent to 8 spaces).
Spaces are used for alignment.
Maximum line length is 120 characters.
Source files use extension *.cpp
instead of *.cc
.
lowerCamelCase()
is used for functions and methods to visually distinguish them from ClassConstructors()
and ClassNames
.
zero spaces before public:
, private:
, or protected:
keywords.
PX4 developers are encouraged to create appropriate in-source documentation.
:::note Source-code documentation standards are not enforced, and the code is currently inconsistently documented. We'd like to do better! :::
Currently we have two types of source-based documentation:
We encourage other in-source documentation where it adds value/is not redundant.
:::tip Developers should name C++ entities (classes, functions, variables etc.) such that their purpose can be inferred - reducing the need for explicit documentation. :::
Do not add documentation that can trivially be inferred from C++ entity names.
ALWAYS specify units of variables, constants, and input/return parameters where they are defined.
Commonly you may want to add information about corner cases and error handling.
Please avoid "magic numbers", for example, where does this number in the conditional come from? What about the multiplier on yaw stick input?
Instead, define the numbers as named constants with appropriate context in the header:
and update the source implementation.
Please use descriptive, multi-paragraph commit messages for all non-trivial changes. Structure them well so they make sense in the one-line summary but also provide full detail.
Use git commit -s
to sign off on all of your commits. This will add signed-off-by:
with your name and email as the last line.
The description should include:
An overview of what the changes deliver; enough to understand the broad purpose of the code
Links to related issues or supporting information.
Information about what testing of the PR funcitonality has been done, with links to flight logs.
PRINT_MODULE_*
methods are used for both module run time usage instructions and for the in this guide.
The API is documented .
Good examples of usage include the and the files linked from the modules reference.
tags should be used if documentation is needed: @class
, @file
, @param
, @return
, @brief
, @var
, @see
, @note
. A good example of usage is .
This commit guide is based on best practices for the Linux Kernel and other by Linus Torvalds.
Github are the primary mechanism used to submit new functionality and bug fixes to PX4.
They include the new set of in your branch (relative the main branch), and a description of the changes.
Where possible, the results from general both before and after the change.