Hauptinhalt

Simulate Manual Control for Fixed-Wing with PX4 Host Target

This example shows how to use the UAV Toolbox Support Package for PX4® Autopilots to take manual control inputs from Joystick / RC Transmitter and control the fixed-wing flight.

Prerequisites

Required Third-Party Software

Recommended: QGC version 4.3.0

Model

Open the px4demo_ManualControl_FixedWing model.

This example model is configured to use SIH in Host Target as simulator, Fixed-wing (plane) as vehicle type, and jMAVSim as the visualizer. Perform these steps if you have changed the hardware or not using the pre-configured model.

1. Open the model.

2. Go to Modeling > Model Settings to open the Configuration Parameters dialog box.

3. Open the Hardware Implementation pane, and select PX4 Host Target.

4. Expand Target hardware resources for that board and ensure the settings as shown in this image.

Read Desired Position and Current Position

In this example, the quadcopter must try to maintain the desired position and altitude. According to the error in position, the pitch and roll commands are generated and the output to the actuator motors are modified.

The Input Sliders in the model can be used to provide the desired coordinates of the flight of the quadcopter.

  • The variable des_alt represents an altitude at which the vehicle hovers. The altitude value can be set using the respective slider or directly changing the value of constant des_alt.

  • The desired position for X and Y can be set by assigning desired values to constants des_x and des_y or using respective sliders.

In the Desired Position, Altitude and Yaw area, you can also provide dynamic inputs (instead of only static inputs) to test the tracking capabilities of the position controller. In this example, the sine wave is used as the dynamic input and can be selected using respective manual switches.

The vehicle's position in the NED reference frame and its rates can be accessed using uORB Read block, which is configured to read the message 'vehicle_local_position'.

Run the Model on PX4 Host Target and Start jMAVSim Simulator

In this task, you select the Hardware Board as PX4 Host Target and start the jMAVSim simulator.

1. In the Modeling tab, click Model Settings.

2. In the Configuration Parameters dialog box, navigate to the Hardware Implementation pane:

  • Set the Hardware board to PX4 Host Target (the same option that you selected during Hardware Setup screens).

  • In the Target Hardware Resources section, set the Build options to Build, load and run.

3. Once Simulink model is ready, there are two options to build the Simulink model and launch the simulator:

  • On the Hardware tab, in the Mode section, select Run on board and then click Build, Deploy & Start. Once the model is deployed in the target hardware (PX4 Host Target in this example), the jMAVSim simulator is launched and the model executes independently in target hardware without having any dependencies and without communication with Simulink.

  • On the Hardware tab, in the Mode section, select Run on board and then click Monitor & Tune. This launches QGC and jMAVSim. In the jMAVSim simulator, you can monitor and log the data while the model executes in the target hardware.

During Monitor and Tune operation, various parameters and variables can be monitored using display or scope blocks.

4. In the QGC, select SIH plane AERT as the airframe in the Vehicle Setup -> Airframe tab of QGC.

5. Click Apply and Restart. Restart QGC to apply the changes.

6. Click Actuators and setup the actuators.

7. Click Safety and select SIH enabled from HITL Enabled drop-down list.

8. Configure the communication links by clicking the gear icon in QGC and navigating to Application Settings > Comm Links. For more information see Configuring QGC for Vehicle Visualization Without a Display.

9. Arm the vehicle

10. Use the slider control to increase the throttle to its maximum. This gives full power to the fixed-wing plane.

11. Adjust Roll, Pitch, and Yaw:

  • Roll: This controls the rotation of the plane around its front-to-back axis. Adjusting roll will tilt the plane to the left or right.

  • Pitch: This controls the rotation around the side-to-side axis. Changing pitch will make the plane nose up or down.

  • Yaw: This controls the rotation around the vertical axis. Altering yaw will turn the plane left or right.

Note: As this is manual control, flight might not be stable. Small adjustments can lead to significant changes in the plane's behavior. Make gradual inputs to better manage control.

By default, this example uses jMAVSim for visualization. For more information, see Deployment and Verification Using PX4 Host Target and jMAVSim/Simulink.

However, you can opt to use Simulink for visualization instead. You have the option to use either:

  • Simulation 3D UAV Vehicle Visualization (high fidelity)

  • UAV Animation Visualization (low fidelity visualizer)

Additionally, you can select the fixed-wing option in the airframe settings. For more information, see Visualize 3D Scenarios in Unreal Engine with PX4 Host Target Simulation.

Related Topics

Deployment and Verification Using PX4 Host Target and jMAVSim/Simulink