### GDB Initial Output Example Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/advanced_config/bootloader_update.md Example of the initial output displayed when starting a GDB session for bootloader operations. ```text GNU gdb (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 8.0.50.20171128-git Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from px4fmuv5_bl.elf...done. ``` -------------------------------- ### Install PX4 Development Tools and Simulation Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/dev_setup/dev_env_mac.md Installs necessary toolchain packages, Python dependencies, and Gazebo simulation tools using the provided setup script. The `--sim-tools` flag includes Gazebo. ```shell ./Tools/setup/macos.sh --sim-tools ``` -------------------------------- ### Setup Cross Compiler Toolchain Directory Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/flight_controller/beaglebone_blue.md Creates and sets permissions for the directory where the ARM cross-compiler toolchain will be installed. ```bash mkdir -p /opt/bbblue_toolchain/gcc-arm-linux-gnueabihf chmod -R 777 /opt/bbblue_toolchain cd /opt/bbblue_toolchain/gcc-arm-linux-gnueabihf ``` -------------------------------- ### Run ROS Melodic Setup Script Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/ros/mavros_installation.md Execute the downloaded ubuntu_sim_ros_melodic.sh script to set up ROS Melodic and PX4. This script includes MAVROS installation. ```sh bash ubuntu_sim_ros_melodic.sh ``` -------------------------------- ### Check Netplan Installation Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/companion_computer/holybro_pixhawk_jetson_baseboard.md Verify if Netplan is installed on the system. If not, install it using apt. ```bash netplan -h ``` ```bash sudo apt update sudo apt install netplan.io ``` -------------------------------- ### Set Horizontal Acceptance Radius for Precision Landing Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/advanced_config/parameter_reference.md Configure the PLD_HACC_RAD parameter to define the horizontal acceptance radius. The system will start descending if it is closer above the landing target than this radius. ```text PLD_HACC_RAD: 0.2 (m) ``` -------------------------------- ### Run PX4 SITL Simulation with Docker Source: https://github.com/px4/px4-autopilot/blob/main/README.md Start a PX4 Software-in-the-Loop (SITL) simulation using Docker. This is a quick way to get started without complex build tool setup. Ensure Docker is installed and running. ```bash docker run --rm -it -p 14550:14550/udp px4io/px4-sitl:latest ``` -------------------------------- ### Manual Download and Run Setup Script Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/dev_setup/dev_env_linux_ubuntu.md Alternatively, download the ubuntu.sh and requirements.txt files directly and then execute the bash script. This method is useful if you only need the setup scripts without cloning the entire repository initially. ```sh wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/ubuntu.sh ``` ```sh wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/requirements.txt ``` ```sh bash ubuntu.sh ``` -------------------------------- ### Download and Run Arch Setup Scripts Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/dev_setup/dev_env_linux_arch.md Download the arch.sh and requirements.txt scripts individually and then execute the arch.sh script. This is useful if you only need the setup scripts without cloning the entire repository. ```bash wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/arch.sh wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/requirements.txt bash arch.sh ``` -------------------------------- ### TFmini Driver Start Example Source: https://github.com/px4/px4-autopilot/blob/main/docs/zh/modules/modules_driver_distance_sensor.md Example of starting the TFmini serial bus driver on a specific serial device. The 'stop' command is used to halt the driver. ```bash tfmini start -d /dev/ttyS1 ``` ```bash tfmini stop ``` -------------------------------- ### uLanding Radar Driver Start Example Source: https://github.com/px4/px4-autopilot/blob/main/docs/zh/modules/modules_driver_distance_sensor.md Example of starting the uLanding Radar serial bus driver on a specified serial device. The 'stop' command is used to halt the driver. ```bash ulanding_radar start -d /dev/ttyS1 ``` ```bash ulanding_radar stop ``` -------------------------------- ### Start Custom Application Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/concept/system_startup.md Add this command to `extras.txt` to start a custom application after the main system boot. Ensure the application name is correct to avoid boot failures. ```sh custom_app start ``` -------------------------------- ### Download PX4 Setup Scripts Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/flight_controller/raspberry_pi_navio2.md Download the `ubuntu.sh` and `requirements.txt` scripts from the PX4 repository to set up the development environment. ```sh wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/ubuntu.sh wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/requirements.txt ``` -------------------------------- ### Install gfortran Compiler Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/sim_gazebo_gz/tools_avl_automation.md Command to install the gfortran compiler on Ubuntu, which may be required for AVL setup. ```bash sudo apt update sudo apt install gfortran ``` -------------------------------- ### Run Example Mode Manual C++ Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/ros2/px4_ros2_control_interface.md Execute the example_mode_manual C++ ROS 2 node to register a custom manual mode. This demonstrates the registration process and expected output. ```sh ros2 run example_mode_manual_cpp example_mode_manual ``` -------------------------------- ### Install ROS 2 Foxy on Ubuntu Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/ros2/user_guide.md Instructions for installing ROS 2 Foxy on Ubuntu 20.04. Refer to the official guide for detailed steps. ```sh # Follow the official installation guide: [Install ROS 2 Foxy](https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html). You can install _either_ the desktop (`ros-foxy-desktop`) _or_ bare-bones versions (`ros-foxy-ros-base`), _and_ the development tools (`ros-dev-tools`). ``` -------------------------------- ### List All System Parameters Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/advanced/parameters_and_configurations.md Use the `param show` command in the system console to list all available system parameters. ```sh param show ``` -------------------------------- ### DroneCAN Firmware Database Entry Example Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/dronecan/index.md An example entry in the `/fs/microsd/ufw/FW.db` file, mapping a board ID to its firmware filename. This format is used to track installed firmware versions. ```txt 122.bin=122-1.17.63eeff1a.uavcan.bin ``` -------------------------------- ### Start Batt_smbus Driver Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/smart_batteries/rotoye_batmon.md Start the batt_smbus driver from the MAVLink console. Use the -X flag for external buses and specify the bus number and I2C address for each BatMon. This example shows how to start two BatMons on external bus 1 with addresses 0x0b and 0x0c. ```shell batt_smbus start -X -b 1 -a 11 # External bus 1, address 0x0b ``` ```shell batt_smbus start -X -b 1 -a 12 # External bus 1, address 0x0c ``` -------------------------------- ### Debian Version Formatting Examples Source: https://github.com/px4/px4-autopilot/blob/main/docs/zh/hardware/board_packaging.md This table illustrates how Git tags are converted into Debian-compatible version strings. It shows examples for stable releases, pre-releases, and development builds. ```text | Git Tag | Debian Version | 备注 | | --------------------------- | -------------------------- | --------------------------------------------------------- | | `v1.17.0` | `1.17.0` | Stable release | | `v1.17.0-beta1` | `1.17.0~beta1` | Pre-release (`~` sorts before release) | | `v1.17.0-alpha1-42-gabcdef` | `1.17.0~alpha1.42.gabcdef` | Development build | ``` -------------------------------- ### Optional and Mandatory Application Startup Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/concept/system_startup.md Use `set +e` and `set -e` in `extras.txt` to control whether boot fails if an application is unknown or fails to start. Optional applications will not abort boot. ```sh set +e optional_app start # Will not result in boot failure if optional_app is unknown or fails set -e mandatory_app start # Will abort boot if mandatory_app is unknown or fails ``` -------------------------------- ### Start Logging Immediately Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/dev_log/logging.md Use this command to start logging immediately, overriding the arming state. This is useful for starting logs before arming. ```bash logger on ``` -------------------------------- ### Start Micro XRCE-DDS Agent (Snap Package) Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/middleware/uxrce_dds.md Start the Micro XRCE-DDS Agent installed via snap package. Note the different command name compared to a standalone build. It uses UDP4 transport and port 8888. ```sh micro-xrce-dds-agent udp4 -p 8888 ``` -------------------------------- ### Display Make Help Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/debug/simulation_debugging.md View all available make targets in the build directory to understand available commands and options. ```sh make help ``` -------------------------------- ### Run Ubuntu Setup Script Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/dev_setup/dev_env_linux_ubuntu.md Execute the ubuntu.sh script to install all necessary development tools and dependencies for PX4 on a clean Ubuntu LTS system. Options like --no-nuttx and --no-sim-tools can be used to customize the installation. ```sh bash ./PX4-Autopilot/Tools/setup/ubuntu.sh ``` -------------------------------- ### Install ROS 2 Humble Desktop Full Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/companion_computer/holybro_pixhawk_jetson_baseboard.md Install the ROS 2 Humble Desktop Full package on the Jetson using apt. This is recommended for further ROS 2 development. ```shell sudo apt install -y ros-humble-desktop-full -y ``` -------------------------------- ### Example SBOM File Path Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/contribute/sbom.md This shows the typical location and naming convention for an SBOM file within the build directory. ```txt build//.sbom.spdx.json ``` -------------------------------- ### Add OSRF Gazebo Repository Source: https://github.com/px4/px4-autopilot/blob/main/docs/uk/simulation/px4_sitl_prebuilt_packages.md Adds the OSRF Gazebo repository to your system for installing the px4-gazebo package. This is a one-time setup. ```bash # Add OSRF Gazebo repository (one-time setup) sudo curl -fsSL https://packages.osrfoundation.org/gazebo.gpg \ -o /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] \ http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" \ | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null sudo apt update ``` -------------------------------- ### postinst Script for Package Installation Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/hardware/board_packaging.md Automates tasks after package installation, including creating symlinks, setting up directories, and reloading systemd. ```bash #!/usr/bin/env bash set -e # Create px4-* symlinks if [ -f /usr/bin/px4-alias.sh ]; then grep "^alias " /usr/bin/px4-alias.sh | \ sed "s/alias \(px4-[a-zA-Z0-9_]*\)=.*/\1/" | while read cmd; do ln -sf px4 "/usr/bin/${cmd}" done fi # Create data directories mkdir -p /data/px4/param mkdir -p /data/px4/etc/extras # Reload systemd if command -v systemctl > /dev/null 2>&1; then systemctl daemon-reload fi ``` -------------------------------- ### Restart WSL Environment Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/dev_setup/dev_env_windows_wsl.md After the toolchain installation, restart the WSL environment by exiting the shell, shutting down WSL, and then starting it again. This ensures all changes are applied. ```shell exit wsl --shutdown wsl ``` -------------------------------- ### Start System Power Simulation Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/modules/modules_system.md Starts the system power simulation module. ```bash system_power_simulation start ``` -------------------------------- ### Install and Use i2c-tools for Device Detection Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/flight_controller/raspberry_pi_pilotpi_rpios.md Install the i2c-tools package and use `i2cdetect` to scan the I2C bus. The output will help identify connected I2C devices by their address. For example, `1e` indicates a HMC5883 compass, and `0e` indicates an IST8310 compass. ```sh sudo apt-get update sudo apt-get install i2c-tools i2cdetect -y 0 ``` ```text 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- 0e -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- ``` -------------------------------- ### Install Full GStreamer Packages (Ubuntu Companion) Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/companion_computer/video_streaming.md Installs the full set of GStreamer development packages on an Ubuntu companion computer, mirroring QGC dependencies. ```sh DEBIAN_FRONTEND=noninteractive apt-get -y --quiet install libgstreamer1.0-dev libgstreamer-plugins-bad1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-gl1.0-0 gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-rtp gstreamer1.0-gl gstreamer1.0-libav gstreamer1.0-rtsp gstreamer1.0-vaapi gstreamer1.0-x ``` -------------------------------- ### Start Gazebo SITL with X500 Quadrotor and Downward LIDAR Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/sensor/rangefinders.md Use this command to start the PX4 SITL simulator with a Quadrotor(x500) model that includes a 1D LIDAR sensor facing downwards. This setup is suitable for testing landing and terrain following use cases. ```sh make px4_sitl gz_x500_lidar_down ``` -------------------------------- ### Start Gazebo Classic with IDE Support Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/sim_gazebo_classic/index.md Launch Gazebo Classic with IDE support using a make target. This allows for separate debugging of Gazebo and PX4. ```sh make px4_sitl gazebo-classic___ide ``` ```sh make px4_sitl gazebo-classic_iris_ide ``` -------------------------------- ### C++ Class Example Following PX4 Style Guide Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/contribute/code.md Illustrates C++ class structure, method naming, private member variable naming, and constant declaration according to PX4's modified Google C++ style guide. Use this as a template for new code. ```cpp class MyClass { public: /** * @brief Description of what this function does. * * @param[in] input_param Clear description of the input [units] * @return Whatever we are returning [units] */ float doSomething(const float input_param) const { const float in_scope_variable = input_param + kConstantFloat; return in_scope_variable * _private_member_variable; } void setPrivateMember(const float private_member_variable) { _private_member_variable = private_member_variable; } /** * @return Whatever we are "getting" [units] */ float getPrivateMember() const { return _private_member_variable; } private: // Clear description of the constant if not completely obvious from the name [units] static constexpr float kConstantFloat = ...; // Clear description of the variable if not completely obvious from the name [units] float _private_member_variable{...}; }; ``` -------------------------------- ### Download ROS Melodic Setup Script Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/ros/mavros_installation.md Download the ubuntu_sim_ros_melodic.sh script using wget. This script is used for setting up ROS Melodic with PX4. ```sh wget https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_ros_melodic.sh ``` -------------------------------- ### Start Gazebo Simulation World Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/sim_gazebo_gz/gazebo_models.md This command launches the Gazebo simulation world. It is typically run in a separate terminal when using the standalone PX4 SITL setup. ```bash python3 /path/to/simulation-gazebo --world windy ``` -------------------------------- ### Get Docker Container IP Address Source: https://github.com/px4/px4-autopilot/blob/main/docs/en/test_and_ci/docker.md Use this command to find the IP address of your Docker container, which is necessary for manual communication link setup with QGroundControl. ```bash $ docker inspect -f '{ {range .NetworkSettings.Networks}}{ {.IPAddress}}{ {end}}' mycontainer ```