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.
Available models
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:
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 |
---|---|
gpio | A hobby servo. |
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 servo API 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. | |
Reconfigure | Reconfigure this resource. | |
GetResourceName | Get the ResourceName for this servo with the given name. | |
Close | Safely shut down the resource and prevent further use. |
Troubleshooting
You can find additional assistance in the Troubleshooting section.
You can also ask questions in the Community Discord and we will be happy to help.
Next steps
For general configuration and development info, see:
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!