5.3 Frequently Asked Questions

image-20231213171753465

Caused by:
Validation error(s):
\### Validating other build tools ...
Unable to locate build tool "Pixhawk Toolchain C Compiler": echo
Unable to locate build tool "Pixhawk ToolchainC Pre-Linker": echo
Unable to locate build tool "Pixhawk Toolchain Archiver": echo

Compilation errors can be categorized as: MATLAB model issues, PX4 firmware issues, or MATLAB model–PX4 firmware linkage issues.

Answer:

MATLAB model issues: Code generation checks the model at the initial stage, so these errors typically appear within seconds of clicking Build. The most common issue is data type/dimension mismatch between interfaces. Click on the error module to jump to the problem.

image-20231213171854587

PX4 firmware issues: Compilation problems in PX4 source code are displayed in the MATLAB compilation log. The log indicates the problem location — modify accordingly. The platform's PX4 firmware is located at: PX4PSP\Firmware.

image-20231213171914714

MATLAB–PX4 linkage issues: These occur when PX4 firmware upgrades change interfaces, causing mismatches with MATLAB-generated code during the final link phase. MATLAB alone cannot pinpoint the error. Open WinWSL and re-execute compilation commands (e.g., make px4_fmu-v6c_default) to see the specific error.

image-20231213171934465

5.3.2 Using a delay module in the auto-generated controller causes the aircraft to fly erratically during HIL simulation. Why?

Problem description:

In the routine PX4PSP\RflySimAPIs\Exp02_FlightControl\e5-AttitudeCtrl\E5.1\HIL, the RC input channels CH1–CH4 were disconnected from the inputConditioning module and replaced with fixed value inputs. After starting HIL, the aircraft flies around erratically on the ground.

image-20231213172034155

image-20231213172057223

Answer:

A 200-step delay at 0.001 s step size is only 0.2 seconds. Since px4_simulink_app starts running immediately at power-on, control commands are sent before the flight controller's EKF filter has initialized, causing filter divergence and inaccurate position/attitude.

image-20231213172114402

Robust solution: Read the EKF state uORB message directly, verify filter initialization, then apply a delay before sending control commands. Simple solution: Increase the delay time, or write a trigger mechanism in a MATLAB function that only sends commands after the simulation time exceeds 60 s.

5.3.3 How to implement autonomous attitude control of a UAV?

Problem description:

We need the UAV to fly to a certain altitude, then respond to custom attitude angle setpoints and autonomously track them.

Answer:

Use an RC channel to transmit trigger information — e.g., when CH5 is at its maximum value, the program starts executing. Build a state machine in Simulink: take off first, wait until the target altitude is reached, then switch to attitude control. The specific controller design method falls under Simulink programming — consult relevant literature. To receive desired attitude angles from external sources, use the external control interface in 0.ApiExps\9.PX4CtrlExternalTune\Readme.pdf to subscribe to the rfly_ctrls message (passed in by an external program) in the flight controller.

5.3.4 How to get the result data from attitude control HIL simulation? Can the data be obtained from flight logs?

Answer:

Use the interface in 0.ApiExps\9.PX4CtrlExternalTune\Readme.pdf to obtain in real-time: the model's true attitude (simulation values) from Simulink and the flight controller's estimated attitude. Similar data can also be extracted from flight logs.

5.3.5 When compiling firmware via WinWSL, the error region 'AXI_SRAM' overflowed by 15401072 bytes appears. How to resolve this?

Problem description:

image-20231213172444957

image-20231213172452210

Answer:

The compiled firmware exceeds the flight controller's available memory. Edit the CMake file to comment out unused modules. For Pixhawk series flight controllers, the file is located at: PX4PSP\Firmware\boards\px4\

For example, for a Pixhawk 6C: C:\PX4PSP\Firmware\boards\px4\fmu-v6c\default.cmake

Comment out unused modules, then recompile:

