Encoder API | Component APIs

Encoder API

The encoder API allows you to give commands to your encoder components for getting the position of a motor or a joint in ticks or degrees.

The encoder component supports the following methods:

Method Name Description viam-micro-server Support
GetPosition Get the current position of the encoder in ticks or degrees.
ResetPosition Set the current position of the encoder to be the new zero position.
GetProperties Get a list of all the position types that are supported by a given encoder.
GetGeometries Get all the geometries associated with the encoder in its current configuration, in the frame of the encoder.
Reconfigure Reconfigure this resource.
DoCommand Execute model-specific commands that are not otherwise defined by the component API.
GetResourceName Get the ResourceName for this encoder.
Close Safely shut down the resource and prevent further use.

API

GetPosition

Get the current position of the encoder in ticks or degrees. Relative encoders return ticks since last zeroing. Absolute encoders return degrees. Supported by viam-micro-server.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

ResetPosition

Set the current position of the encoder to be the new zero position. Supported by viam-micro-server.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

GetProperties

Get a list of all the position types that are supported by a given encoder. Supported by viam-micro-server.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

GetGeometries

Get all the geometries associated with the encoder in its current configuration, in the frame of the encoder. 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:


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 encoder as a modular resource 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:


For more information, see the Python SDK Docs.

GetResourceName

Get the ResourceName for this encoder.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

Close

Safely shut down the resource and prevent further use.

Parameters:

Returns:

Example: