Configure a VectorNav IMU

An inertial measurement unit (IMU) provides data for the AngularVelocity, Orientation, CompassHeading, and LinearAcceleration methods. Acceleration and magnetometer data are available by using the sensor GetReadings method, which IMUs wrap.

The imu-vectornav movement sensor model supports IMUs manufactured by VectorNav that support SPI connection.

Navigate to the Config tab of your robot’s page in the Viam app. Click on the Components subtab and navigate to the Create component menu. Enter a name for your movement sensor, select the movement-sensor type, and select the imu-vectornav model.

Click Create Component.

Creation of an imu-vectornav movement sensor in the Viam app config builder.

Edit and fill in the attributes as applicable.

{
  "components": [
    {
      "name": "<your-sensor-name>",
      "type": "movement_sensor",
      "model": "imu-vectornav",
      "attributes": {
        "board": "<your-board-name>",
        "spi": "<your-spi-bus-name-on-board>",
        "spi_baud_rate": <int>,
        "polling_freq_hz": <int>,
        "chip_select_pin": "<pin-number-on-board>"
      },
      "depends_on": []
    }
  ]
}
{
  "components": [
    {
      "name": "myIMU",
      "type": "movement_sensor",
      "model": "imu-vectornav",
      "attributes": {
        "board": "local",
        "spi": "1",
        "spi_baud_rate": 3800,
        "polling_freq_hz": 80,
        "chip_select_pin": "36"
      },
      "depends_on": []
    }
  ]
}

Attributes

NameTypeInclusionDescription
boardstringRequiredThe name of the board to which the device is wired.
spistringThe name of the SPI bus over which the device communicates with the board.
chip_select_pinstringRequiredThe (pin number) of the pin on the board (other than the SPI bus pins) connected to the IMU chip. Used to tell the chip whether the current SPI message is meant for it or for another device.
spi_baud_rateintRequiredThe rate at which data is sent from the IMU.
Default: 115200
polling_frequency_hzintRequiredHow many times per second the sensor is polled.


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