……
    MODULES
        airspeed_selector
        px4_simulink_app
        attitude_estimator_q
        camera_feedback
        commander
        dataman
        ekf2
        esc_battery
        events
        flight_mode_manager
        # fw_att_control      Comment out the fixed-wing attitude control module
        fw_pos_control_l1
        gyro_calibration
        gyro_fft
        land_detector
        landing_target_estimator
        load_mon
        local_position_estimator
        logger
        mavlink
        mc_att_control
        mc_hover_thrust_estimator
        mc_pos_control
        mc_rate_control
        #micrortps_bridge
        navigator
        rc_update
        rover_pos_control
        sensors
        sih
        temperature_compensation
        # uuv_att_control     Comment out the UUV attitude control module
        # uuv_pos_control     Comment out the UUV position control module
        vmount
        # vtol_att_control    Comment out the VTOL attitude control module
……

Answer:

The RflySim platform uses MAVLink 2.

5.3.7 How does PX4 receive position information sent by QGC in Mission mode?

Answer:

Similar to Position mode: Position mode sends a single setpoint, while Mission mode sends the next waypoint each time the current one is reached.

Problem description:

Answer:

Refer to: [RflySim Installation Directory]\RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\Readme.pdf

You cannot run make px4_sitl_default directly. You must first run a MATLAB command to switch compilation targets, then run SITLRun to perform SIL simulation with the auto-generated controller.

Answer:

No, it does not completely replace the firmware — only the controller module is replaced.

5.3.10 Can you provide the code from the development training course on Bilibili? The code in the RflySim GitHub repository seems different, and the turntable experiment files are not on GitHub.

Answer:

Download and install the latest version of the platform. All training course routine files are located in: [Installation Directory]\PX4PSP\RflySimAPIs\5.RflySimFlyCtrl

5.3.11 During HIL simulation, the actuator_output value is not the calculated value. QGC shows two simultaneous outputs. What is the cause?

Answer:

Select "Yes" for the last item when installing the platform:

5.3.12 When doing HIL, should parameters be changed in the .m file or the param.c file? Changes to the .m file seem to have no effect.

Problem description:

Answer:

For the flashed experiment, connect to QGC and modify the controller parameters directly in QGC.

5.3.13 An error occurs during HIL in the tutorial case. Normal simulation works fine, but compilation fails. Using MATLAB 2020b with VS2017. How to resolve?

Problem description:

Answer:

The file is incomplete — the RflyUdpFast.cpp file was not copied. Ensure all required files are present.

5.3.14 After HIL uORB read/write testing, sensor data (compass, accelerometer) cannot be read in QGC settings. The sensor option is not displayed, and firmware cannot be reflashed. What is the cause?

Answer:

The sensor settings page is only displayed when the frame is set to a real aircraft frame (not a simulation frame).

Answer:

When writing a custom controller, ensure you correctly understand the controller's input/output interfaces. If PWM pulse width is written directly in the program, verify that the observation method reads the data correctly.

Answer:

Refer to: 5.RflySimFlyCtrl\0.ApiExps\2.PSPOfficialExps\px4demo_Serial_TxRx.slx

Answer:

Question 1 — Aircraft flying erratically: Please provide a screenshot or file of your controller for review.

Question 2 — Recording intermediate variables: You can:

  • Define a custom uORB message and review it in the flight log. Reference: RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\7.uORB-Create
  • Write variables to a .bin file stored on the SD card. Reference: RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\5.Log-Write-Read
  • Use CopterSim data logging. Reference: RflySimAPIs\2.RflySimUsage\1.BasicExps\e13_Log-Get

5.3.18 How to input x, y, z coordinates directly and send the vehicle to that position? Are there examples?

Answer:

  • Using the official controller: Use MAVLink / Offboard mode.
  • Using a custom controller: Use the rfly_ctrl interface. Reference: RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\9.PX4CtrlExternalTune

For more questions, please visit: https://github.com/RflySim/Docs/issues

results matching ""

    No results matching ""