Configure NTRIP-Based RTK GPS with Serial Connection

A global positioning system (GPS) receives signals from satellites in the earth’s orbit to determine where it is and how fast it is going. All supported GPS models provide data for the Position, CompassHeading, LinearVelocity, and GetAccuracy methods. You can obtain fix and correction data by using the sensor GetReadings method, which is available because GPSes wrap the sensor component.

The gps-nmea-rtk-serial and gps-nmea-rtk-pmtk movement sensor models support NTRIP-based real time kinematic positioning (RTK) GPS units (such as these) and RTCM versions up to 3.3.

The chip requires a correction source to get to the required positional accuracy. The gps-nmea-rtk-serial model uses an over-the-internet correction source like an RTK reference station and sends the data over a serial connection to the board.

Follow the guide to Set up a SparkFun RTK Reference Station to configure a SparkFun station for use with this RTK-enabled GPS movement sensor model.

Physically connect your movement sensor to your machine’s computer and power both on. Then, configure the movement sensor:

Navigate to the CONFIGURE tab of your machine’s page in the Viam app. Click the + icon next to your machine part in the left-hand menu and select Component. Select the movement-sensor type, then select the gps-nmea-rtk-serial model. Enter a name or use the suggested name for your movement sensor and click Create.

Creation of a `gps-nmea-rtk-serial` movement sensor in the Viam app config builder.

Fill in the attributes as applicable to your movement sensor, according to the table below.

{
  "components": [
    {
      "name": "<your-sensor-name>",
      "model": "gps-nmea-rtk-serial",
      "type": "movement_sensor",
      "namespace": "rdk",
      "attributes": {
        "serial_path": "<path_to_serial_port>",
        "serial_baud_rate": <int>,
        "ntrip_connect_attempts": <int>,
        "ntrip_mountpoint": "<identifier>",
        "ntrip_password": "<password for NTRIP server>",
        "ntrip_url": "<URL of NTRIP server>",
        "ntrip_username": "<username for NTRIP server>"
      },
      "depends_on": [],
    }
  ]
}
{
  "components": [
    {
      "name": "my_GPS",
      "model": "gps-nmea-rtk-serial",
      "type": "movement_sensor",
      "namespace": "rdk",
      "attributes": {
        "serial_path": "/dev/serial/by-path/usb-0:1.1:1.0",
        "serial_baud_rate": 115200,
        "ntrip_connect_attempts": 12,
        "ntrip_mountpoint": "MNTPT",
        "ntrip_password": "pass",
        "ntrip_url": "http://ntrip/url",
        "ntrip_username": "usr"
      },
      "depends_on": []
    }
  ]
}

The "serial_path" filepath used in this example is specific to serial devices connected to Linux systems. The "serial_path" filepath on a macOS system might resemble "/dev/ttyUSB0" or "/dev/ttyS0".

The following attributes are available for a gps-nmea-rtk-pmtk movement sensor:

NameTypeRequired?Description
serial_pathstringRequiredThe full filesystem path to the serial device, starting with /dev/. To find your serial device path, first connect the serial device to your machine, then:
  • On Linux, run ls /dev/serial/by-path/* to show connected serial devices, or look for your device in the output of sudo dmesg | grep tty. Example: "/dev/serial/by-path/usb-0:1.1:1.0".
  • On macOS, run ls /dev/tty* | grep -i usb to show connected USB serial devices, ls /dev/tty* to browse all devices, or look for your device in the output of sudo dmesg | grep tty. Example: "/dev/ttyS0".
serial_baud_rateintOptionalThe rate at which data is sent from the sensor.
Default: 38400
ntrip_urlstringRequiredThe URL of the NTRIP server from which you get correction data. Connects to a base station (maintained by a third party) for RTK corrections.
ntrip_usernamestringOptionalUsername for the NTRIP server.
ntrip_passwordstringOptionalPassword for the NTRIP server.
ntrip_connect_attemptsintOptionalHow many times to attempt connection before timing out.
Default: 10
ntrip_mountpointstringOptionalIf you know of an RTK mountpoint near you, write its identifier here. It will be appended to NTRIP address string (for example, “nysnet.gov/rtcm/NJMTPT1”) and that mountpoint’s data will be used for corrections.

Test the movement sensor

After you configure your movement sensor, open the movement sensor’s TEST panel on the CONFIGURE or CONTROL tabs. This panel presents the data collected by the movement sensor. The sections in the panel include the position, linear velocity and compass heading.

The movement sensor component in the test panel

Troubleshooting

If your movement sensor is not working as expected, follow these steps:

  1. Check your machine logs on the LOGS tab to check for errors.
  2. Review this movement sensor model’s documentation to ensure you have configured all required attributes.
  3. Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the movement sensor there.

If none of these steps work, reach out to us on the Community Discord and we will be happy to help.

Next steps

For more configuration and usage info, see:

Have questions, or want to meet other people working on robots? Join our Community Discord.

If you notice any issues with the documentation, feel free to file an issue or edit this file.