Main Content

PX4 Read Position Setpoint

Read the position setpoints published by the PX4 Navigator module in the uORB topic position_setpoint_triplet

  • Library:
  • UAV Toolbox Support Package for PX4 Autopilots / PX4 Utility Blocks

Description

The PX4 Read Position Setpoint block outputs the position setpoints published by the PX4 navigator module in the position_setpoint_triplet uORB topic. The block outputs the coordinates of the current destination setpoint (Current), the next setpoint after the current destination (Next) and the most recent setpoint that was traversed (Previous). The block outputs the Previous, Current and Next position setpoints as coordinates in either the World Geodetic System of 1984 (WGS 84), local north-east-down (NED), or local east-north-up (ENU) coordinate systems.

You can create an autonomous mission in the plan view of the QGroundControl (QGC) and upload the mission to the PX4 Autopilot over MAVLink. For information on creating missions, see Plan View. The mission consists of waypoints such as TakeOff, Position (also known as Waypoint), Land and so on. The MAVLink module on the PX4 Autopilot decodes the mission data and stores it in the memory. The navigator module in PX4 retrieves the waypoints from the onboard memory and publishes them in the position_setpoint_triplet uORB topic. The Previous, Current, and Next setpoints are automatically updated by the navigator module when the vehicle reaches those waypoints.

Note

If the onboard companion computer is enabled with PX4 (PX4 parameter COM_OBS_AVOID is set to 1), the current waypoint will be updated using the waypoint data received from the onboard computer. The updated waypoint from the onboard computer is communicated to PX4 using the Path Planning Interface over MAVLink. The PX4 MAVLink module receives the waypoint and publishes the waypoint in vehicle_trajectory_waypoint uORB topic. When onboard computer workflow is enabled, this block reads the waypoint from vehicle_trajectory_waypoint uORB topic and outputs it as current waypoint.

The block also outputs the waypoint mode for the current position setpoint which indicates the corresponding waypoint type that has been set in the mission uploaded from QGroundControl (QGC). This helps in distinguishing the Current Waypoint types (TakeOff, Waypoint, Land) in Simulink.

Feed the coordinates that the block outputs directly to the controller algorithm designed in Simulink as input commands. Use the Type output to distinguish between waypoints and take corresponding appropriate action in the controller.

This block also reads the setpoint data for missions created in the QGC, for which the mission type is Flight plan. However, you cannot use this block to read setpoint data for geofencing and rally missions.

Among the flight plan missions, the supported mission commands whose waypoint data can be retrieved by the block are Takeoff, Land and Waypoint. Return to Launch (RTL) is not supported.

Note

The PX4 Read Position Setpoint block is supported only when you select Use default startup script (rcS) as the startup script option for the PX4 Autopilot during the Select System Startup Script in PX4 step of the Hardware Setup process. For more information, see Selecting Startup Script for PX4 Autopilot.

Note

The PX4 Read Position Setpoint block requires you to connect an SD card to the PX4 Autopilot. Ensure that the connected SD card does not contain any custom startup script (rc.txt) in the etc folder.

Note

The PX4 Read Position Setpoint  block cannot determine if the ongoing mission in QGroundControl is paused. You need to find a separate logic to determine if the mission is paused in QGroundControl.

Ports

Output

expand all

This port outputs the coordinates of the last traversed setpoint by the vehicle either in the WGS84 (latitude, longitude, and altitude) coordinate system or as local coordinates (x, y, and z) in the NED and ENU coordinate systems.

Data Types: double

This port outputs the coordinates of the current destination setpoint of the vehicle either in the WGS84 (latitude, longitude, and altitude) coordinate system or as local coordinates (x, y, and z) in NED and ENU coordinate systems.

Data Types: double

This port outputs the coordinates of the next setpoint after the current destination of the vehicle either in the WGS84 (latitude, longitude, and altitude) coordinate system or as local coordinates (x, y, and z) in NED and ENU coordinate systems.

Data Types: double

The Type output port provides information on the waypoint mode or mission command for the current setpoint that is set in the mission created and uploaded from QGroundControl. The port outputs one of the following types.

Waypoint Type or Mission Command Type Output
Takeoff3
Land4
Waypoint0
Loiter2
Idle5

Data Types: uint8

This port outputs the Simulink bus for the position_setpoint_triplet uORB topic. Use this port to avail other information that is published as part of the position_setpoint_triplet topic by the navigator module.

Dependencies

To enable this port, select the Output Simulink bus for position_setpoint_triplet parameter.

Data Types: Bus

This port outputs the Simulink bus for the vehicle_trajectory_waypoint uORB topic. Use this port to avail other information that is published as part of the vehicle_trajectory_waypoint topic such as yaw setpoint, velocity setpoint and so on.

Dependencies

To enable this port, select the Output Simulink bus for vehicle_trajectory_waypoint parameter.

Data Types: Bus

The port returns value 1 when there is no new waypoint received from the onboard computer during the last 0.5 seconds. Use this flag to enable any specific onboard failsafe action that is modelled with the controller.

Dependencies

To enable this port, select the Output onboard computer failsafe flag parameter.

Data Types: Boolean

This port outputs the status flag to indicate if the onboard computer workflow is enabled or not.

The port returns value 1 when the onboard computer is enabled with PX4 and 0 otherwise.

Dependencies

To enable this port, select the Output onboard computer enabled status parameter.

Data Types: Boolean

Input

Parameters

expand all

Main

Use this port to specify the desired coordinate format for the previous, current and next waypoints. The format can be specified as one of the following:

  • Local Coordinates (NED): Use this option to output the previous, current, and next setpoints as local coordinates (x, y, and z) in the NED frame. The transformation method that is used to convert the Geodetic coordinates provided by the PX4 to local coordinates is flat.

  • Local Coordinates (ENU): Use this option to output the previous, current, and next setpoints as local coordinates (x, y, and z) in the ENU frame. The transformation method that is used to convert the Geodetic coordinates provided by PX4 to local coordinates is flat.

  • WGS84: Use this option to output the previous, current, and next setpoints as the original Geodetic coordinates (latitude, longitude, and altitude) returned by PX4.

Specify the time interval at which the block reads values from the uORB network. When you specify this parameter as -1, Simulink determines the best sample time for the block based on the context of the block within the model.

Advanced

Select this parameter to enable Position Setpoint port. This port contains the full Simulink bus for the position_setpoint_triplet uORB topic. Use this port to avail other information that is published as part of the position_setpoint_triplet topic by the navigator module.

Select this parameter to enable Trajectory Waypoint port.

Select this parameter to enable Onboard Failsafe port. Use this port to model your own failsafe condition.

Select this parameter to enable Onboard Status port.

Version History

Introduced in R2021b