Movement Sensor Component
The movement sensor component provides an API for GPS location, linear velocity and acceleration, angular velocity and acceleration and heading.
If you have hardware or software that provides such measurements, use a movement sensor component.
Configuration
To use a movement sensor and get its measurements, you need to add it to your machine’s configuration.
Go to your machine’s CONFIGURE page, and add a model that supports your sensor.
The following list shows the available sensor models. For additional configuration information, click on the model name:
Add support for other models
If none of the existing models fit your use case, you can create a modular resource to add support for it.
Model | Description |
---|---|
accel-adxl345 | The Analog Devices ADXL345 digital accelerometer |
gyro-mpu6050 | A gyroscope/accelerometer manufactured by TDK InvenSense |
Add support for other models
If none of the existing models fit your use case, you can create a modular resource to add support for it.
viam-micro-server
works differently from the RDK, so creating modular resources for it is different.
Refer to the Micro-RDK Module Template on GitHub for information on how to create custom resources for your viam-micro-server
machine.
You will need to recompile and flash your ESP32 yourself instead of using Viam’s prebuilt binary and installer.
API
The movement sensor API supports the following methods:
Different movement sensors provide different data, so be aware that not all of the methods below are supported by all movement sensors.
Tip
You can run GetProperties
on your sensor for a list of its supported methods.
Method Name | Description | Models That Support This Method | viam-micro-server Support |
---|---|---|---|
GetPosition | Get the current latitude, longitude and altitude. | GPS models, wheeled-odometry | |
GetLinearVelocity | Get the current linear velocity as a 3D vector. | GPS models, wheeled-odometry | |
GetAngularVelocity | Get the current angular velocity as a 3D vector. | IMU models, gyro-mpu6050 , and wheeled-odometry | |
GetLinearAcceleration | Get the current linear acceleration as a 3D vector. | IMU models, accel-adxl345 , and gyro-mpu6050 | |
GetCompassHeading | Get the current compass heading in degrees. | GPS models | |
GetOrientation | Get the current orientation. | IMU models, wheeled-odometry | |
GetProperties | Get the supported properties of this sensor. | all models | |
GetAccuracy | Get the accuracy of the various sensors. | GPS models | |
GetReadings | Obtain the measurements/data specific to this sensor. | all models | |
DoCommand | Send or receive model-specific commands. | all models | |
Close | Safely shut down the resource and prevent further use. | all models |
Troubleshooting
If your movement sensor is not working as expected, follow these steps:
- Check your machine logs on the LOGS tab to check for errors.
- Review your movement sensor model’s documentation to ensure you have configured all required attributes.
- 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 general configuration and development info, see:
To capture data from the movement sensor or use it for motion, see the following services:
- data management service: to capture and sync the movement sensor’s data
- motion service: to move machines or components of machines
- navigation service: to navigate with GPS
- SLAM service: for mapping
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!