Table of Contents
The GPS driver/app reads data from an attached GPS module.
It is assumed here that you have a working serial connection to your FMU.
To start the GPS app on the FMU type:
nsh> gps start -m all
To check whether the app is running:
nsh> gps status
To stop, use:
nsh> gps stop
To see the output of the GPS app, first start the mavlink app and connect to a ground station. The gps app sends the sensor information to the mavlink app which finally transmits the data to the groundstation. Usually the gps app is started by the startup script and it tries to detect the type of gps receiver automatically.
Command Line Options
Further options can speed up the process of establishing communication with the gps. If you do not set -m or -b the gps app tries all combinations. This can take some time and therefore it is recommended to set the two values if possible.
--device / -d
For the standard gps plug this should be /dev/ttyS3
--mode / -m
You have the following options:
all, tries all modes with the most common baud rates
ubx, for u-blox devices (e. g. 3DR GPS uBlox LEA-6)
mtkcustom, for the MediaTek MT3329
--baud / -b
Set the baudrate of the gps.
--verbose / -v
Print verbose information for debugging.
--retry / -r
Force the app to retry to establish communication with the gps.
nsh> gps start -d /dev/ttyS3 -m ubx -b 9600
nsh> gps start -d /dev/ttyS3 -m mtkcustom -b 38400
The gps app is structured in different modules. Each module handles a different gps protocol (for different receivers). This structure allows to extend the app easily to support even more protocols.
Currently the structure and the code files is as follows:
- gps.c : the main file which starts the routines for the various protocols depending on the command line arguments.
- for the active protocol 2 pthreads are started
- main thread
- watchdog thread
- ubx.c : Handles the ubx protocol
- holds the definition of the main ubx loop and the ubx watchdog loop
- mtk.c : Handles support for the custom protocol of the MediaTek MT3329 receiver
- holds the definition of the main mtk loop and the mtk watchdog loop
For each module 2 loops need to be defined. The main loop and the watchdog loop. These are then started as separate threads in the gps_main function in gps.c
This is highly dependent on the protocol. In general, this thread should initialize the module and then start to parse the data coming from the gps module. Finally, the obtained information should be published via uORB to vehicle_gps_position. Look at the implementation in mtk.c if you need to implement support for a new protocol.
This loop measures the time since the last valid message fromt the gps receiver. Depending on the receiver type, the watchdog loop can try a re-configuration of the receiver if this time value is above a threshold. Also, the watchdog reports the subsystem health state to the subsystem_info loop of the commander app.