Main Content

GPS

Read vehicle_gps_position uORB topic and obtain GPS coordinates

Since R2020a

Add-On Required: This feature requires the UAV Toolbox Support Package for PX4 Autopilots add-on.

  • GPS block

Libraries:
UAV Toolbox Support Package for PX4 Autopilots / PX4 Sensor Blocks

Description

The GPS block reads the vehicle_gps_position uORB topic and outputs the GPS coordinates of the GPS receiver connected to the PX4 Autopilot. The block outputs latitude, longitude and altitude, by default, and it also provides the option to add more outputs that are based on the GPS coordinates.

On each simulation step, the block checks if a new message is available on the vehicle_gps_position topic. If a new message is available, the block retrieves the message and outputs it, and the timestamp is updated. If a new message is not available, the block outputs the last updated uORB message and the timestamp is not updated. If a message has not been received since the start of the simulation, the outputs are zeroes.

During Normal mode simulation, the block outputs zeroes.

During Connected I/O simulation, this block reads data from the peripherals of the hardware.

Ports

Output

expand all

The Status output indicates if the vehicle_gps_position uORB message was received during a previous time step or not. A value of 0 indicates that the uORB data at the outputs is the latest, and a value of 1 indicates that the uORB data was not updated during the previous time step.

This output can be used to trigger subsystems for processing new messages received in the uORB network.

Data Types: Boolean

The latitude coordinate based on the current position of the GPS receiver connected to PX4 Autopilot, as read from the vehicle_gps_position uORB topic.

Data Types: int32

The longitude coordinate based on the current position of the GPS receiver connected to PX4 Autopilot, as read from the vehicle_gps_position uORB topic.

Data Types: int32

The altitude coordinate based on the current position of the GPS receiver above Mean Sea Level, as read from the vehicle_gps_position uORB topic.

Data Types: int32

The ground speed coordinate from the GPS receiver connected to PX4 Autopilot, as read from the vehicle_gps_position uORB topic.

Dependencies

This output appears only if you have selected the Ground speed (m/s) parameter.

Data Types: float32

The course over ground (not the heading, but the direction of movement) value within (-π to π), based on the direction of movement of the GPS receiver connected to PX4 Autopilot, as read from the vehicle_gps_position uORB topic.

Dependencies

This output appears only if you have selected the Course (rad) parameter.

Data Types: float32

The type of signal or technique being used by the GPS receiver to determine the location, as read from the vehicle_gps_position uORB topic. The following table represents the values for this signal:

ValueType of Fix
0-1No fix
22D fix
33D fix
4RTCM code differential
5Real-Time Kinematic, float
6Real-Time Kinematic, fixed
8Extrapolated. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix.

Dependencies

This output appears only if you have selected the GPS fix type parameter.

Data Types: uint8

The number of satellites used by the GPS receiver to determine the GPS coordinates, as read from the vehicle_gps_position uORB topic.

Dependencies

This output appears only if you have selected the Number of satellites parameter.

Data Types: uint8

UTC timestamp in Unix time (in microseconds) obtained from the GPS receiver, as read from the vehicle_gps_position uORB topic. The value might be unavailable right after cold start, indicated by a value of 0.

Dependencies

This output appears only if you have selected the Unix timestamp UTC (us) parameter.

Data Types: uint64

The horizontal and vertical dilution of precisions (DOP) used by the GPS receiver, as read from the vehicle_gps_position uORB topic.

Dependencies

This output appears only if you have selected the Dilution of precision parameter.

Data Types: float32

The north, east, and down velocity measured by the GPS receiver connected to the PX4 Autopilot, as read from the vehicle_gps_position uORB topic.

Dependencies

This output appears only if you have selected the NED velocity parameter.

Data Types: float32

The altitude coordinate based on the current position of the GPS receiver based on ellipsoidal model (1e-3 meters above Ellipsoid), as read from the vehicle_gps_position uORB topic.

Dependencies

This output appears only if you have selected the Altitude above Ellipsoid parameter.

Data Types: int32

The jamming indicator value of the GPS receiver, which indicates if jamming of signals is occurring or not, as read from the vehicle_gps_position uORB topic.

Dependencies

This output appears only if you have selected the Jamming indicator parameter.

Data Types: int32

Represents the time since the PX4 system start when the vehicle_gps_position uORB topic was last updated.

Dependencies

This output appears only if you have selected the PX4 timestamp (us) parameter.

Data Types: uint64

Parameters

expand all

Main tab

Enter the time interval at which the block reads values from the uORB network.

When you set this parameter to -1, Simulink® determines the best sample time for the block based on the block context within the model.

Advanced Tab
  • When you select this option, the read operation runs in Blocking Mode. The read operation is blocked while waiting for the requested data to be available. When the data is available, the block outputs the selected values, and the Status port is set to 0.

    The board waits for the message in Blocking Mode for the time mentioned in the Timeout in seconds. If the data is not received before the timeout, then the Status port outputs 1 and the block outputs the last received value.

    A task overrun occurs if the target hardware is still waiting for the data to be available when the next read operation is scheduled to begin.

    To fix overruns, increase the time step by using the Sample time parameter.

  • When you clear this option, the read operation runs in Non-Blocking Mode. In this mode, the block does not wait for the requested data to be available.

Version History

Introduced in R2020a