Servo Component

The servo component provides an API for controlling the angular position of a servo precisely or getting its current status.

If you have a physical “RC” or “hobby” servo motor with built-in potentiometer position sensors, configure it as a servo component.

If your motor is coupled with an encoder, not a potentiometer, for position feedback, you should configure it as an encoded motor instead.

Configuration

To use a hobby servo, you need to add it to your machine’s configuration.

Go to your machine’s CONFIGURE page, and add a model that supports your servo.

For additional configuration information, click on the model name:

Model
Description
ModelDescription
gpioA hobby servo.

API

The servo API supports the following methods:

Method NameDescriptionviam-micro-server Support
MoveMove the servo to the desired angle in degrees.

GetPositionGet the current set angle of the servo in degrees.

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

StopStop the servo from moving.

ReconfigureReconfigure this resource.

DoCommandExecute model-specific commands that are not otherwise defined by the component API.
GetResourceNameGet the ResourceName for this servo with the given name.

CloseSafely shut down the resource and prevent further use.

Troubleshooting

If your servo is not working as expected, follow these steps:

  1. Check your machine logs on the LOGS tab to check for errors.
  2. Review your servo model’s documentation to ensure you have configured all required attributes.
  3. Check that all wires are securely attached to the correct pins on the board.
  4. Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the servo 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: