Welcome to GPS Module repository
3.2 Draw GPS track
Draw GPS track
This function plots real-time GPS data information and displays it in RVIZ.
1. Implementation principle
It is impossible to directly visualize GPS information. We need to convert the coordinate system and convert the GPS trajectory from the latitude and longitude WGS-84 coordinates to the real world XYZ coordinate system. With the XYZ coordinates in the real world, we can display the path through RVIZ and simulate the trajectory of GPS. The trajectory is to accumulate the position of each GPS coordinate relative to the first coordinate, and then accumulate to get the trajectory.
2. Startup steps
terminal input,,
roslaunch nmea_navsat_driver gps_path_to_rviz.launch

In the interface displayed by RVIZ we can see that the green line is slowly extending, as shown in the following figure,

3. Launch code analysis
x<launch> <arg name="port" default="/dev/myserial" /> <arg name="baud" default="9600" /> <arg name="frame_id" default="gps" /> <arg name="time_ref_source" default="gps" /> <arg name="useRMC" default="False" /> <node name="nmea_serial_driver_node" pkg="nmea_navsat_driver" type="nmea_serial_driver" output="screen"> <param name="port" value="$(arg port)"/> <param name="baud" value="$(arg baud)" /> <param name="frame_id" value="$(arg frame_id)" /> <param name="time_ref_source" value="$(arg time_ref_source)" /> <param name="useRMC" value="$(arg useRMC)" /> </node>
<node name="gps_path_node" pkg="nmea_navsat_driver" type="Draw_GPS_Path" output="screen"/> <node name="rviz" pkg="rviz" type="rviz" args="-d $(find nmea_navsat_driver)/rviz/gps_path.rviz"/></launch>Three nodes are started, namely nmea_serial_driver_node to read GPS data, gps_path_node to draw GPS data trajectory and rviz node.
Among them, the source code GPS_Path.cpp of the gps_path_node node can be seen under nmea_navsat_driver/src.