Servo API | Component APIs

Servo API

The servo API allows you to give commands to your servo components for controlling the angular position of a hobby servo precisely or getting its current status.

Industrial servos should use the motor API which provides more features than the servo API.

The servo component supports the following methods:

Method Name Description viam-micro-server Support
Move Move the servo to the desired angle in degrees.
GetPosition Get the current set angle of the servo in degrees.
IsMoving Returns whether the servo is actively moving (or attempting to move) under its own power.
Stop Stop the servo from moving.
GetGeometries Get all the geometries associated with the servo in its current configuration, in the frame of the servo.
Reconfigure Reconfigure this resource.
DoCommand Execute model-specific commands that are not otherwise defined by the component API.
GetResourceName Get the ResourceName for this servo.
Close Safely shut down the resource and prevent further use.

API

Move

Move the servo to the desired angle in degrees.

Stability Notice

Support for continuous servos with the GPIO servo model is experimental. Stability is not guaranteed. Breaking changes are likely to occur, and occur often.

If you are using a continuous rotation servo, you can use the Move command, but instead of moving to a given position, the servo will start moving at a set speed.

The speed will be related to the “angle” you pass in as a linear approximation. 90 degrees represents stop, 91 to 180 represents counter-clockwise rotation from slowest to fastest, and 89 to 1 represents clockwise from slowest to fastest. It is recommended that you test your servo to determine the desired speed.

Supported by viam-micro-server.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

GetPosition

Get the current set angle of the servo in degrees. Supported by viam-micro-server.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

IsMoving

Returns whether the servo is actively moving (or attempting to move) under its own power.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

Stop

Stop the servo from moving. Supported by viam-micro-server.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

GetGeometries

Get all the geometries associated with the servo in its current configuration, in the frame of the servo. 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 servo and want to add features that have no corresponding built-in API method, you can implement them with DoCommand.

Parameters:

Returns:

Raises:

Example:


For more information, see the Python SDK Docs.

GetResourceName

Get the ResourceName for this servo.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.

Close

Safely shut down the resource and prevent further use.

Parameters:

Returns:

Example:


For more information, see the Python SDK Docs.