diff --git a/.clang-tidy b/.clang-tidy index 81f2d62596..9293603c71 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -105,6 +105,89 @@ Checks: '*, -readability-redundant-declaration, -readability-static-accessed-through-instance, -readability-static-definition-in-anonymous-namespace, + -altera-struct-pack-align, + -bugprone-easily-swappable-parameters, + -concurrency-mt-unsafe, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-non-private-member-variables-in-classes, + -hicpp-uppercase-literal-suffix, + -llvm-qualified-auto, + -misc-non-private-member-variables-in-classes, + -misc-use-anonymous-namespace, + -modernize-concat-nested-namespaces, + -readability-const-return-type, + -readability-identifier-length, + -readability-isolate-declaration, + -readability-qualified-auto, + -readability-redundant-access-specifiers, + -cppcoreguidelines-avoid-do-while, + -misc-include-cleaner, + -misc-const-correctness, + -llvm-else-after-return, + -readability-function-cognitive-complexity, + -cppcoreguidelines-init-variables, + -bugprone-reserved-identifier, + -cert-dcl37-c, + -cert-dcl51-cpp, + -modernize-use-nodiscard, + -misc-confusable-identifiers, + -cert-err33-c, + -readability-redundant-inline-specifier, + -readability-uppercase-literal-suffix, + -bugprone-narrowing-conversions, + -cppcoreguidelines-narrowing-conversions, + -bugprone-switch-missing-default-case, + -cppcoreguidelines-avoid-goto, + -hicpp-avoid-goto, + -bugprone-branch-clone, + -bugprone-unhandled-self-assignment, + -cert-oop54-cpp, + -performance-enum-size, + -readability-avoid-nested-conditional-operator, + -cppcoreguidelines-prefer-member-initializer, + -cppcoreguidelines-explicit-virtual-functions, + -cppcoreguidelines-virtual-class-destructor, + -readability-convert-member-functions-to-static, + -readability-make-member-function-const, + -bugprone-assignment-in-if-condition, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-incorrect-roundings, + -bugprone-macro-parentheses, + -bugprone-multi-level-implicit-pointer-conversion, + -bugprone-signed-char-misuse, + -bugprone-too-small-loop-variable, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-use-default-member-init, + -hicpp-multiway-paths-covered, + -hicpp-named-parameter, + -misc-header-include-cycle, + -misc-no-recursion, + -performance-no-int-to-ptr, + -readability-avoid-return-with-void-value, + -readability-avoid-unconditional-preprocessor-if, + -readability-delete-null-pointer, + -readability-duplicate-include, + -readability-redundant-casting, + -readability-redundant-member-init, + -readability-reference-to-constructed-temporary, + -readability-simplify-boolean-expr, + -bugprone-unsafe-functions, + -cert-msc24-c, + -cert-msc32-c, + -cert-msc33-c, + -cert-msc51-cpp, + -cert-str34-c, + -cppcoreguidelines-macro-to-enum, + -modernize-macro-to-enum, + -abseil-string-find-str-contains, + -bugprone-suspicious-include, + -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, + -clang-analyzer-optin.core.EnumCastOutOfRange, + -modernize-type-traits, + -misc-definitions-in-headers, + -bugprone-casting-through-void, + -readability-redundant-string-init, ' WarningsAsErrors: '*' CheckOptions: diff --git a/.github/workflows/build_all_targets.yml b/.github/workflows/build_all_targets.yml index 56e6a6ee1a..4c0bc0fcb9 100644 --- a/.github/workflows/build_all_targets.yml +++ b/.github/workflows/build_all_targets.yml @@ -2,6 +2,37 @@ # - If you want to keep the tests running in GitHub Actions you need to uncomment the "runs-on: ubuntu-latest" lines # and comment the "runs-on: [runs-on,runner=..." lines. # - If you would like to duplicate this setup try setting up "RunsOn" on your own AWS account try https://runs-on.com +# +# =================================================================================== +# RELEASE UPLOAD LOGIC +# =================================================================================== +# This workflow handles building firmware and uploading to S3 + GitHub Releases. +# +# S3 Bucket Structure (s3://px4-travis/Firmware/): +# - master/ <- Latest main branch build (for QGC compatibility) +# - stable/ <- Latest stable release, controlled by 'stable' branch +# - beta/ <- Latest pre-release, controlled by 'beta' branch +# - vX.Y.Z/ <- Archived stable release +# - vX.Y.Z-beta1/ <- Archived pre-release +# +# Trigger Behavior: +# - Tag v1.16.1 -> Upload to: v1.16.1/ only (versioned archive) +# - Tag v1.17.0-beta1 -> Upload to: v1.17.0-beta1/ only (versioned archive) +# - Branch main -> Upload to: master/ (for QGC compatibility) +# - Branch stable -> Upload to: stable/ (QGC stable firmware) +# - Branch beta -> Upload to: beta/ (QGC beta firmware) +# - Branch release/** -> Build only, no S3 upload (CI validation) +# - Pull requests -> Build only, no S3 upload (CI validation) +# +# GitHub Releases: +# - All version tags create a draft GitHub Release +# - Pre-releases (alpha/beta/rc suffixes) are automatically marked as such +# +# IMPORTANT: Version tags do NOT upload to stable/ or beta/. Only the +# corresponding branch pushes control those directories. This prevents +# pre-release tags from accidentally overwriting stable firmware (#26340) +# and avoids race conditions between tag and branch builds. +# =================================================================================== name: Build all targets @@ -29,6 +60,7 @@ concurrency: permissions: contents: write actions: read + packages: read jobs: group_targets: @@ -94,6 +126,9 @@ jobs: fail-fast: false container: image: ${{ matrix.container }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} steps: - uses: runs-on/action@v2 - uses: actions/checkout@v4 @@ -159,6 +194,13 @@ jobs: path: ~/.ccache key: ${{ steps.cc_restore.outputs.cache-primary-key }} + # =========================================================================== + # ARTIFACT UPLOAD JOB + # =========================================================================== + # Uploads build artifacts to S3 and creates GitHub Releases. + # Runs for version tags (v*), main, stable, and beta branch pushes. + # See header comments for full upload logic documentation. + # =========================================================================== artifacts: name: Upload Artifacts # runs-on: ubuntu-latest @@ -177,31 +219,31 @@ jobs: - name: Choose Upload Location id: upload-location run: | - # Determine upload location based on branch or tag with the following considerations: - # Destination: AWS S3 bucket px4-travis in folder Firmware/ - # - If branch is main -> upload to master/ - # - Older versions of QGC are hardocded to look for master/ - # - If branch is stable or beta -> upload to stable/ or beta/ - # - If a tag vX.Y.Z -> upload to vX.Y.Z/ - # - Also update stable/ to point to the same version - #. - Older versions of QGC are hardocded to look for stable/ - # - If a pull request -> do not upload set -euo pipefail ref="${GITHUB_REF}" branch=${{ needs.group_targets.outputs.branchname }} location="$branch" + is_prerelease="false" + # Main branch uploads to "master" for QGC backward compatibility if [[ "$branch" == "main" ]]; then location="master" fi + # Version tags: upload to versioned directory (e.g., v1.16.1/) if [[ "$ref" == refs/tags/v[0-9]* ]]; then tag="${ref#refs/tags/}" location="$tag" + + # Pre-release tags contain -alpha, -beta, or -rc suffix + if [[ "$tag" =~ -(alpha|beta|rc) ]]; then + is_prerelease="true" + fi fi echo "uploadlocation=$location" >> $GITHUB_OUTPUT + echo "is_prerelease=$is_prerelease" >> $GITHUB_OUTPUT - name: Uploading Artifacts to S3 [${{ steps.upload-location.outputs.uploadlocation }}] uses: jakejarvis/s3-sync-action@master @@ -215,28 +257,13 @@ jobs: SOURCE_DIR: artifacts/ DEST_DIR: Firmware/${{ steps.upload-location.outputs.uploadlocation }}/ - # if we are uploading artifacts to a versioned folder - # we should also update the stable folder in the s3 bucket - - name: Uploading Artifacts to S3 [stable] - uses: jakejarvis/s3-sync-action@master - if: startsWith(github.ref, 'refs/tags/v') - with: - args: --acl public-read - env: - AWS_S3_BUCKET: 'px4-travis' - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: 'us-west-1' - SOURCE_DIR: artifacts/ - DEST_DIR: Firmware/stable/ - - # if build is a release triggered by a versioned tag then create a github release - # and upload the build artifacts. A draft release is created so that the release - # can be reviewed before publishing + # Create a draft GitHub Release for all version tags + # Pre-releases are automatically marked as such - name: Upload Artifacts to GitHub Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/v') with: draft: true + prerelease: ${{ steps.upload-location.outputs.is_prerelease == 'true' }} files: artifacts/*.px4 name: ${{ steps.upload-location.outputs.uploadlocation }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 66821d5e17..e43feee8b3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -19,6 +19,10 @@ concurrency: jobs: build: runs-on: ubuntu-latest + + container: + image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556 + strategy: fail-fast: false matrix: @@ -35,20 +39,17 @@ jobs: "px4_sitl_allyes", "module_documentation", ] + steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Building [${{ matrix.check }}] - uses: addnab/docker-run-action@v3 - with: - image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556 - options: -v ${{ github.workspace }}:/workspace - run: | - cd /workspace - git config --global --add safe.directory /workspace - make ${{ matrix.check }} + run: | + cd "$GITHUB_WORKSPACE" + git config --global --add safe.directory "$GITHUB_WORKSPACE" + make ${{ matrix.check }} - name: Uploading Coverage to Codecov.io if: contains(matrix.check, 'coverage') diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index b373c59765..fc3c5a46ea 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -1,4 +1,4 @@ -name: Clang Tidy +name: Static Analysis on: push: @@ -11,20 +11,59 @@ on: - '**' paths-ignore: - 'docs/**' + +permissions: + contents: read + jobs: - build: - runs-on: ubuntu-latest + clang_tidy: + name: Clang-Tidy + runs-on: [runs-on, runner=16cpu-linux-x64, "run-id=${{ github.run_id }}", "extras=s3-cache"] + container: + image: px4io/px4-dev:v1.17.0-beta1 steps: + - uses: runs-on/action@v2 - uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-tags: true - - name: Testing (clang-tidy) - uses: addnab/docker-run-action@v3 + - name: Configure Git Safe Directory + run: git config --system --add safe.directory '*' + + - name: Restore Compiler Cache + id: cc_restore + uses: actions/cache/restore@v4 with: - image: px4io/px4-dev-clang:2021-09-08 - options: -v ${{ github.workspace }}:/workspace - run: | - cd /workspace - git config --global --add safe.directory /workspace - make clang-tidy + path: ~/.ccache + key: ccache-clang-tidy-${{ github.head_ref || github.ref_name }} + restore-keys: | + ccache-clang-tidy-${{ github.head_ref || github.ref_name }}- + ccache-clang-tidy-main- + ccache-clang-tidy- + + - name: Configure Compiler Cache + run: | + mkdir -p ~/.ccache + echo "base_dir = ${GITHUB_WORKSPACE}" > ~/.ccache/ccache.conf + echo "compression = true" >> ~/.ccache/ccache.conf + echo "compression_level = 6" >> ~/.ccache/ccache.conf + echo "max_size = 120M" >> ~/.ccache/ccache.conf + echo "hash_dir = false" >> ~/.ccache/ccache.conf + echo "compiler_check = content" >> ~/.ccache/ccache.conf + ccache -s + ccache -z + + - name: Run Clang-Tidy Analysis + run: make -j16 clang-tidy + + - name: Compiler Cache Stats + if: always() + run: ccache -s + + - name: Save Compiler Cache + if: always() + uses: actions/cache/save@v4 + with: + path: ~/.ccache + key: ${{ steps.cc_restore.outputs.cache-primary-key }} diff --git a/.github/workflows/ekf_functional_change_indicator.yml b/.github/workflows/ekf_functional_change_indicator.yml index d84572386e..11c1970680 100644 --- a/.github/workflows/ekf_functional_change_indicator.yml +++ b/.github/workflows/ekf_functional_change_indicator.yml @@ -15,21 +15,21 @@ concurrency: jobs: unit_tests: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: main test - uses: addnab/docker-run-action@v3 - with: - image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556 - options: -v ${{ github.workspace }}:/workspace + container: + image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: main test run: | - cd /workspace - git config --global --add safe.directory /workspace + cd "$GITHUB_WORKSPACE" + git config --global --add safe.directory "$GITHUB_WORKSPACE" make tests TESTFILTER=EKF - - name: Check if there is a functional change - run: git diff --exit-code - working-directory: src/modules/ekf2/test/change_indication + - name: Check if there is a functional change + run: git diff --exit-code + working-directory: src/modules/ekf2/test/change_indication diff --git a/.github/workflows/ekf_update_change_indicator.yml b/.github/workflows/ekf_update_change_indicator.yml index 991dfd397b..6f6e1dde55 100644 --- a/.github/workflows/ekf_update_change_indicator.yml +++ b/.github/workflows/ekf_update_change_indicator.yml @@ -8,40 +8,47 @@ on: jobs: unit_tests: runs-on: ubuntu-latest + + container: + image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556 + env: GIT_COMMITTER_EMAIL: bot@px4.io GIT_COMMITTER_NAME: PX4BuildBot - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: main test - uses: addnab/docker-run-action@v3 - with: - image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556 - options: -v ${{ github.workspace }}:/workspace + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: main test run: | - cd /workspace - git config --global --add safe.directory /workspace + cd "$GITHUB_WORKSPACE" + git config --global --add safe.directory "$GITHUB_WORKSPACE" make tests TESTFILTER=EKF - - name: Check if there exists diff and save result in variable - id: diff-check - run: echo "CHANGE_INDICATED=$(git diff --exit-code --output=/dev/null || echo $?)" >> $GITHUB_OUTPUT - working-directory: src/modules/ekf2/test/change_indication + - name: Check if there exists diff and save result in variable + id: diff-check + working-directory: src/modules/ekf2/test/change_indication + run: | + if git diff --quiet; then + echo "CHANGE_INDICATED=false" >> $GITHUB_OUTPUT + else + echo "CHANGE_INDICATED=true" >> $GITHUB_OUTPUT + fi - - name: auto-commit any changes to change indication - uses: stefanzweifel/git-auto-commit-action@v4 - with: - file_pattern: 'src/modules/ekf2/test/change_indication/*.csv' - commit_user_name: ${GIT_COMMITTER_NAME} - commit_user_email: ${GIT_COMMITTER_EMAIL} - commit_message: | - '[AUTO COMMIT] update change indication' + - name: auto-commit any changes to change indication + if: steps.diff-check.outputs.CHANGE_INDICATED == 'true' + uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: 'src/modules/ekf2/test/change_indication/*.csv' + commit_user_name: ${{ env.GIT_COMMITTER_NAME }} + commit_user_email: ${{ env.GIT_COMMITTER_EMAIL }} + commit_message: | + [AUTO COMMIT] update change indication - See .github/workflopws/ekf_update_change_indicator.yml for more details + See .github/workflows/ekf_update_change_indicator.yml for more details - - name: if there is a functional change, fail check - if: ${{ steps.diff-check.outputs.CHANGE_INDICATED }} - run: exit 1 + - name: if there is a functional change, fail check + if: steps.diff-check.outputs.CHANGE_INDICATED == 'true' + run: exit 1 diff --git a/.github/workflows/mavros_mission_tests.yml b/.github/workflows/mavros_mission_tests.yml index c5d50109b6..0b1a84f7b3 100644 --- a/.github/workflows/mavros_mission_tests.yml +++ b/.github/workflows/mavros_mission_tests.yml @@ -19,25 +19,27 @@ concurrency: jobs: build: runs-on: ubuntu-latest + strategy: fail-fast: false - matrix: - config: - - {vehicle: "iris", mission: "MC_mission_box"} steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Build SITL and Run Tests - uses: addnab/docker-run-action@v3 - with: - image: px4io/px4-dev-ros-melodic:2021-09-08 - options: -v ${{ github.workspace }}:/workspace + - name: Build SITL and Run Tests (inside old ROS container) run: | - cd /workspace - git config --global --add safe.directory /workspace - make px4_sitl_default - make px4_sitl_default sitl_gazebo-classic - ./test/rostest_px4_run.sh mavros_posix_test_mission.test mission:=${{matrix.config.mission}} vehicle:=${{matrix.config.vehicle}} + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/workspace" \ + -w /workspace \ + px4io/px4-dev-ros-melodic:2021-09-08 \ + bash -c ' + git config --global --add safe.directory /workspace + make px4_sitl_default + make px4_sitl_default sitl_gazebo-classic + ./test/rostest_px4_run.sh \ + mavros_posix_test_mission.test \ + mission:=MC_mission_box \ + vehicle:=iris + ' diff --git a/.github/workflows/mavros_offboard_tests.yml b/.github/workflows/mavros_offboard_tests.yml index 2aaf21e95b..dd6b750812 100644 --- a/.github/workflows/mavros_offboard_tests.yml +++ b/.github/workflows/mavros_offboard_tests.yml @@ -19,27 +19,26 @@ concurrency: jobs: build: runs-on: ubuntu-latest - env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true + strategy: fail-fast: false - matrix: - config: - - {test_file: "mavros_posix_tests_offboard_posctl.test", vehicle: "iris"} steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Build PX4 and Run Tests - uses: addnab/docker-run-action@v3 - with: - image: px4io/px4-dev-ros-melodic:2021-09-08 - options: -v ${{ github.workspace }}:/workspace + - name: Build SITL and Run Tests (inside old ROS container) run: | - cd /workspace - git config --global --add safe.directory /workspace - make px4_sitl_default - make px4_sitl_default sitl_gazebo-classic - ./test/rostest_px4_run.sh ${{matrix.config.test_file}} vehicle:=${{matrix.config.vehicle}} + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/workspace" \ + -w /workspace \ + px4io/px4-dev-ros-melodic:2021-09-08 \ + bash -c ' + git config --global --add safe.directory /workspace + make px4_sitl_default + make px4_sitl_default sitl_gazebo-classic + ./test/rostest_px4_run.sh \ + mavros_posix_tests_offboard_posctl.test \ + vehicle:=iris + ' diff --git a/.github/workflows/nuttx_env_config.yml b/.github/workflows/nuttx_env_config.yml index 791f2fbf4c..f05b456bb6 100644 --- a/.github/workflows/nuttx_env_config.yml +++ b/.github/workflows/nuttx_env_config.yml @@ -19,27 +19,28 @@ concurrency: jobs: build: runs-on: ubuntu-latest + + container: + image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556 + strategy: matrix: - config: [ - px4_fmu-v5_default, - ] + config: + - px4_fmu-v5_default steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Build PX4 and Run Test [${{ matrix.config }}] - uses: addnab/docker-run-action@v3 - with: - image: px4io/px4-dev:v1.16.0-rc1-258-g0369abd556 - options: -v ${{ github.workspace }}:/workspace + - name: Build PX4 and Run Test [${{ matrix.config }}] run: | - cd /workspace - git config --global --add safe.directory /workspace - export PX4_EXTRA_NUTTX_CONFIG="CONFIG_NSH_LOGIN_PASSWORD=\"test\";CONFIG_NSH_CONSOLE_LOGIN=y" + cd "$GITHUB_WORKSPACE" + git config --global --add safe.directory "$GITHUB_WORKSPACE" + export PX4_EXTRA_NUTTX_CONFIG='CONFIG_NSH_LOGIN_PASSWORD="test";CONFIG_NSH_CONSOLE_LOGIN=y' echo "PX4_EXTRA_NUTTX_CONFIG: $PX4_EXTRA_NUTTX_CONFIG" + make ${{ matrix.config }} nuttx_context + echo "Check that the config option is set" grep CONFIG_NSH_LOGIN_PASSWORD build/${{ matrix.config }}/NuttX/nuttx/.config diff --git a/.github/workflows/sitl_tests.yml b/.github/workflows/sitl_tests.yml index 813e78073b..c114b05cb3 100644 --- a/.github/workflows/sitl_tests.yml +++ b/.github/workflows/sitl_tests.yml @@ -33,8 +33,10 @@ jobs: matrix: config: - {model: "iris", latitude: "59.617693", longitude: "-151.145316", altitude: "48", build_type: "RelWithDebInfo" } # Alaska - - {model: "tailsitter" , latitude: "29.660316", longitude: "-82.316658", altitude: "30", build_type: "RelWithDebInfo" } # Florida - - {model: "standard_vtol", latitude: "47.397742", longitude: "8.545594", altitude: "488", build_type: "Coverage" } # Zurich + # VTOL/tailsitter disabled: persistent flaky CI failures (timeouts, erratic + # transitions). Re-enable once the test infrastructure is stabilized. + # - {model: "tailsitter" , latitude: "29.660316", longitude: "-82.316658", altitude: "30", build_type: "RelWithDebInfo" } # Florida + # - {model: "standard_vtol", latitude: "47.397742", longitude: "8.545594", altitude: "488", build_type: "Coverage" } # Zurich steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index 2d33363206..3cbe67acc9 100644 --- a/Makefile +++ b/Makefile @@ -412,7 +412,7 @@ tests: $(call cmake-build,px4_sitl_test) # work around lcov bug #316; remove once lcov is fixed (see https://github.com/linux-test-project/lcov/issues/316) -LCOBUG = --ignore-errors mismatch +LCOBUG = --ignore-errors mismatch,negative tests_coverage: @$(MAKE) clean @$(MAKE) --no-print-directory tests PX4_CMAKE_BUILD_TYPE=Coverage @@ -492,13 +492,29 @@ px4_sitl_default-clang: @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && cmake "$(SRC_DIR)" $(CMAKE_ARGS) -G"$(PX4_CMAKE_GENERATOR)" -DCONFIG=px4_sitl_default -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ @$(PX4_MAKE) -C "$(SRC_DIR)"/build/px4_sitl_default-clang +# Paths to exclude from clang-tidy (auto-generated from .gitmodules + manual additions): +# - All submodules (external code we consume, not edit) +# - Test code (allowed looser style) +# - Example code (educational, not production) +# - Vendored third-party code (e.g., CMSIS_5) +# - NuttX-only drivers excluded at CMake level (mcp_common); I2C-dependent libs excluded here (smbus) +# - GPIO excluded here (NuttX platform headers) +# - Emscripten failsafe web build: source path + Unity build path (failsafe_test.dir) +# because CMake Unity Builds merge sources into a generated .cxx under build/ +# +# To add manual exclusions, append to CLANG_TIDY_EXCLUDE_EXTRA below. +# Submodules are automatically excluded - no action needed when adding new ones. +CLANG_TIDY_SUBMODULES := $(shell git config --file .gitmodules --get-regexp path | awk '{print $$2}' | tr '\n' '|' | sed 's/|$$//') +CLANG_TIDY_EXCLUDE_EXTRA := src/systemcmds/tests|src/examples|src/modules/gyro_fft/CMSIS_5|src/lib/drivers/smbus|src/drivers/gpio|src/modules/commander/failsafe/emscripten|failsafe_test\.dir|\.pb\.cc +CLANG_TIDY_EXCLUDE := $(CLANG_TIDY_SUBMODULES)|$(CLANG_TIDY_EXCLUDE_EXTRA) + clang-tidy: px4_sitl_default-clang - @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && "$(SRC_DIR)"/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j_clang_tidy) -p . + @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && "$(SRC_DIR)"/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j_clang_tidy) -exclude="$(CLANG_TIDY_EXCLUDE)" -p . # to automatically fix a single check at a time, eg modernize-redundant-void-arg # % run-clang-tidy-4.0.py -fix -j4 -checks=-\*,modernize-redundant-void-arg -p . clang-tidy-fix: px4_sitl_default-clang - @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && "$(SRC_DIR)"/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j_clang_tidy) -fix -p . + @cd "$(SRC_DIR)"/build/px4_sitl_default-clang && "$(SRC_DIR)"/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j_clang_tidy) -exclude="$(CLANG_TIDY_EXCLUDE)" -fix -p . # TODO: Fix cppcheck errors then try --enable=warning,performance,portability,style,unusedFunction or --enable=all cppcheck: px4_sitl_default diff --git a/README.md b/README.md index 8353f3add6..bf4d74bb76 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,109 @@ -# PX4 Drone Autopilot +
+
+
+
+
+ The autopilot stack the industry builds on. +
-[](https://github.com/PX4/PX4-Autopilot/actions/workflows/build_all_targets.yml) [](https://github.com/PX4/PX4-Autopilot/actions?query=workflow%3A%22SITL+Tests%22) + -[](https://discord.gg/dronecode) +--- -This repository holds the [PX4](http://px4.io) flight control solution for drones, with the main applications located in the [src/modules](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules) directory. It also contains the PX4 Drone Middleware Platform, which provides drivers and middleware to run drones. +## About -PX4 is highly portable, OS-independent and supports Linux, NuttX and MacOS out of the box. +PX4 is an open-source autopilot stack for drones and unmanned vehicles. It supports multirotors, fixed-wing, VTOL, rovers, and many more experimental platforms from racing quads to industrial survey aircraft. It runs on [NuttX](https://nuttx.apache.org/), Linux, and macOS. Licensed under [BSD 3-Clause](LICENSE). -* Official Website: http://px4.io (License: BSD 3-clause, [LICENSE](https://github.com/PX4/PX4-Autopilot/blob/main/LICENSE)) -* [Supported airframes](https://docs.px4.io/main/en/airframes/airframe_reference.html) ([portfolio](https://px4.io/ecosystem/commercial-systems/)): - * [Multicopters](https://docs.px4.io/main/en/frames_multicopter/) - * [Fixed wing](https://docs.px4.io/main/en/frames_plane/) - * [VTOL](https://docs.px4.io/main/en/frames_vtol/) - * [Autogyro](https://docs.px4.io/main/en/frames_autogyro/) - * [Rover](https://docs.px4.io/main/en/frames_rover/) - * many more experimental types (Blimps, Boats, Submarines, High Altitude Balloons, Spacecraft, etc) -* Releases: [Downloads](https://github.com/PX4/PX4-Autopilot/releases) +## Why PX4 -## Releases +**Modular architecture.** PX4 is built around [uORB](https://docs.px4.io/main/en/middleware/uorb.html), a [DDS](https://docs.px4.io/main/en/middleware/uxrce_dds.html)-compatible publish/subscribe middleware. Modules are fully parallelized and thread safe. You can build custom configurations and trim what you don't need. -Release notes and supporting information for PX4 releases can be found on the [Developer Guide](https://docs.px4.io/main/en/releases/). +**Wide hardware support.** PX4 runs on a wide range of [autopilot boards](https://docs.px4.io/main/en/flight_controller/) and supports an extensive set of sensors, telemetry radios, and actuators through the [Pixhawk](https://pixhawk.org/) ecosystem. -## Building a PX4 based drone, rover, boat or robot +**Developer friendly.** First-class support for [MAVLink](https://mavlink.io/) and [DDS / ROS 2](https://docs.px4.io/main/en/ros2/) integration. Comprehensive [SITL simulation](https://docs.px4.io/main/en/simulation/), hardware-in-the-loop testing, and [log analysis](https://docs.px4.io/main/en/log/flight_log_analysis.html) tools. An active developer community on [Discord](https://discord.gg/dronecode) and the [weekly dev call](https://docs.px4.io/main/en/contribute/). -The [PX4 User Guide](https://docs.px4.io/main/en/) explains how to assemble [supported vehicles](https://docs.px4.io/main/en/airframes/airframe_reference.html) and fly drones with PX4. See the [forum and chat](https://docs.px4.io/main/en/#getting-help) if you need help! +**Vendor neutral governance.** PX4 is hosted under the [Dronecode Foundation](https://www.dronecode.org/), part of the Linux Foundation. Business-friendly BSD-3 license. No single vendor controls the roadmap. +## Supported Vehicles -## Changing Code and Contributing +|
+
+ + Multicopter + + |
+
+
+ + Fixed Wing + + |
+
+
+ + VTOL + + |
+
+
+ + Rover + + |
+
-
+
+
+
+
+
+
A simulator implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). It can be ran in SITL directly on the computer or as an alternative to HITL offering a hard real-time simulation directly on the hardware autopilot.
Supported Vehicles: Quad, Hexa, Plane, Tailsitter, Standard VTOL, Ackermann Rover
| -| [FlightGear](../sim_flightgear/index.md) |A simulator that provides physically and visually realistic simulations. In particular it can simulate many weather conditions, including thunderstorms, snow, rain and hail, and can also simulate thermals and different types of atmospheric flows. [Multi-vehicle simulation](../sim_flightgear/multi_vehicle.md) is also supported.
Supported Vehicles: Plane, Autogyro, Rover
| -| [JMAVSim](../sim_jmavsim/index.md) |A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).
Supported Vehicles: Quad
| -| [JSBSim](../sim_jsbsim/index.md) |A simulator that provides advanced flight dynamics models. This can be used to model realistic flight dynamics based on wind tunnel data.
Supported Vehicles: Plane, Quad, Hex
| -| [AirSim](../sim_airsim/index.md) |A cross platform simulator that provides physically and visually realistic simulations. This simulator is resource intensive, and requires a significantly more powerful computer than the other simulators described here.
Supported Vehicles: Iris (MultiRotor model and a configuration for PX4 QuadRotor in the X configuration).
| +| 시뮬레이터 | 설명 | +| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [Simulation-In-Hardware](../sim_sih/index.md) (SIH) |A simulator implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). It can be ran in SITL directly on the computer or as an alternative to HITL offering a hard real-time simulation directly on the hardware autopilot.
Supported Vehicles: Quad, Hexa, Plane, Tailsitter, Standard VTOL, Ackermann Rover
| +| [FlightGear](../sim_flightgear/index.md) |A simulator that provides physically and visually realistic simulations. In particular it can simulate many weather conditions, including thunderstorms, snow, rain and hail, and can also simulate thermals and different types of atmospheric flows. [Multi-vehicle simulation](../sim_flightgear/multi_vehicle.md) is also supported.
Supported Vehicles: Plane, Autogyro, Rover
| +| [JMAVSim](../sim_jmavsim/index.md) |A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).
Supported Vehicles: Quad
| +| [JSBSim](../sim_jsbsim/index.md) |A simulator that provides advanced flight dynamics models. This can be used to model realistic flight dynamics based on wind tunnel data.
Supported Vehicles: Plane, Quad, Hex
| +| [AirSim](../sim_airsim/index.md) |A cross platform simulator that provides physically and visually realistic simulations. This simulator is resource intensive, and requires a significantly more powerful computer than the other simulators described here.
Supported Vehicles: Iris (MultiRotor model and a configuration for PX4 QuadRotor in the X configuration).
| diff --git a/docs/ko/smart_batteries/rotoye_batmon.md b/docs/ko/smart_batteries/rotoye_batmon.md index 896ef46e27..b4ba96fd30 100644 --- a/docs/ko/smart_batteries/rotoye_batmon.md +++ b/docs/ko/smart_batteries/rotoye_batmon.md @@ -47,7 +47,7 @@ In _QGroundControl_: 3. Start the [batt_smbus driver](../modules/modules_driver.md) in the console. 예를 들어 동일한 버스에서 두 개의 BatMon을 실행하려면: ```sh - batt_smbus start -X -b 1 -a 11 # External bus 1, address 0x0b + batt_smbus start -X -b 1 -a 11 # External bus 1, address 0x0b batt_smbus start -X -b 1 -a 12 # External bus 1, address 0x0c ``` diff --git a/docs/ko/test_and_ci/continous_integration.md b/docs/ko/test_and_ci/continous_integration.md index 92a888659c..e2a8d03076 100644 --- a/docs/ko/test_and_ci/continous_integration.md +++ b/docs/ko/test_and_ci/continous_integration.md @@ -1,3 +1,194 @@ # PX4 지속 통합 -PX4 빌드 및 테스트는 GitHub 작업과 Jenkins 서버를 사용합니다. +PX4 uses GitHub Actions for continuous integration, with different workflows handling code builds, testing, and documentation. + +## Documentation CI + +The documentation pipeline handles building, deploying, and translating the PX4 User Guide. +All documentation CI is consolidated into a single orchestrator workflow organized in tiers. + +### Docs Orchestrator + +**Workflow file:** [`docs-orchestrator.yml`](https://github.com/PX4/PX4-Autopilot/blob/main/.github/workflows/docs-orchestrator.yml) + +This is the main documentation workflow. It runs on pull requests, pushes to `main` and `release/**` branches, and manual `workflow_dispatch` triggers, performing different jobs depending on the trigger event. +Jobs are organized in tiers, where each tier depends on the previous one completing successfully. + +#### Tier Structure + +| Tier | Job | PR | Push / Dispatch | 설명 | +| ---- | -------------- | ----------------------------------------------- | --------------------------------- | -------------------------------------------------------------------------------- | +| T1 | Detect Changes | Yes | — | Checks if source code files changed (triggers metadata regen) | +| T2 | PR Metadata | Yes (conditional) | — | Builds PX4 SITL and regenerates all auto-generated docs | +| T2 | Metadata Sync | — | Yes | Builds PX4 SITL, regenerates metadata, auto-commits | +| T2 | Link Check | Yes | — | Checks for broken links in changed files, posts PR comment | +| T3 | Build Site | Yes (if docs/source changed) | Yes (after T2) | Builds the VitePress documentation site | +| T4 | Deploy | — | Yes | Deploys to AWS S3 | + +#### Pull Request Flow + +When a PR modifies files in `docs/**` or the orchestrator workflow file itself, the workflow validates the changes: + +```txt +PR Event + │ + ▼ +┌─────────────────────────────────────┐ +│ T1: Detect Changes │ +│ • Checks if src/msg/ROMFS changed │ +└─────────────────┬───────────────────┘ + │ + ┌───────┴───────┐ + ▼ ▼ +┌──────────────────┐ ┌─────────────────────────┐ +│ T2: PR Metadata │ │ T2: Link Check (~30s) │ +│ (conditional) │ │ • Detects changed .md │ +│ • Builds SITL │ │ • Runs filtered check │ +│ • Generates │ │ • Posts PR comment │ +│ metadata │ │ • Runs full check │ +│ • Builds │ └────────────┬────────────┘ +│ failsafe web │ │ +└────────┬─────────┘ │ + └───────────┬────────────┘ + ▼ +┌─────────────────────────────────────┐ +│ T3: Build Site (~7-10 min) │ +│ (skipped if only workflow YAML │ +│ changed — no docs/source changes) │ +│ • Builds VitePress site │ +│ • Verifies no build errors │ +└─────────────────┬───────────────────┘ + │ + ▼ + DONE +``` + +| Job | Duration | 설명 | +| -------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| **T1: Detect Changes** | ~10s | Determines if metadata regeneration is needed | +| **T2: PR Metadata** | ~10-15m | Rebuilds PX4 SITL and regenerates all metadata (only if source files changed) | +| **T2: Link Check** | ~30s | Checks for broken links in changed markdown files and posts a sticky comment to the PR (skipped on fork PRs) | +| **T3: Build Site** | ~7-10m | Builds the VitePress site to verify there are no build errors. Skipped when only the workflow YAML changed (no docs or source changes). | + +#### Push / Dispatch Flow (main/release branches) + +When changes are pushed to `main` or `release/**` branches (or a `workflow_dispatch` is triggered), the workflow regenerates metadata, builds, and deploys. +Only `main` and `release/*` branches are accepted for deploy — other branches will fail with a clear error. + +```txt +Push / Dispatch Event + │ + ▼ +┌─────────────────────────────────────┐ +│ T2: Metadata Sync (~10-15 min) │ +│ • Builds px4_sitl_default │ +│ • Generates parameter/airframe/ │ +│ module documentation │ +│ • Builds failsafe web simulator │ +│ • Formats with Prettier │ +│ • Auto-commits if changes detected │ +│ (with [skip ci]) │ +└─────────────────┬───────────────────┘ + │ + ▼ +┌─────────────────────────────────────┐ +│ T3: Build Site (~7-10 min) │ +│ • Builds VitePress site │ +│ • Uploads build artifact │ +└─────────────────┬───────────────────┘ + │ + ▼ +┌─────────────────────────────────────┐ +│ T4: Deploy (~3 min) │ +│ • Syncs to AWS S3 │ +│ • HTML: 60s cache │ +│ • Assets: 24h immutable cache │ +└─────────────────────────────────────┘ +``` + +| Job | Duration | 설명 | +| ------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------ | +| **T2: Metadata Sync** | ~10-15m | Rebuilds PX4 SITL, regenerates all metadata, formats with Prettier, auto-commits with `[skip ci]` | +| **T3: Build Site** | ~7-10m | Builds the VitePress documentation site | +| **T4: Deploy** | ~3m | Syncs built site to AWS S3 (HTML: 60s cache, assets: 24h cache) | + +Crowdin upload is handled by a separate workflow (see below). + +#### Generated Metadata + +The metadata regeneration job creates the following auto-generated documentation: + +| 형식 | 출력 | 설명 | +| ------------------ | ------------------------------------------------ | --------------------------------------------------------------- | +| 매개변수 | `docs/en/advanced_config/parameter_reference.md` | Complete parameter reference | +| 기체 | `docs/en/airframes/airframe_reference.md` | Airframe configurations | +| 모듈 | `docs/en/modules/*.md` | Module documentation | +| Messages | `docs/en/msg_docs/*.md` | uORB message documentation | +| uORB Graphs | `docs/public/middleware/*.json` | Topic dependency graphs | +| Failsafe Simulator | `docs/public/config/failsafe/*` | Interactive failsafe simulator (WebAssembly) | + +:::warning +Do not manually edit the auto-generated files listed above. They are overwritten on every push to main. +::: + +#### Path Triggers + +The workflow triggers on different paths depending on the event: + +**Push** (main/release branches): + +| Path | Reason | +| ------------------------ | ------------------------------------- | +| `docs/**` | Documentation source files | +| `src/**` | Source code changes affect metadata | +| `msg/**` | Message definitions affect metadata | +| `ROMFS/**` | ROMFS files affect metadata | +| `Tools/module_config/**` | Module configuration affects metadata | + +**Pull Request:** + +| Path | Reason | +| ----------------------------------------- | ------------------------------ | +| `docs/**` | Documentation source files | +| `.github/workflows/docs-orchestrator.yml` | Changes to the workflow itself | + +Source-only changes on PRs are detected at runtime by the T1: Detect Changes job using [dorny/paths-filter](https://github.com/dorny/paths-filter), which conditionally triggers the T2: PR Metadata job. + +### Crowdin Download Workflow + +**Workflow file:** [`docs_crowdin_download.yml`](https://github.com/PX4/PX4-Autopilot/blob/main/.github/workflows/docs_crowdin_download.yml) + +This scheduled workflow downloads completed translations from Crowdin and creates pull requests. + +| 설정 | Value | +| -------------------- | ---------------------------------------------------------------------------------------------------------------- | +| **Schedule** | Every Sunday at 00:00 UTC | +| **Target Languages** | Korean (ko), Ukrainian (uk), Chinese Simplified (zh-CN) | + +**Process:** + +1. Downloads translations for each target language from Crowdin +2. Creates a separate PR for each language with new translations +3. PRs are labeled "Documentation" and assigned for review + +### Caching Strategy + +The workflows use caching to speed up builds: + +| Cache | Size | Purpose | +| --------------------------------- | --------------------- | -------------------------------------------------- | +| ccache | 1GB | C++ compilation cache for SITL builds | +| node_modules | ~26MB | Node.js dependencies for VitePress | + +### Infrastructure + +Jobs run on [runs-on](https://runs-on.com/) self-hosted runners with S3 cache: + +| Job | Runner | +| ---------------------------------- | ------------------------------------------------- | +| T1: Detect Changes | ubuntu-latest | +| T2: PR Metadata | 4 CPU (with px4-dev container) | +| T2: Metadata Sync | 4 CPU (with px4-dev container) | +| T2: Link Check | ubuntu-latest | +| T3: Build Site | 4 CPU | +| T4: Deploy | ubuntu-latest | diff --git a/docs/ko/test_and_ci/docker.md b/docs/ko/test_and_ci/docker.md index 8d650a97a0..453366512b 100644 --- a/docs/ko/test_and_ci/docker.md +++ b/docs/ko/test_and_ci/docker.md @@ -1,12 +1,11 @@ # PX4 도커 컨테이너 -Docker containers are provided for the complete [PX4 development toolchain](../dev_setup/dev_env.md#supported-targets) including NuttX and Linux based hardware, [Gazebo Classic](../sim_gazebo_classic/index.md) simulation, and [ROS](../simulation/ros_interface.md). +Docker containers are provided for the complete [PX4 development toolchain](../dev_setup/dev_env.md#supported-targets) including NuttX and Linux based hardware, [Gazebo](../sim_gazebo_gz/index.md) simulation, and [ROS 2](../ros2/user_guide.md). This topic shows how to use the [available docker containers](#px4_containers) to access the build environment in a local Linux computer. :::info -Dockerfiles and README can be found on [Github here](https://github.com/PX4/PX4-containers/tree/master?tab=readme-ov-file#container-hierarchy). -They are built automatically on [Docker Hub](https://hub.docker.com/u/px4io/). +The recommended `px4-dev` container is built from the [Dockerfile in the PX4-Autopilot source tree](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/Dockerfile) by the [Container build workflow](https://github.com/PX4/PX4-Autopilot/actions/workflows/dev_container.yml). ::: ## 준비 사항 @@ -35,33 +34,36 @@ sudo usermod -aG docker $USER # Log in/out again before using docker! ``` -## Container Hierarchy {#px4_containers} +## px4-dev Container (Recommended) {#px4_containers} -The available containers are on [GitHub here](https://github.com/PX4/PX4-containers/tree/master?tab=readme-ov-file#container-hierarchy). +The **`px4-dev`** container is the recommended container for building PX4 firmware. +It is a single, multi-architecture container (linux/amd64 and linux/arm64) based on Ubuntu 24.04 that includes everything needed to build PX4 for NuttX hardware targets. -이를 통하여 다양한 빌드 대상 및 구성을 테스트할 수 있습니다(포함된 도구는 이름에서 유추할 수 있음). -The containers are hierarchical, such that containers have the functionality of their parents. -For example, the partial hierarchy below shows that the docker container with NuttX build tools (`px4-dev-nuttx-focal`) does not include ROS 2, while the simulation containers do: +It is published to both registries simultaneously: -```plain -- px4io/px4-dev-base-focal - - px4io/px4-dev-nuttx-focal - - px4io/px4-dev-simulation-focal - - px4io/px4-dev-ros-noetic - - px4io/px4-dev-ros2-foxy - - px4io/px4-dev-ros2-rolling -- px4io/px4-dev-base-jammy - - px4io/px4-dev-nuttx-jammy -``` +- **GitHub Container Registry:** [ghcr.io/px4/px4-dev](https://github.com/PX4/PX4-Autopilot/pkgs/container/px4-dev) +- **Docker Hub:** [px4io/px4-dev](https://hub.docker.com/r/px4io/px4-dev) -The most recent version can be accessed using the `latest` tag: `px4io/px4-dev-nuttx-focal:latest` -(available tags are listed for each container on _hub.docker.com_. -For example, the `px4io/px4-dev-nuttx-focal` tags can be found on [hub.docker.com here](https://hub.docker.com/r/px4io/px4-dev-nuttx-focal/tags?page=1&ordering=last_updated)). +The container includes: + +- Ubuntu 24.04 base +- ARM cross-compiler (`gcc-arm-none-eabi`) and Xtensa compiler (for ESP32 targets) +- Build tools: `cmake`, `ninja`, `ccache`, `make` +- Python 3 with PX4 build dependencies +- NuttX toolchain libraries (`libnewlib-arm-none-eabi`, etc.) + +The container is built from the [Dockerfile](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/Dockerfile) in the PX4 source tree using the [Container build workflow](https://github.com/PX4/PX4-Autopilot/actions/workflows/dev_container.yml). +Images are tagged with the PX4 version (e.g. `px4io/px4-dev:v1.16.0`). :::tip -Typically you should use a recent container, but not necessarily the `latest` (as this changes too often). +A `px4-sim` container with simulation tools (Gazebo Harmonic) is planned to complement `px4-dev` for simulation workflows. ::: +### Legacy Containers + +The older per-distro containers from [PX4/PX4-containers](https://github.com/PX4/PX4-containers) (e.g. `px4-dev-nuttx-jammy`, `px4-dev-ros2-humble`, etc.) are no longer recommended. +They will be replaced by `px4-dev` (for builds) and the upcoming `px4-sim` (for simulation). + ## 도커 컨테이너 활용 도커 컨테이너에서 실행되는 툴체인을 사용하여 호스트 컴퓨터에서 PX4 빌드 방법을 설명합니다. @@ -121,7 +123,7 @@ docker run -it --privileged \ - `
+
A simulator implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). It can be ran in SITL directly on the computer or as an alternative to HITL offering a hard real-time simulation directly on the hardware autopilot.
Supported Vehicles: Quad, Hexa, Plane, Tailsitter, Standard VTOL, Ackermann Rover
| -| [FlightGear](../sim_flightgear/README.md) |Симулятор який надає фізично та візуально реалістичні симуляції. Зокрема він може моделювати багато погодних умов, включаючи грози, сніг, дощ та град, а також може симулювати температурні режими та різні типи атмосферних течій. [Симуляція кількох засобів](../sim_flightgear/multi_vehicle.md) також підтримується.
Рухомі засоби, що підтримуються: Літак, Автожир, Ровер
| -| [JMAVSim](../sim_jmavsim/index.md) |A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).
Supported Vehicles: Quad
| -| [JSBSim](../sim_jsbsim/README.md) |Симулятор, який надає моделі просунутої динаміки польоту. Він може використовуватися для моделювання реалістичної динаміки польоту, заснованої на даних з аеродинамічної труби.
Рухомі засоби, що підтримуються: Літак, Квадрокоптер, Гексакоптер
| -| [AirSim](../sim_airsim/README.md) |Міжплатформовий симулятор який надає фізично та візуально реалістичні симуляції. This simulator is resource intensive, and requires a significantly more powerful computer than the other simulators described here.
Supported Vehicles: Iris (MultiRotor model and a configuration for PX4 QuadRotor in the X configuration).
| +| Симулятор | Опис | +| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [Simulation-In-Hardware](../sim_sih/README.md) (SIH) |A simulator implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). It can be ran in SITL directly on the computer or as an alternative to HITL offering a hard real-time simulation directly on the hardware autopilot.
Supported Vehicles: Quad, Hexa, Plane, Tailsitter, Standard VTOL, Ackermann Rover
| +| [FlightGear](../sim_flightgear/README.md) |Симулятор який надає фізично та візуально реалістичні симуляції. Зокрема він може моделювати багато погодних умов, включаючи грози, сніг, дощ та град, а також може симулювати температурні режими та різні типи атмосферних течій. [Симуляція кількох засобів](../sim_flightgear/multi_vehicle.md) також підтримується.
Рухомі засоби, що підтримуються: Літак, Автожир, Ровер
| +| [JMAVSim](../sim_jmavsim/index.md) |A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).
Supported Vehicles: Quad
| +| [JSBSim](../sim_jsbsim/README.md) |Симулятор, який надає моделі просунутої динаміки польоту. Він може використовуватися для моделювання реалістичної динаміки польоту, заснованої на даних з аеродинамічної труби.
Рухомі засоби, що підтримуються: Літак, Квадрокоптер, Гексакоптер
| +| [AirSim](../sim_airsim/README.md) |Міжплатформовий симулятор який надає фізично та візуально реалістичні симуляції. This simulator is resource intensive, and requires a significantly more powerful computer than the other simulators described here.
Supported Vehicles: Iris (MultiRotor model and a configuration for PX4 QuadRotor in the X configuration).
| diff --git a/docs/uk/smart_batteries/rotoye_batmon.md b/docs/uk/smart_batteries/rotoye_batmon.md index 9050fe7efd..43f79d30c7 100644 --- a/docs/uk/smart_batteries/rotoye_batmon.md +++ b/docs/uk/smart_batteries/rotoye_batmon.md @@ -47,7 +47,7 @@ In _QGroundControl_: 3. Start the [batt_smbus driver](../modules/modules_driver.md) in the console. Наприклад, для запуску двох BatMons у одному підключенні: ```sh - batt_smbus start -X -b 1 -a 11 # External bus 1, address 0x0b + batt_smbus start -X -b 1 -a 11 # External bus 1, address 0x0b batt_smbus start -X -b 1 -a 12 # External bus 1, address 0x0c ``` diff --git a/docs/uk/test_and_ci/continous_integration.md b/docs/uk/test_and_ci/continous_integration.md index 2dfa556b90..dbf3b444a7 100644 --- a/docs/uk/test_and_ci/continous_integration.md +++ b/docs/uk/test_and_ci/continous_integration.md @@ -1,3 +1,194 @@ # Безперервна інтеграція -PX4 збірки і тестування виконуються використовуючи GitHub і сервер Jenkins . +PX4 uses GitHub Actions for continuous integration, with different workflows handling code builds, testing, and documentation. + +## Documentation CI + +The documentation pipeline handles building, deploying, and translating the PX4 User Guide. +All documentation CI is consolidated into a single orchestrator workflow organized in tiers. + +### Docs Orchestrator + +**Workflow file:** [`docs-orchestrator.yml`](https://github.com/PX4/PX4-Autopilot/blob/main/.github/workflows/docs-orchestrator.yml) + +This is the main documentation workflow. It runs on pull requests, pushes to `main` and `release/**` branches, and manual `workflow_dispatch` triggers, performing different jobs depending on the trigger event. +Jobs are organized in tiers, where each tier depends on the previous one completing successfully. + +#### Tier Structure + +| Tier | Job | PR | Push / Dispatch | Опис | +| ---- | -------------- | ----------------------------------------------- | --------------------------------- | -------------------------------------------------------------------------------- | +| T1 | Detect Changes | Так | — | Checks if source code files changed (triggers metadata regen) | +| T2 | PR Metadata | Yes (conditional) | — | Builds PX4 SITL and regenerates all auto-generated docs | +| T2 | Metadata Sync | — | Так | Builds PX4 SITL, regenerates metadata, auto-commits | +| T2 | Link Check | Так | — | Checks for broken links in changed files, posts PR comment | +| T3 | Build Site | Yes (if docs/source changed) | Yes (after T2) | Builds the VitePress documentation site | +| T4 | Deploy | — | Так | Deploys to AWS S3 | + +#### Pull Request Flow + +When a PR modifies files in `docs/**` or the orchestrator workflow file itself, the workflow validates the changes: + +```txt +PR Event + │ + ▼ +┌─────────────────────────────────────┐ +│ T1: Detect Changes │ +│ • Checks if src/msg/ROMFS changed │ +└─────────────────┬───────────────────┘ + │ + ┌───────┴───────┐ + ▼ ▼ +┌──────────────────┐ ┌─────────────────────────┐ +│ T2: PR Metadata │ │ T2: Link Check (~30s) │ +│ (conditional) │ │ • Detects changed .md │ +│ • Builds SITL │ │ • Runs filtered check │ +│ • Generates │ │ • Posts PR comment │ +│ metadata │ │ • Runs full check │ +│ • Builds │ └────────────┬────────────┘ +│ failsafe web │ │ +└────────┬─────────┘ │ + └───────────┬────────────┘ + ▼ +┌─────────────────────────────────────┐ +│ T3: Build Site (~7-10 min) │ +│ (skipped if only workflow YAML │ +│ changed — no docs/source changes) │ +│ • Builds VitePress site │ +│ • Verifies no build errors │ +└─────────────────┬───────────────────┘ + │ + ▼ + DONE +``` + +| Job | Duration | Опис | +| -------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| **T1: Detect Changes** | ~10s | Determines if metadata regeneration is needed | +| **T2: PR Metadata** | ~10-15m | Rebuilds PX4 SITL and regenerates all metadata (only if source files changed) | +| **T2: Link Check** | ~30s | Checks for broken links in changed markdown files and posts a sticky comment to the PR (skipped on fork PRs) | +| **T3: Build Site** | ~7-10m | Builds the VitePress site to verify there are no build errors. Skipped when only the workflow YAML changed (no docs or source changes). | + +#### Push / Dispatch Flow (main/release branches) + +When changes are pushed to `main` or `release/**` branches (or a `workflow_dispatch` is triggered), the workflow regenerates metadata, builds, and deploys. +Only `main` and `release/*` branches are accepted for deploy — other branches will fail with a clear error. + +```txt +Push / Dispatch Event + │ + ▼ +┌─────────────────────────────────────┐ +│ T2: Metadata Sync (~10-15 min) │ +│ • Builds px4_sitl_default │ +│ • Generates parameter/airframe/ │ +│ module documentation │ +│ • Builds failsafe web simulator │ +│ • Formats with Prettier │ +│ • Auto-commits if changes detected │ +│ (with [skip ci]) │ +└─────────────────┬───────────────────┘ + │ + ▼ +┌─────────────────────────────────────┐ +│ T3: Build Site (~7-10 min) │ +│ • Builds VitePress site │ +│ • Uploads build artifact │ +└─────────────────┬───────────────────┘ + │ + ▼ +┌─────────────────────────────────────┐ +│ T4: Deploy (~3 min) │ +│ • Syncs to AWS S3 │ +│ • HTML: 60s cache │ +│ • Assets: 24h immutable cache │ +└─────────────────────────────────────┘ +``` + +| Job | Duration | Опис | +| ------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------ | +| **T2: Metadata Sync** | ~10-15m | Rebuilds PX4 SITL, regenerates all metadata, formats with Prettier, auto-commits with `[skip ci]` | +| **T3: Build Site** | ~7-10m | Builds the VitePress documentation site | +| **T4: Deploy** | ~3m | Syncs built site to AWS S3 (HTML: 60s cache, assets: 24h cache) | + +Crowdin upload is handled by a separate workflow (see below). + +#### Generated Metadata + +The metadata regeneration job creates the following auto-generated documentation: + +| Тип | Output | Опис | +| ------------------ | ------------------------------------------------ | --------------------------------------------------------------- | +| Параметри | `docs/en/advanced_config/parameter_reference.md` | Complete parameter reference | +| Планери | `docs/en/airframes/airframe_reference.md` | Airframe configurations | +| Модулі | `docs/en/modules/*.md` | Module documentation | +| Messages | `docs/en/msg_docs/*.md` | uORB message documentation | +| uORB Graphs | `docs/public/middleware/*.json` | Topic dependency graphs | +| Failsafe Simulator | `docs/public/config/failsafe/*` | Interactive failsafe simulator (WebAssembly) | + +:::warning +Do not manually edit the auto-generated files listed above. They are overwritten on every push to main. +::: + +#### Path Triggers + +The workflow triggers on different paths depending on the event: + +**Push** (main/release branches): + +| Path | Reason | +| ------------------------ | ------------------------------------- | +| `docs/**` | Documentation source files | +| `src/**` | Source code changes affect metadata | +| `msg/**` | Message definitions affect metadata | +| `ROMFS/**` | ROMFS files affect metadata | +| `Tools/module_config/**` | Module configuration affects metadata | + +**Pull Request:** + +| Path | Reason | +| ----------------------------------------- | ------------------------------ | +| `docs/**` | Documentation source files | +| `.github/workflows/docs-orchestrator.yml` | Changes to the workflow itself | + +Source-only changes on PRs are detected at runtime by the T1: Detect Changes job using [dorny/paths-filter](https://github.com/dorny/paths-filter), which conditionally triggers the T2: PR Metadata job. + +### Crowdin Download Workflow + +**Workflow file:** [`docs_crowdin_download.yml`](https://github.com/PX4/PX4-Autopilot/blob/main/.github/workflows/docs_crowdin_download.yml) + +This scheduled workflow downloads completed translations from Crowdin and creates pull requests. + +| Налаштування | Значення | +| -------------------- | ---------------------------------------------------------------------------------------------------------------- | +| **Schedule** | Every Sunday at 00:00 UTC | +| **Target Languages** | Korean (ko), Ukrainian (uk), Chinese Simplified (zh-CN) | + +**Process:** + +1. Downloads translations for each target language from Crowdin +2. Creates a separate PR for each language with new translations +3. PRs are labeled "Documentation" and assigned for review + +### Caching Strategy + +The workflows use caching to speed up builds: + +| Cache | Розмір | Ціль | +| --------------------------------- | --------------------- | -------------------------------------------------- | +| ccache | 1GB | C++ compilation cache for SITL builds | +| node_modules | ~26MB | Node.js dependencies for VitePress | + +### Infrastructure + +Jobs run on [runs-on](https://runs-on.com/) self-hosted runners with S3 cache: + +| Job | Runner | +| ---------------------------------- | ------------------------------------------------- | +| T1: Detect Changes | ubuntu-latest | +| T2: PR Metadata | 4 CPU (with px4-dev container) | +| T2: Metadata Sync | 4 CPU (with px4-dev container) | +| T2: Link Check | ubuntu-latest | +| T3: Build Site | 4 CPU | +| T4: Deploy | ubuntu-latest | diff --git a/docs/uk/test_and_ci/docker.md b/docs/uk/test_and_ci/docker.md index 1cb4ad8cdf..ee4f47ace8 100644 --- a/docs/uk/test_and_ci/docker.md +++ b/docs/uk/test_and_ci/docker.md @@ -1,12 +1,11 @@ # Docker контейнери для PX4 -Docker containers are provided for the complete [PX4 development toolchain](../dev_setup/dev_env.md#supported-targets) including NuttX and Linux based hardware, [Gazebo Classic](../sim_gazebo_classic/index.md) simulation, and [ROS](../simulation/ros_interface.md). +Docker containers are provided for the complete [PX4 development toolchain](../dev_setup/dev_env.md#supported-targets) including NuttX and Linux based hardware, [Gazebo](../sim_gazebo_gz/index.md) simulation, and [ROS 2](../ros2/user_guide.md). This topic shows how to use the [available docker containers](#px4_containers) to access the build environment in a local Linux computer. :::info -Dockerfiles and README can be found on [Github here](https://github.com/PX4/PX4-containers/tree/master?tab=readme-ov-file#container-hierarchy). -They are built automatically on [Docker Hub](https://hub.docker.com/u/px4io/). +The recommended `px4-dev` container is built from the [Dockerfile in the PX4-Autopilot source tree](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/Dockerfile) by the [Container build workflow](https://github.com/PX4/PX4-Autopilot/actions/workflows/dev_container.yml). ::: ## Вимоги @@ -35,33 +34,36 @@ sudo usermod -aG docker $USER # Log in/out again before using docker! ``` -## Container Hierarchy {#px4_containers} +## px4-dev Container (Recommended) {#px4_containers} -The available containers are on [GitHub here](https://github.com/PX4/PX4-containers/tree/master?tab=readme-ov-file#container-hierarchy). +The **`px4-dev`** container is the recommended container for building PX4 firmware. +It is a single, multi-architecture container (linux/amd64 and linux/arm64) based on Ubuntu 24.04 that includes everything needed to build PX4 for NuttX hardware targets. -Вони дозволяють тестувати різні цілі збірки та конфігурації (включені інструменти можна зрозуміти з їх назв). -Контейнери є ієрархічними, тобто такими, що мають функціональність вихідних контейнерів. -For example, the partial hierarchy below shows that the docker container with NuttX build tools (`px4-dev-nuttx-focal`) does not include ROS 2, while the simulation containers do: +It is published to both registries simultaneously: -```plain -- px4io/px4-dev-base-focal - - px4io/px4-dev-nuttx-focal - - px4io/px4-dev-simulation-focal - - px4io/px4-dev-ros-noetic - - px4io/px4-dev-ros2-foxy - - px4io/px4-dev-ros2-rolling -- px4io/px4-dev-base-jammy - - px4io/px4-dev-nuttx-jammy -``` +- **GitHub Container Registry:** [ghcr.io/px4/px4-dev](https://github.com/PX4/PX4-Autopilot/pkgs/container/px4-dev) +- **Docker Hub:** [px4io/px4-dev](https://hub.docker.com/r/px4io/px4-dev) -The most recent version can be accessed using the `latest` tag: `px4io/px4-dev-nuttx-focal:latest` -(available tags are listed for each container on _hub.docker.com_. -For example, the `px4io/px4-dev-nuttx-focal` tags can be found on [hub.docker.com here](https://hub.docker.com/r/px4io/px4-dev-nuttx-focal/tags?page=1&ordering=last_updated)). +The container includes: + +- Ubuntu 24.04 base +- ARM cross-compiler (`gcc-arm-none-eabi`) and Xtensa compiler (for ESP32 targets) +- Build tools: `cmake`, `ninja`, `ccache`, `make` +- Python 3 with PX4 build dependencies +- NuttX toolchain libraries (`libnewlib-arm-none-eabi`, etc.) + +The container is built from the [Dockerfile](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/Dockerfile) in the PX4 source tree using the [Container build workflow](https://github.com/PX4/PX4-Autopilot/actions/workflows/dev_container.yml). +Images are tagged with the PX4 version (e.g. `px4io/px4-dev:v1.16.0`). :::tip -Typically you should use a recent container, but not necessarily the `latest` (as this changes too often). +A `px4-sim` container with simulation tools (Gazebo Harmonic) is planned to complement `px4-dev` for simulation workflows. ::: +### Legacy Containers + +The older per-distro containers from [PX4/PX4-containers](https://github.com/PX4/PX4-containers) (e.g. `px4-dev-nuttx-jammy`, `px4-dev-ros2-humble`, etc.) are no longer recommended. +They will be replaced by `px4-dev` (for builds) and the upcoming `px4-sim` (for simulation). + ## Використання Docker контейнера Наступні інструкції показують, як зібрати вихідний код PX4 на основному комп'ютері за допомогою інструментарію, що працює у docker контейнері. @@ -121,23 +123,23 @@ docker run -it --privileged \ - `
+
A simulator implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). It can be ran in SITL directly on the computer or as an alternative to HITL offering a hard real-time simulation directly on the hardware autopilot.
Supported Vehicles: Quad, Hexa, Plane, Tailsitter, Standard VTOL, Ackermann Rover
| -| [FlightGear](../sim_flightgear/index.md) |A simulator that provides physically and visually realistic simulations. In particular it can simulate many weather conditions, including thunderstorms, snow, rain and hail, and can also simulate thermals and different types of atmospheric flows. [Multi-vehicle simulation](../sim_flightgear/multi_vehicle.md) is also supported.
Supported Vehicles: Plane, Autogyro, Rover
| -| [JMAVSim](../sim_jmavsim/index.md) |A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).
Supported Vehicles: Quad
| -| [JSBSim](../sim_jsbsim/index.md) |A simulator that provides advanced flight dynamics models. This can be used to model realistic flight dynamics based on wind tunnel data.
Supported Vehicles: Plane, Quad, Hex
| -| [AirSim](../sim_airsim/index.md) |A cross platform simulator that provides physically and visually realistic simulations. This simulator is resource intensive, and requires a significantly more powerful computer than the other simulators described here.
Supported Vehicles: Iris (MultiRotor model and a configuration for PX4 QuadRotor in the X configuration).
| +| 仿真器 | 描述 | +| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [Simulation-In-Hardware](../sim_sih/index.md) (SIH) |A simulator implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). It can be ran in SITL directly on the computer or as an alternative to HITL offering a hard real-time simulation directly on the hardware autopilot.
Supported Vehicles: Quad, Hexa, Plane, Tailsitter, Standard VTOL, Ackermann Rover
| +| [FlightGear](../sim_flightgear/index.md) |A simulator that provides physically and visually realistic simulations. In particular it can simulate many weather conditions, including thunderstorms, snow, rain and hail, and can also simulate thermals and different types of atmospheric flows. [Multi-vehicle simulation](../sim_flightgear/multi_vehicle.md) is also supported.
Supported Vehicles: Plane, Autogyro, Rover
| +| [JMAVSim](../sim_jmavsim/index.md) |A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).
Supported Vehicles: Quad
| +| [JSBSim](../sim_jsbsim/index.md) |A simulator that provides advanced flight dynamics models. This can be used to model realistic flight dynamics based on wind tunnel data.
Supported Vehicles: Plane, Quad, Hex
| +| [AirSim](../sim_airsim/index.md) |A cross platform simulator that provides physically and visually realistic simulations. This simulator is resource intensive, and requires a significantly more powerful computer than the other simulators described here.
Supported Vehicles: Iris (MultiRotor model and a configuration for PX4 QuadRotor in the X configuration).
| diff --git a/docs/zh/smart_batteries/rotoye_batmon.md b/docs/zh/smart_batteries/rotoye_batmon.md index e12979457b..20e9e615cf 100644 --- a/docs/zh/smart_batteries/rotoye_batmon.md +++ b/docs/zh/smart_batteries/rotoye_batmon.md @@ -47,7 +47,7 @@ In _QGroundControl_: 3. Start the [batt_smbus driver](../modules/modules_driver.md) in the console. For example, to run two BatMons on the same bus: ```sh - batt_smbus start -X -b 1 -a 11 # External bus 1, address 0x0b + batt_smbus start -X -b 1 -a 11 # External bus 1, address 0x0b batt_smbus start -X -b 1 -a 12 # External bus 1, address 0x0c ``` diff --git a/docs/zh/test_and_ci/continous_integration.md b/docs/zh/test_and_ci/continous_integration.md index e02b039d2f..0418804b38 100644 --- a/docs/zh/test_and_ci/continous_integration.md +++ b/docs/zh/test_and_ci/continous_integration.md @@ -1,3 +1,194 @@ # PX4 持续集成 -PX4 构建和测试分布在多个持续集成服务上。 +PX4 uses GitHub Actions for continuous integration, with different workflows handling code builds, testing, and documentation. + +## Documentation CI + +The documentation pipeline handles building, deploying, and translating the PX4 User Guide. +All documentation CI is consolidated into a single orchestrator workflow organized in tiers. + +### Docs Orchestrator + +**Workflow file:** [`docs-orchestrator.yml`](https://github.com/PX4/PX4-Autopilot/blob/main/.github/workflows/docs-orchestrator.yml) + +This is the main documentation workflow. It runs on pull requests, pushes to `main` and `release/**` branches, and manual `workflow_dispatch` triggers, performing different jobs depending on the trigger event. +Jobs are organized in tiers, where each tier depends on the previous one completing successfully. + +#### Tier Structure + +| Tier | Job | PR | Push / Dispatch | 描述 | +| ---- | -------------- | ----------------------------------------------- | --------------------------------- | -------------------------------------------------------------------------------- | +| T1 | Detect Changes | Yes | — | Checks if source code files changed (triggers metadata regen) | +| T2 | PR Metadata | Yes (conditional) | — | Builds PX4 SITL and regenerates all auto-generated docs | +| T2 | Metadata Sync | — | Yes | Builds PX4 SITL, regenerates metadata, auto-commits | +| T2 | Link Check | Yes | — | Checks for broken links in changed files, posts PR comment | +| T3 | Build Site | Yes (if docs/source changed) | Yes (after T2) | Builds the VitePress documentation site | +| T4 | Deploy | — | Yes | Deploys to AWS S3 | + +#### Pull Request Flow + +When a PR modifies files in `docs/**` or the orchestrator workflow file itself, the workflow validates the changes: + +```txt +PR Event + │ + ▼ +┌─────────────────────────────────────┐ +│ T1: Detect Changes │ +│ • Checks if src/msg/ROMFS changed │ +└─────────────────┬───────────────────┘ + │ + ┌───────┴───────┐ + ▼ ▼ +┌──────────────────┐ ┌─────────────────────────┐ +│ T2: PR Metadata │ │ T2: Link Check (~30s) │ +│ (conditional) │ │ • Detects changed .md │ +│ • Builds SITL │ │ • Runs filtered check │ +│ • Generates │ │ • Posts PR comment │ +│ metadata │ │ • Runs full check │ +│ • Builds │ └────────────┬────────────┘ +│ failsafe web │ │ +└────────┬─────────┘ │ + └───────────┬────────────┘ + ▼ +┌─────────────────────────────────────┐ +│ T3: Build Site (~7-10 min) │ +│ (skipped if only workflow YAML │ +│ changed — no docs/source changes) │ +│ • Builds VitePress site │ +│ • Verifies no build errors │ +└─────────────────┬───────────────────┘ + │ + ▼ + DONE +``` + +| Job | Duration | 描述 | +| -------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| **T1: Detect Changes** | ~10s | Determines if metadata regeneration is needed | +| **T2: PR Metadata** | ~10-15m | Rebuilds PX4 SITL and regenerates all metadata (only if source files changed) | +| **T2: Link Check** | ~30s | Checks for broken links in changed markdown files and posts a sticky comment to the PR (skipped on fork PRs) | +| **T3: Build Site** | ~7-10m | Builds the VitePress site to verify there are no build errors. Skipped when only the workflow YAML changed (no docs or source changes). | + +#### Push / Dispatch Flow (main/release branches) + +When changes are pushed to `main` or `release/**` branches (or a `workflow_dispatch` is triggered), the workflow regenerates metadata, builds, and deploys. +Only `main` and `release/*` branches are accepted for deploy — other branches will fail with a clear error. + +```txt +Push / Dispatch Event + │ + ▼ +┌─────────────────────────────────────┐ +│ T2: Metadata Sync (~10-15 min) │ +│ • Builds px4_sitl_default │ +│ • Generates parameter/airframe/ │ +│ module documentation │ +│ • Builds failsafe web simulator │ +│ • Formats with Prettier │ +│ • Auto-commits if changes detected │ +│ (with [skip ci]) │ +└─────────────────┬───────────────────┘ + │ + ▼ +┌─────────────────────────────────────┐ +│ T3: Build Site (~7-10 min) │ +│ • Builds VitePress site │ +│ • Uploads build artifact │ +└─────────────────┬───────────────────┘ + │ + ▼ +┌─────────────────────────────────────┐ +│ T4: Deploy (~3 min) │ +│ • Syncs to AWS S3 │ +│ • HTML: 60s cache │ +│ • Assets: 24h immutable cache │ +└─────────────────────────────────────┘ +``` + +| Job | Duration | 描述 | +| ------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------ | +| **T2: Metadata Sync** | ~10-15m | Rebuilds PX4 SITL, regenerates all metadata, formats with Prettier, auto-commits with `[skip ci]` | +| **T3: Build Site** | ~7-10m | Builds the VitePress documentation site | +| **T4: Deploy** | ~3m | Syncs built site to AWS S3 (HTML: 60s cache, assets: 24h cache) | + +Crowdin upload is handled by a separate workflow (see below). + +#### Generated Metadata + +The metadata regeneration job creates the following auto-generated documentation: + +| 类型 | 输出 | 描述 | +| ------------------ | ------------------------------------------------ | --------------------------------------------------------------- | +| 参数 | `docs/en/advanced_config/parameter_reference.md` | Complete parameter reference | +| 机型 | `docs/en/airframes/airframe_reference.md` | Airframe configurations | +| Modules | `docs/en/modules/*.md` | Module documentation | +| Messages | `docs/en/msg_docs/*.md` | uORB message documentation | +| uORB Graphs | `docs/public/middleware/*.json` | Topic dependency graphs | +| Failsafe Simulator | `docs/public/config/failsafe/*` | Interactive failsafe simulator (WebAssembly) | + +:::warning +Do not manually edit the auto-generated files listed above. They are overwritten on every push to main. +::: + +#### Path Triggers + +The workflow triggers on different paths depending on the event: + +**Push** (main/release branches): + +| Path | Reason | +| ------------------------ | ------------------------------------- | +| `docs/**` | Documentation source files | +| `src/**` | Source code changes affect metadata | +| `msg/**` | Message definitions affect metadata | +| `ROMFS/**` | ROMFS files affect metadata | +| `Tools/module_config/**` | Module configuration affects metadata | + +**Pull Request:** + +| Path | Reason | +| ----------------------------------------- | ------------------------------ | +| `docs/**` | Documentation source files | +| `.github/workflows/docs-orchestrator.yml` | Changes to the workflow itself | + +Source-only changes on PRs are detected at runtime by the T1: Detect Changes job using [dorny/paths-filter](https://github.com/dorny/paths-filter), which conditionally triggers the T2: PR Metadata job. + +### Crowdin Download Workflow + +**Workflow file:** [`docs_crowdin_download.yml`](https://github.com/PX4/PX4-Autopilot/blob/main/.github/workflows/docs_crowdin_download.yml) + +This scheduled workflow downloads completed translations from Crowdin and creates pull requests. + +| 设置 | 值 | +| -------------------- | ---------------------------------------------------------------------------------------------------------------- | +| **Schedule** | Every Sunday at 00:00 UTC | +| **Target Languages** | Korean (ko), Ukrainian (uk), Chinese Simplified (zh-CN) | + +**Process:** + +1. Downloads translations for each target language from Crowdin +2. Creates a separate PR for each language with new translations +3. PRs are labeled "Documentation" and assigned for review + +### Caching Strategy + +The workflows use caching to speed up builds: + +| Cache | Size | Purpose | +| --------------------------------- | --------------------- | -------------------------------------------------- | +| ccache | 1GB | C++ compilation cache for SITL builds | +| node_modules | ~26MB | Node.js dependencies for VitePress | + +### Infrastructure + +Jobs run on [runs-on](https://runs-on.com/) self-hosted runners with S3 cache: + +| Job | Runner | +| ---------------------------------- | ------------------------------------------------- | +| T1: Detect Changes | ubuntu-latest | +| T2: PR Metadata | 4 CPU (with px4-dev container) | +| T2: Metadata Sync | 4 CPU (with px4-dev container) | +| T2: Link Check | ubuntu-latest | +| T3: Build Site | 4 CPU | +| T4: Deploy | ubuntu-latest | diff --git a/docs/zh/test_and_ci/docker.md b/docs/zh/test_and_ci/docker.md index 176cdba49e..d9998ca5bc 100644 --- a/docs/zh/test_and_ci/docker.md +++ b/docs/zh/test_and_ci/docker.md @@ -1,12 +1,11 @@ # PX4 Docker 容器 -Docker containers are provided for the complete [PX4 development toolchain](../dev_setup/dev_env.md#supported-targets) including NuttX and Linux based hardware, [Gazebo Classic](../sim_gazebo_classic/index.md) simulation, and [ROS](../simulation/ros_interface.md). +Docker containers are provided for the complete [PX4 development toolchain](../dev_setup/dev_env.md#supported-targets) including NuttX and Linux based hardware, [Gazebo](../sim_gazebo_gz/index.md) simulation, and [ROS 2](../ros2/user_guide.md). This topic shows how to use the [available docker containers](#px4_containers) to access the build environment in a local Linux computer. :::info -Dockerfiles and README can be found on [Github here](https://github.com/PX4/PX4-containers/tree/master?tab=readme-ov-file#container-hierarchy). -They are built automatically on [Docker Hub](https://hub.docker.com/u/px4io/). +The recommended `px4-dev` container is built from the [Dockerfile in the PX4-Autopilot source tree](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/Dockerfile) by the [Container build workflow](https://github.com/PX4/PX4-Autopilot/actions/workflows/dev_container.yml). ::: ## 系统必备组件 @@ -35,33 +34,36 @@ sudo usermod -aG docker $USER # Log in/out again before using docker! ``` -## Container Hierarchy {#px4_containers} +## px4-dev Container (Recommended) {#px4_containers} -The available containers are on [GitHub here](https://github.com/PX4/PX4-containers/tree/master?tab=readme-ov-file#container-hierarchy). +The **`px4-dev`** container is the recommended container for building PX4 firmware. +It is a single, multi-architecture container (linux/amd64 and linux/arm64) based on Ubuntu 24.04 that includes everything needed to build PX4 for NuttX hardware targets. -使用容器的最简单方法是通过 docker_run.sh 帮助程序脚本。 -The containers are hierarchical, such that containers have the functionality of their parents. -For example, the partial hierarchy below shows that the docker container with NuttX build tools (`px4-dev-nuttx-focal`) does not include ROS 2, while the simulation containers do: +It is published to both registries simultaneously: -```plain -- px4io/px4-dev-base-focal - - px4io/px4-dev-nuttx-focal - - px4io/px4-dev-simulation-focal - - px4io/px4-dev-ros-noetic - - px4io/px4-dev-ros2-foxy - - px4io/px4-dev-ros2-rolling -- px4io/px4-dev-base-jammy - - px4io/px4-dev-nuttx-jammy -``` +- **GitHub Container Registry:** [ghcr.io/px4/px4-dev](https://github.com/PX4/PX4-Autopilot/pkgs/container/px4-dev) +- **Docker Hub:** [px4io/px4-dev](https://hub.docker.com/r/px4io/px4-dev) -The most recent version can be accessed using the `latest` tag: `px4io/px4-dev-nuttx-focal:latest` -(available tags are listed for each container on _hub.docker.com_. -For example, the `px4io/px4-dev-nuttx-focal` tags can be found on [hub.docker.com here](https://hub.docker.com/r/px4io/px4-dev-nuttx-focal/tags?page=1&ordering=last_updated)). +The container includes: + +- Ubuntu 24.04 base +- ARM cross-compiler (`gcc-arm-none-eabi`) and Xtensa compiler (for ESP32 targets) +- Build tools: `cmake`, `ninja`, `ccache`, `make` +- Python 3 with PX4 build dependencies +- NuttX toolchain libraries (`libnewlib-arm-none-eabi`, etc.) + +The container is built from the [Dockerfile](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/Dockerfile) in the PX4 source tree using the [Container build workflow](https://github.com/PX4/PX4-Autopilot/actions/workflows/dev_container.yml). +Images are tagged with the PX4 version (e.g. `px4io/px4-dev:v1.16.0`). :::tip -Typically you should use a recent container, but not necessarily the `latest` (as this changes too often). +A `px4-sim` container with simulation tools (Gazebo Harmonic) is planned to complement `px4-dev` for simulation workflows. ::: +### Legacy Containers + +The older per-distro containers from [PX4/PX4-containers](https://github.com/PX4/PX4-containers) (e.g. `px4-dev-nuttx-jammy`, `px4-dev-ros2-humble`, etc.) are no longer recommended. +They will be replaced by `px4-dev` (for builds) and the upcoming `px4-sim` (for simulation). + ## 使用 Docker 容器 典型命令的语法如下所示。 @@ -121,7 +123,7 @@ Where, - `