This ROS package computes odometry heading for a robot using GNSS (Global Navigation Satellite System) data or wheel odometry data. It is designed to work with ROS Melodic and provides a modular and configurable implementation.
The gnss_odom package computes odometry for a robot using either:
- GNSS data: Computes heading and speed based on consecutive GNSS fixes.
- Wheel odometry data: Computes heading and speed based on displacement from wheel encoders.
The package publishes the computed odometry as an Odometry message, which can be used by other ROS nodes for navigation, localization, or mapping.
- Computes heading from GNSS fixes or odometry data.
- Uses least-squares fitting for a smoother heading estimate.
- Corrects heading direction based on velocity sign.
- Publishes odometry messages with orientation information.
The node supports two methods for heading calculation:
-
Direct GNSS Bearing
- Uses
pyproj.Geod.inv()to get the GNSS bearing. - Converts it to radians and applies an optional offset.
- Uses
-
Least-Squares Line Fitting
- Stores recent GNSS/odometry positions.
- Fits a line using
np.linalg.lstsq(). - Computes the heading angle from the line slope.
- Corrects direction based on movement and velocity.
rospysensor_msgsnav_msgsgeometry_msgs
pyproj(for geodetic calculations)numpy(for basic mathematical operations)
-
Clone the Repository:
cd ~/catkin_ws/src git clone https://github.com/ikh-innovation/gnss_odom.git
-
Install Dependencies: Ensure that the required ROS packages are installed:
sudo apt-get install ros-melodic-sensor-msgs ros-melodic-nav-msgs ros-melodic-geometry-msgs
Install the
pyprojPython library:pip install pyproj numpy
-
Build the Package:
cd ~/catkin_ws catkin_make source devel/setup.bash
To run the gnss_odom node, use the following command:
rosrun gnss_odom gnss_odomThe package includes launch files for easy configuration and execution. To use a launch file:
roslaunch gnss_odom gnss_odom.launchThe following parameters can be configured for the gnss_odom node:
| Parameter Name | Description | Default Value |
|---|---|---|
cmd_vel_topic |
Command velocity topic | /aristos/wheel/cmd_vel |
fix_topic |
GNSS fix topic | /aristos/filter/positionlla/gnss |
odom_topic |
Odometry input topic | /aristos/odometry/gps/onlyRTK |
odom_pub_topic |
Published odometry topic | gnss_heading/odom |
use_odometry |
Use odometry instead of GNSS for heading | true |
velocity_threshold |
Minimum velocity for heading update | 0.2 m/s |
distance_threshold |
Minimum distance for heading update | 0.05 m |
heading_offset |
Additional heading offset (radians) | 0.0 |
use_fitted_heading |
Enable least-squares heading estimation | true |
num_fit_points |
Number of past points used for fitting | 4 |
gnss_ellipsoid |
Ellipsoid model used by pyproj | WGS84 |
gnss_heading/odom(nav_msgs/Odometry)
Publishes computed odometry data with orientation.
/aristos/wheel/cmd_vel(geometry_msgs/Twist)
Stores velocity data for heading correction./aristos/filter/positionlla/gnss(sensor_msgs/NavSatFix)
Processes GNSS data to compute heading./aristos/odometry/gps/onlyRTK(nav_msgs/Odometry)
Processes odometry data when enabled.
The package includes the following launch files:
Launches the gnss_odom node with default parameters. You can override parameters using the arg tag.
Example:
<launch>
<node name="gnss_odom_node" pkg="gnss_odom" type="gnss_odom" output="screen">
<param name="cmd_vel_topic" value="/aristos/wheel/cmd_vel" />
<param name="fix_topic" value="/aristos/filter/positionlla/gnss" />
<param name="odom_topic" value="/aristos/odometry/gps/onlyRTK"/>
<param name="odom_pub_topic" value="gnss_heading/odom" />
<param name="use_odometry" value="true"/>
<param name="velocity_threshold" value="0.2"/>
<param name="distance_threshold" value="0.05"/>
<param name="heading_offset" value="0.0"/>
<param name="use_fitted_heading" value="true"/>
<param name="num_fit_points" value="4"/>
<param name="gnss_ellipsoid" value="WGS84"/> <!--pyproj supported ellipsoids-->
</node>
</launch>