Read GPS module data

This function is to obtain longitude, latitude and altitude data by reading GPS module data and parsing GPS data through the terminal.

1. Read GPS data through the terminal

terminal input:

image-20220616144805709

Then we look at the topic data, the terminal input:

image-20220616144931422

Regarding the data on these topics of GPS, here is an explanation.

topictypeDescription
/extend_fixgps_common/GPSFixGPSFix messages contain GPS satellite status and positioning information
/fixsensor_msgs/NavSatFixGPS location information
/time_referencesensor_msgs/TimeReferencdGPS time information
/velgeometry_msgs/TwistStampedGPS speed information

For each topic message type, please refer to the official website URL,

gps_common/GPSFix Documentation (ros.org)

sensor_msgs/NavSatFix Documentation (ros.org)

sensor_msgs/TimeReference Documentation (ros.org)

geometry_msgs/TwistStamped Documentation (ros.org)

We can print out these topic messages on the terminal, and what we get is the GPS data. Take printing /fix as an example, the terminal input

The terminal will print out the following data,

image-20220616151122053

Among them, latitude, longitude, altitude represent latitude, longitude and altitude respectively.

2、Read the latitude, longitude and altitude of GPS data

terminal runs,

image-20220616150450647

The data printed by the terminal is the latitude, longitude and altitude of the current GPS module, look at the source code, read_lat_long.py

The program subscribes to the data of the /fix topic, then parses it in the callback function, and finally prints it to the terminal.