Configure an NMEA-Based GPS
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
movement sensor model supports NMEA-based GPS units and RTCM versions up to 3.3.
This GPS model uses communication standards set by the National Marine Electronics Association (NMEA).
The gps-nmea
model can be connected using USB and send data through a serial connection to any device, or employ an I2C connection to a board:
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
model.
Enter a name or use the suggested name for your movement sensor and click Create.
Fill in the attributes as applicable to your movement sensor, according to the table below.
{
"components": [
{
"name": "<your-sensor-name>",
"model": "gps-nmea",
"type": "movement_sensor",
"namespace": "rdk",
"attributes": {
"connection_type": "<serial|I2C>",
"serial_attributes": {
"serial_path": "<your-device-path>",
"serial_baud_rate": <int>
},
"i2c_attributes": {
"i2c_bus": "<index-of-bus-on-board>",
"i2c_addr": <int>,
"i2c_baud_rate": <int>
}
},
"depends_on": [],
}
]
}
{
"components": [
{
"name": "my-gps-nmea",
"model": "gps-nmea",
"type": "movement_sensor",
"namespace": "rdk",
"attributes": {
"connection_type": "serial",
"serial_attributes": {
"serial_path": "/dev/serial/by-path/usb-0:1.1:1.0",
"serial_baud_rate": 38400
}
},
"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
{
"components": [
{
"name": "my-gps-nmea",
"model": "gps-nmea",
"type": "movement_sensor",
"namespace": "rdk",
"attributes": {
"connection_type": "I2C",
"i2c_attributes": {
"i2c_bus": "1",
"i2c_addr": 111,
"i2c_baud_rate": 38400
}
},
"depends_on": []
}
]
}
Attributes
Name | Type | Required? | Description |
---|---|---|---|
connection_type | string | Required | "I2C" or "serial" . See Connection Attributes below. |
Connection attributes
You need to configure attributes to specify how the GPS connects to your computer. You can use either serial communication (over USB) or I2C communication (through pins to a board).
Use connection_type
to specify "serial"
or "I2C"
connection in the main attributes
config.
Then create a struct within attributes
for either serial_attributes
or i2c_attributes
, respectively.
See examples of this struct in the example tabs above.
Serial config attributes
For a movement sensor communicating over serial, you’ll need to include a serial_attributes
struct containing:
Name | Type | Required? | Description |
---|---|---|---|
serial_path | string | Required | The full filesystem path to the serial device, starting with
|
serial_baud_rate | int | Optional | The rate at which data is sent from the sensor. Default: 38400 |
I2C config attributes
For a movement sensor communicating over I2C, you’ll need a i2c_attributes
struct containing:
Name | Type | Required? | Description |
---|---|---|---|
i2c_bus | string | Required | The index of the I2C bus on the board wired to the sensor. |
i2c_addr | int | Required | The device’s I2C address. |
i2c_baud_rate | int | Optional | The rate at which data is sent from the sensor. Optional. Default: 38400 |
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.
Next steps
For more configuration and development 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.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!