Movement sensor API | Component APIs

Movement sensor API

The movement sensor API allows you to give commands to your movement sensor components for getting a GPS location, linear velocity and acceleration, angular velocity and acceleration, and heading.

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

API

GetLinearVelocity

Report the current linear velocity in the x, y, and z directions (as a 3D vector) in meters per second.

Supported by GPS models. Supported by viam-micro-server.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetAngularVelocity

Report the current angular velocity about the x, y, and z axes (as a 3D vector) in degrees per second.

Supported by IMU models and by gyro-mpu6050. Supported by viam-micro-server.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetCompassHeading

Report the current compass heading in degrees.

Supported by GPS models. Supported by viam-micro-server.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetOrientation

Report the current orientation of the sensor.

Supported by IMU models.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetPosition

Report the current GeoPoint (latitude, longitude) and altitude (in meters).

Supported by GPS models. Supported by viam-micro-server.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetProperties

Get the supported properties of this sensor. Supported by viam-micro-server.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetAccuracy

Get the reliability metrics of the movement sensor, including various parameters to assess the sensor’s accuracy and precision in different dimensions.

Supported by GPS models and imu-wit.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetLinearAcceleration

Report the current linear acceleration in the x, y, and z directions (as a 3D vector) in meters per second per second.

Supported by IMU models, accel-adxl345, and gyro-mpu6050. Supported by viam-micro-server.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetGeometries

Get all the geometries associated with the movement sensor in its current configuration, in the frame of the movement sensor. The motion and navigation services use the relative position of inherent geometries to configured geometries representing obstacles for collision detection and obstacle avoidance while motion planning.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

GetReadings

Get all the measurements/data from the sensor. Results depend on the sensor model and can be of any type. If a sensor is not configured to take a certain measurement or fails to read a piece of data, that data will not appear in the readings dictionary. Supported by viam-micro-server.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

Reconfigure

Reconfigure this resource. Reconfigure must reconfigure the resource atomically and in place.

Parameters:

Returns:

For more information, see the Go SDK Docs.

DoCommand

Execute model-specific commands that are not otherwise defined by the component API. Most models do not implement DoCommand. Any available model-specific commands should be covered in the model’s documentation. If you are implementing your own movement sensor and want to add features that have no corresponding built-in API method, you can implement them with DoCommand. Supported by viam-micro-server.

Parameters:

Returns:

Raises:

Example:


Copy

For more information, see the Python SDK Docs.

GetResourceName

Get the ResourceName for this movement sensor.

Parameters:

Returns:

Example:


Copy

For more information, see the Python SDK Docs.

Close

Safely shut down the resource and prevent further use.

Parameters:

Returns:

Example: