Skip to content

MATLAB Command-Line Interface

The RflySim platform also supports running related commands via the MATLAB command-line window, specifically including the following:

1.1. PX4Upload

Enables one-click upload of PX4 firmware to the flight controller. The firmware being uploaded is located at: \PX4PSP\Firmware\build[BuildCommand][BuildCommand].px4 (e.g., [BuildCommand] could be px4_fmu-v6x_default).

PX4Upload

After executing the above command, a black window will pop up, prompting the user to connect/disconnect the flight controller and displaying a progress bar for the upload.

1.2. PX4CMD

Replaces firmware compilation options. To switch to the compilation environment for the Pixhawk6C flight controller, perform the following:

PX4CMD('px4_fmu-v6c_default')

or

PX4CMD 'px4_fmu-v6c_default'

1.3. PX4Build

Performs firmware compilation.

1.4. PX4AppName

Renames the px4_simulink_app module in the PX4 software, enabling support for multiple automatic code generation programs. For detailed usage, see:

PX4AppName('rfly_simulink_app')

% or

PX4AppName 'rfly_simulink_app'

Relevant examples can be found at: [RflySim Installation Directory]\RflySimAPIs\5.RflySimFlyCtrl\3.CustExps\e0_AdvApiExps\1.CusMaskPX4Code and [RflySim Installation Directory]\RflySimAPIs\5.RflySimFlyCtrl\3.CustExps\e0_AdvApiExps\2.RenamePX4App

1.5. PX4AppLoad

Loads the renamed PX4 software app, used to import previously developed app programs. Usage is as follows:

PX4AppLoad('C:\PX4PSP\rfly_simulink_app')

or

PX4AppLoad 'C:\PX4PSP\rfly_simulink_app'

Relevant examples can be found at: [RflySim Installation Directory]\RflySimAPIs\5.RflySimFlyCtrl\3.CustExps\e0_AdvApiExps\1.CusMaskPX4Code and [RflySim Installation Directory]\RflySimAPIs\5.RflySimFlyCtrl\3.CustExps\e0_AdvApiExps\3.LoadPX4App

1.6. PX4ModiFile

Replaces parts of the PX4 software code via an Excel-based method. Usage is as follows:

PX4ModiFile('C:\Users\dream\Desktop\自定义屏献UORB消息的例子px4Block.xlsx')

Relevant examples can be found at: [RflySim Installation Directory]\RflySimAPIs\5.RflySimFlyCtrl\3.CustExps\e0_AdvApiExps\1.CusMaskPX4Code and [RflySim Installation Directory]\RflySimAPIs\5.RflySimFlyCtrl\3.CustExps\e0_AdvApiExps\2.RenamePX4App

1.7. PX4Official

Generates official firmware (without output masking) directly via command execution. This can be used to restore a flight controller for external control in HITL mode, or to repair a faulty flight controller. Usage is as follows:

PX4Official

After executing the above command, input the following command to upload the official firmware to the flight controller:

PX4Upload

1.8. PX4SitlSet (RflySim Toolchain Personal Edition and above)

Enables the current automatic code generation controller (px4_simulink_app) to support SITL simulation. Usage: After building the Simulink program to generate the hardware-in-the-loop .px4 file, run PX4SitlSet, then run SITLRun (for a standard quadcopter), or other SITL simulation scripts driven by DLL models, to perform hardware-software-in-the-loop simulation of the automatically generated algorithm. Command format:

PX4SitlSet
**Related example routines can be found at:** [[RflySim installation directory]\RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\1.FullThrottleCodeGen](../px4psp/RflySimAPIs/5.RflySimFlyCtrl/0.ApiExps\14.SITLVeriGenCodeFirm\1.FullThrottleCodeGen\Readme.pdf), [[RflySim installation directory]\RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\2.AttitudeCtrlCodeGen](../px4psp/RflySimAPIs/5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\2.AttitudeCtrlCodeGen\Readme.pdf), [[RflySim installation directory]\RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\3.OffboardCtrlCodeGen](../px4psp/RflySimAPIs/5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\3.OffboardCtrlCodeGen\Readme.pdf).

1.9. PX4SitlRec (RflySim toolchain Personal Edition and above)

In SITL simulation code, remove the px4_simulink_app (automated code-generation controller) and revert to standard Software-in-the-Loop (SITL) mode, thereby re-enabling QGC control and Offboard external control. Note: After running the PX4SitlSet test to complete Simulink controller validation, if you intend to run official platform routines such as vision-based control or external control, you must first execute PX4SitlRec to restore the environment. Command format:

PX4SitlRec

Related example routines can be found at: [RflySim installation directory]\RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\1.FullThrottleCodeGen, [RflySim installation directory]\RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\2.AttitudeCtrlCodeGen, [RflySim installation directory]\RflySimAPIs\5.RflySimFlyCtrl\0.ApiExps\14.SITLVeriGenCodeFirm\3.OffboardCtrlCodeGen.