> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Servo control

> Configure ServoToolkit for hobby servo angles and sweeps through GPIO.

`ServoToolkit` from `@agentium/edge` drives a configured GPIO signal using software PWM. It exposes angle and sweep tools for hobby servos.

## Configure a servo

```bash theme={null}
npm install @agentium/core@4.0.0 @agentium/edge@4.0.0 node-libgpiod
```

The factory below creates tools without moving hardware. Supply the GPIO chip, signal pin, and pulse range appropriate to your board and servo:

```typescript theme={null}
import { ServoToolkit, type ServoConfig } from "@agentium/edge";

export function createServoTools(config: ServoConfig) {
  const servo = new ServoToolkit(config);
  return servo.getTools();
}
```

Pass the returned tools to an Agent's `tools` option. GPIO access starts when a tool executes; the host needs permission to use the selected GPIO chip.

| Configuration | Default | Meaning |
| - | - | - |
| `pin` | Required | Signal line on the chosen chip |
| `chipNumber` | `0` | GPIO chip index; confirm this on the target board |
| `minPulseUs` | `500` | Pulse width for zero degrees |
| `maxPulseUs` | `2500` | Pulse width for 180 degrees |
| `frequency` | `50` | PWM frequency in Hz |

## Available tools

| Tool | Input | Behavior |
| - | - | - |
| `servo_set_angle` | `angle` from 0–180, optional `hold_ms` (default 1000) | Pulse at one angle for the requested duration |
| `servo_sweep` | `from_angle`, `to_angle`, optional `step` (1–90, default 5), optional `step_delay_ms` (default 50) | Move in steps between two angles |

Results are JSON strings with operation details or an `error` field. A tool error does not establish the actuator's current position. Successful pulses end by setting the line low and releasing it; the toolkit does not continuously hold position after the requested duration.

## Timing and host controls

PWM uses Node.js timers. Scheduling delays affect pulse accuracy; this is not a hardware PWM or real-time motion controller. Match pulse limits to the actuator and constrain duration and motion ranges in your host tool wrapper before exposing it to a model. The implementation does not provide a cancellable motion session or a guarantee that cancelling an Agent run stops a pulse already in progress.

For general digital I/O, use [GpioToolkit](/edge/gpio). For device monitoring, use [SystemToolkit](/edge/system).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.