Skip to main content

File Reader GPS Example

Basic Knowledge Requirements
  1. Python Programming: Understanding basic Python programming concepts such as functions, loops, conditional statements, and type-checking.
  2. farm-ng GPS Service Overview: This overview provides a base understanding of the gRPC service the client you create will connect to.

This File Reader GPS example provides a utility for reading and parsing GPS messages from the event file. It can process two types of GPS messages: relposned and pvt. The user specifies the type of GPS message to parse, and the script reads the corresponding data, unpacks it, and prints it to the console.

You can either run this example directly on a brain by ssh'ing in, or use your local PC.

1. Obtain a log file

Record your own

See the Recorder App Guide for instructions.

Download the log file

You can also download a pre-recorded log file to run this example with.

Click here to download

[Optional] Make a Data folder

We are going to make a folder that will store all of our log files, including the one you just downloaded.

cd <to-your-base-directory>
mkdir <data-dir>
cd <data-dir>
mv ~/Download/2023_09_29_17_52_35_070804_dubnium-durian.0000.bin

Now you should navigate (in your terminal) to the farm-ng-amiga repository.

2. Install the farm-ng Brain ADK package

3. Install the example's dependencies

Setup

cd farm-ng-amiga/
Recommended

Create a virtual environment

python3 -m venv venv
source venv/bin/activate

Install

cd py/examples/file_reader_gps
pip install -r requirements.txt

4. Execute the Python script

Specify the log file, e.g.:

python main.py --file-name <path-from-above>/2023_09_29_17_52_35_070804_dubnium-durian.0000.bin
python main.py --file-name <path-to-your-file>
info

You should replace <path-to-your-file> with the path to your events binary file (.bin).

Tip

You can also specify a gps interface to read by adding the flag --topic-name

For example:

python main.py --file-name <path-to-your-file> --topic-name relposned
python main.py --file-name <path-to-your-file> --topic-name pvt

If everything worked correctly you should now see a large stream of text come up in your terminal!

The output should look something like this:

All available topics: ['/gps/pvt', '/gps/relposned']
Found 11 packets of gps/relposned

Message stamp: 92614.926564468
GPS time: 1695861128.4
Relative pose north: 2680.3909000000003
Relative pose east: -4297.41093
Relative pose down: -4.00042
Relative pose length: 506481.000063
Accuracy north: 0.0010000000474974513
Accuracy east: 0.0010000000474974513
Accuracy down: 0.0011399999493733048
Carrier solution: 2
GNSS fix ok: True
--------------------------------------------------

Congrats you are done!