PX4 User Guide Original Version === [TOC] :::info **Official Website: [PX4 User Guide](https://docs.px4.io/main/en/)** ::: PX4 Setting --- ### Download bootloader on laptop * Follow the instruction: [PX4-Bootloader](https://github.com/PX4/PX4-Bootloader) >Reference: https://hackmd.io/VYuIrmeMRSy2pcKGMvT15Q?view ### Download st-link on laptop 1. Download st-link ```shell= git clone http://github.com/texane/stlink.git cd stlink mkdir build cd build cmake .. make -j4 sudo make install ``` 2. Copy 49-stlinkv2.rules ```shell= cd stlink/config/udev/rules.d sudo cp 49-stlinkv2.rules /etc/udev/rules.d/ ``` >Reference: https://github.com/shengwen-tw/stm32f4-examples ### Bootloader program(only px4fmuv2_bl) 1. Connect st-link and check ![](https://i.imgur.com/fJo2JTy.jpg) 2. 燒錄程式 ```shell= cd PX4-Bootloader/build/px4fmuv2_bl st-flash write px4fmuv2_bl.bin 0x8000000 ``` >Reference: https://hackmd.io/VYuIrmeMRSy2pcKGMvT15Q?view ### Download Mavros :::info **You can download mavros on upboard or laptop** ::: 1. Download Mavors * Follow the instruction: [Install Mavros](https://hackmd.io/iOtCxeZtSSqi2rCyHt2dyg#Install-Mavros) 2. Test * Connect px4 & upboard ![](https://i.imgur.com/IaH9qRS.jpg) * Command ```shell= roslaunch mavros px4.launch ``` * Result ![](https://i.imgur.com/Z0DWPkQ.jpg) * Topic ![](https://i.imgur.com/wjvwU8Y.jpg) ![](https://i.imgur.com/HV439FC.jpg) 3. IMU data * Command ```shell= rostopic echo /mavros/imu/data ``` * Result ![](https://i.imgur.com/EA7cDFu.jpg) * Frame ![](https://i.imgur.com/T8GUJIX.png) Implement --- ### Basic Assembly * Follow the instruction: [無人機組裝](https://hackmd.io/E-y2BgvjTOKLia2niLHndQ) * Additional: You can mount upboard on multicopter * ![](https://i.imgur.com/173dd8K.jpg) ### Basic Configuration #### RC sysyem * Connection of RC system has already done by lab member #### Xbee Moudle * Follow the instruction: [天線設定](https://hackmd.io/TNvNXB9sQoilNvrLHINYDw#%E5%A4%A9%E7%B7%9A%E8%A8%AD%E5%AE%9A) #### OptiTrack * Follow the instruction: [OptiTrack](https://hackmd.io/TNvNXB9sQoilNvrLHINYDw#optiTrack) ### QGroundControl #### Download QGroundControl(QGC) * Follow the instruction: [QGC](https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html#ubuntu) #### Connection through usb * Connection * ![](https://i.imgur.com/acmLykV.jpg) * Add a link * Serial port & baud rate need to change according to your device. ![](https://i.imgur.com/PnR1RlJ.png) * Interface * Connection success, you will see the user interface. ![](https://i.imgur.com/C3PC1lA.png) #### Connection through WiFi * Upboard need to use network interface card to connect wifi. * Follow the instruction: [QGC通過mavros連接到飛控](https://blog.csdn.net/qq_38649880/article/details/88342904) #### Configuration * Firmware * Follow the instruction: [Install Stable PX4](https://docs.px4.io/main/en/config/firmware.html#install-stable-px4) * Airframe * Choose the best fit airframe according to your multicopter. For instance, [Quadrotor-X](https://docs.px4.io/main/en/airframes/airframe_reference.html#quadrotor-x) F450 is suitable for our drone. * Follow the instruction: [Airframe](https://docs.px4.io/main/en/config/airframe.html ) ![](https://i.imgur.com/Xv18Jn0.png) * Power moudal: * Follow the instruction: [Battery and Power Module Setup](https://docs.px4.io/main/en/config/battery.html) ![](https://i.imgur.com/ZaL1mZA.png) * Safety: * Follow the instruction: [Low Battery](https://docs.px4.io/main/en/config/safety.html#low-battery-failsafe) ![](https://i.imgur.com/BmBliMr.png) * Follow the instruction: [RC Loss](https://docs.px4.io/main/en/config/safety.html#rc-loss-failsafe) ![](https://i.imgur.com/iKTiyU0.png) * Actuators: * Choose appropriate ==**Airframe**== by instruction above. * Follow the instruction: [Motor Geometry](https://docs.px4.io/main/en/config/actuators.html#motor-geometry) * Rotation and order of motor according to Quadrotor-X. ![](https://i.imgur.com/T2AqjL3.png) ![](https://i.imgur.com/l6pAAjH.png) * Follow the instruction: [Actuator Outputs](https://docs.px4.io/main/en/config/actuators.html#actuator-outputs) * It is better to choose AUX output. ![](https://i.imgur.com/4iPLHgM.png) * Follow the instruction: [Actuator Testing](https://docs.px4.io/main/en/config/actuators.html#actuator-testing) * Make sure rotation of each motor is accurate before flying. ![](https://i.imgur.com/NvUPmQs.png) * If you have problem, check [Actuator Configuration and Testing](https://docs.px4.io/main/en/config/actuators.html#actuator-configuration-and-testing) #### Calibration ![](https://i.imgur.com/x02gjPN.png) * Compass * Follow the instruction: [Compass Calibration](https://docs.px4.io/main/en/config/compass.html#compass-calibration) * Gyroscope * Follow the instruction: [Gyroscope Calibration](https://docs.px4.io/main/en/config/gyroscope.html#gyroscope-calibration) * Accelerometer * Follow the instruction: [Accelerometer](https://docs.px4.io/main/en/config/accelerometer.html#accelerometer) ==Above three is done, click level to update.== * ESC * Follow the instruction: [ESC Calibration](https://docs.px4.io/main/en/advanced_config/esc_calibration.html#esc-calibration) ![](https://i.imgur.com/CbrTHke.png) #### Tuning * Follow the instruction: [Auto-tuning](https://docs.px4.io/main/en/config/autotune.html#auto-tuning) ![](https://i.imgur.com/t8Z2kMJ.png) #### Serial Setting * Concept: [Serial Port Configuration](https://docs.px4.io/main/en/peripherals/serial_configuration.html#serial-port-configuration) * Instruction: [MAVLink Peripherals (GCS/OSD/Companion)](https://docs.px4.io/main/en/peripherals/mavlink_peripherals.html#mavlink-peripherals-gcs-osd-companion) #### Parameters :::info **All setting can modify here** ::: ![](https://i.imgur.com/O7SUEsM.png) ### Flying #### Flight Mode * Concept: [Flight Modes](https://docs.px4.io/main/en/flight_modes/) * Configuration * Notice, Arm switch & Emergency kill switch must setup. * Arm switch: motor will not rotate until switch on. * Emergency kill switch: Force motor to stop. ![](https://i.imgur.com/9MtzllQ.png) #### Manual Mode {%youtube Kml9Gl0oOMA %} #### Offboard Mode :::danger Test of this mode is fail, probably due to nonlinearity of multicopter, PID tune is not suffieient to control our multicopter. ::: * Procedure * Usage: On-board processor and wifi link to ROS * Ground Station: Laptop(ROS + mavros) * Protocol: MAVlink * Commuciation medium: Wifi * Vehicle: Upboard & PX4 Upboard with ROS & mavros, connect to PX4 through usb. ![](https://i.imgur.com/I5Tfk4h.jpg) * GPS / Pose estimate * [Using Vision or Motion Capture Systems for Position Estimation](https://docs.px4.io/main/en/ros/external_position_estimation.html#specific-system-setups) * [基於PX4、樹莓派和Mocap(Optitrack)的室內飛行環境搭建](https://blog.csdn.net/qq_42879437/article/details/117514082?fbclid=IwAR0ST33CtXGXvtWUF2k2PrrCwiGSPqj0ZcK3VUGFmPOsyznJo8lpeypD7Yw#t14) * Image ![](https://i.imgur.com/axL85Vo.png) * Control Objective: * Position: x、y、z * Velocity: vx、vy、vz * Attitude: quaternion、roll/yaw/pitch rate、thrust * Parameter: ![](https://i.imgur.com/nyt65M7.png) * Example Code: [Official Example Code](https://github.com/PX4/PX4-Devguide/blob/master/en/ros/mavros_offboard.md) [mavros_offboard_control](https://github.com/raaslab/mavros_offboard_control) [offboard_control](https://github.com/TIERS/offboard-control) ###### tags: `PX4`