UAV Toolbox Support Package for PX4® Autopilots provides the option to simulate PX4 autopilot algorithms that you develop in Simulink. The workflow is based on PX4 SITL (Software in the Loop). The support package supports simulation of algorithms by generating an executable on the host, referred as PX4 Host Target, and the jMAVSim simulator.
The PX4 Host Target supports code generation and deployment like other supported hardware boards. You can also perform signal monitoring and parameter tuning of the Simulink model by selecting this option.
jMAVSim is one of the supported simulators for PX4-based targets. During the hardware setup of UAV Toolbox Support Package for PX4 Autopilots, this simulator is downloaded and installed, and allows you to view the flight of a quadcopter running the PX4 algorithm that you develop in Simulink. By using jMAVSim, you can test the algorithm for the desired take off, flight, and land actions.
You can use Hardware Setup process in UAV Toolbox Support Package for PX4 Autopilots to prepare the support package for using the PX4 Host Target and testing the connection with jMAVSim simulator.
Perform these steps as part of Hardware Setup to enable PX4 Host Target and test the jMAVSim simulator:
In the Select a PX4 Autopilot and build
configuration Hardware Setup screen, select PX4
Host Target as the PX4 Autopilot board. The supported
Build Target file is
Proceed with the subsequent step of Hardware Setup process to build the firmware and verify that the firmware build is successful.
In the Test Connection Hardware Setup screen, click Launch PX4 Host Target and jMAVSim. The jMAVSim simulator opens in a new window and shows the flight of the quadcopter. This is a test flight using a pre-configured algorithm in the support package to ensure that the necessary components for the simulator are installed.
After you prepare the flight controller algorithm using the Simulink blocks available in UAV Toolbox Support Package for PX4 Autopilots, you can launch the jMAVSim simulator to verify the flight. To do this:
In the Modeling tab, click Model Settings. In the Configuration Parameters dialog box:
In the Hardware board list, select PX4 Host Target.
Under Target Hardware resources > Build Options, select the Build action as Build, load and run.
Click Apply and then OK.
In the Hardware tab, select one of these options to launch jMAVSim simulator:
To view the flight of the PX4 based flight controller based on the algorithm that is present in the Simulink model, click Build, Deploy & Start. The jMAVSim simulator is launched after sometime in a separate window.
To view the flight of the PX4 based flight controller based on the algorithm and perform signal monitoring and parameter tuning of the Simulink model, click Monitor & Tune. The jMAVSim simulator is launched in a separate window. You can change the parameters in the Simulink model and view the change in the simulated flight at runtime in the jMAVSim simulator.
With PX4 Firmware v1.10.2, it has been observed that the PX4 Host Target may exhibit issues with modules not responding after one hour of simulation time.
On Ubuntu 18.04 platform, it is recommended that you set the sample time
as 1 millisecond for the Simulink models to be deployed on PX4 Host Target. If the sample time is greater
than 1 millisecond, issues may occur while writing to some uORB topics such