basic_bot.services.servo_control
Provides a service to control the servo motors using the PCA9685 PWM driver.
On startup, this service will look for a file named servo_config.yml
in the
directory where the service was started which should always be the root project
dir of your basic_bot project. This file should contain a list of servos with
the following format:
servos:
- name: servo_name
channel: 0
motor_range: 180
min_angle: 0
max_angle: 180
min_pulse: 500
max_pulse: 2500
If you update the servo_config.yml
file, you will need to restart the service.
The 'name' and 'channel' are required for each servo. The example above shows the default values for the other parameters.
name
(required) is the unique name of the servo.channel
(required) is the channel on the PCA9685 board that the servo is connected to.motor_range
is the total manufacturer's range of the servo in degrees.min_angle
andmax_angle
are the minimum and maximum angles that the servo should be constrained.min_pulse
andmax_pulse
are the minimum and maximum pulse widths in microseconds that the servo will accept as specified by the manufacturer.
The service listens for messages on the central_hub key: "servo_angles". The
message data
should be a dictionary with keys that are the servo names
from servo_config.yml
and values that are the desired angle in degrees.
The service will send a state update back to the central_hub with the current state of the servos using the key "servo_current_angles", for example:
The service will also provide the current servo config as read from servo_config.yml
at service startup using the key "servo_config", for example:
{
"servo_config": {
"servos": [
{
"name": "servo_name",
"channel": 0,
"motor_range": 180,
"min_angle": 0,
"max_angle": 180,
"min_pulse": 500,
"max_pulse": 2500
}
]
}
}
ANGLE_UPDATE_FREQUENCY
seconds = 10Hz