The robot API for the Smallpeice summer school
Project description
sbot
sbot - SourceBots Robot API
This is the API for Southampton Robotics Outreach robotics competitions.
Installation
If you wish to install openCV from your package manager, you can install the base package with:
pip install sbot
To install the full package, including openCV, you can install with:
pip install sbot[vision]
Usage
Importing the module will, by default, trigger board discovery and wait for the start button to be pressed.
import sbot
Unlike previous versions, robot functionality is accessed directly from the sbot library instead of instantiating a class.
from sbot import *
motors.set_power(0, 0.3)
motors.set_power(1, 0.3)
power.get_output_current(PowerOutputPosition.H0)
utils.sound_buzzer(880, 0.5)
servos.set_position(0, 45/90)
print(arduino.measure_ultrasound_distance(8, 9))
if comp.is_competition:
markers = vision.detect_markers()
leds.set_colour(0, Colour.MAGENTA)
Startup behaviour
You can configure the startup behaviour of sbot with an override.env file in the same directory as your project.
Example override.env file:
ENABLE_DEBUG_LOGGING=1
SKIP_WAIT_START=1
NO_POWERBOARD=1
If SKIP_WAIT_START is set, you will have to manually trigger board discovery and wait for the start button:
from sbot import utils
utils.load_boards()
utils.wait_start()
The currently supported override keys are:
| Override | Description |
|---|---|
| ENABLE_DEBUG_LOGGING | Enable debug logging |
| ENABLE_TRACE_LOGGING | Enable trace level logging |
| SKIP_WAIT_START | Don't block for the start signal automatically |
| NO_POWERBOARD | Allow running without a power board |
| MANUAL_POWER_PORTS | Specify additional serial ports for power boards |
| MANUAL_MOTOR_PORTS | Specify additional serial ports for motor boards |
| MANUAL_SERVO_PORTS | Specify additional serial ports for servo boards |
| MANUAL_ARDUINO_PORTS | Specify additional serial ports for arduino boards |
| MANUAL_LED_PORTS | Specify additional serial ports for led boards, only used in the simulator |
| MANUAL_TIME_PORTS | Specify additional serial ports for the time interface, only used in the simulator |
| SORT_POWER_ORDER | Override the sort order of the power boards, unused |
| SORT_MOTOR_ORDER | Override the sort order of the motor boards |
| SORT_SERVO_ORDER | Override the sort order of the servo boards |
| SORT_ARDUINO_ORDER | Override the sort order of the arduino boards, unused |
| SORT_LED_ORDER | Override the sort order of the led boards, unused |
| SORT_TIME_ORDER | Override the sort order of the time interface, unused |
You can also configure these settings as environment variables, by prepending the prefix SBOT_. For example, ENABLE_DEBUG_LOGGING can be set as SBOT_ENABLE_DEBUG_LOGGING.
Some settings can only be configured as environment variables. These are:
| Environment Variable | Description |
|---|---|
| OPENCV_CALIBRATIONS | Override the location to look for additional camera calibrations, defaults to the working directory |
| SBOT_METADATA_PATH | Override the location to look for metadata files, normally configured by the runner |
| SBOT_PYTEST | Set to 1 when running unit tests, to disable automatic discovery on import |
| SBOT_MQTT_URL | The URI to use for the MQTT broker, normally configured by the runner |
| run_uuid | The UUID to include in all MQTT messages, normally configured by the runner |
| WEBOTS_SIMULATOR | Set to 1 when running in the Webots simulator, used to detect the simulator environment |
| WEBOTS_ROBOT | List of socket URIs to connect to for the simulated boards, configured by the runner |
| WEBOTS_DEVICE_LOGGING | Set to the log level name to use for logging of the simulated boards, defaults to WARNING |
Developer Notes
There are a number of considerations that have been made in the design of this API. Some of these may not be immediately obvious, so they are documented below.
tupleis used to prevent the user from adding, removing or overwriting items in any parts of the API that would return a list.__slots__is used to prevent the user from adding, removing or overwriting attributes in any parts of the API.sbot.serial_wrapper.SerialWrapperhandles automatic reconnection to the serial port if the connection is lost and impleents 3 retries on any serial operation before raising aBoardDisconnectionError.- The old API is still available under
sbot.historic, though this might change.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sbot-2025.1.1.tar.gz.
File metadata
- Download URL: sbot-2025.1.1.tar.gz
- Upload date:
- Size: 68.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10ad46280564f9eadbacc2d25419fc4464e7bd22ef1241aae0637170985c9f27
|
|
| MD5 |
f74cff50fc85a4f1a48cf0b93888537e
|
|
| BLAKE2b-256 |
0898bf2d7d7506d29c55bfa14c89411ad11c94e65fd9a594aae2df5bc9a358ab
|
Provenance
The following attestation bundles were made for sbot-2025.1.1.tar.gz:
Publisher:
test_build.yml on sourcebots/sbot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sbot-2025.1.1.tar.gz -
Subject digest:
10ad46280564f9eadbacc2d25419fc4464e7bd22ef1241aae0637170985c9f27 - Sigstore transparency entry: 347887801
- Sigstore integration time:
-
Permalink:
sourcebots/sbot@78b2ab0312189c7d4c5a9ac641677c220740a786 -
Branch / Tag:
refs/tags/2025.1.1 - Owner: https://github.com/sourcebots
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test_build.yml@78b2ab0312189c7d4c5a9ac641677c220740a786 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sbot-2025.1.1-py3-none-any.whl.
File metadata
- Download URL: sbot-2025.1.1-py3-none-any.whl
- Upload date:
- Size: 72.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3abb8567acc79d6fb9c5377063f02f84a6b9049aa1023e618e53e436d7b8176f
|
|
| MD5 |
0be2e5b6c11a798a341a6c8bfbd740ce
|
|
| BLAKE2b-256 |
886dd1291905877d31baab3a659e49b58eabca574132a94f15d237a3ceddec0b
|
Provenance
The following attestation bundles were made for sbot-2025.1.1-py3-none-any.whl:
Publisher:
test_build.yml on sourcebots/sbot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sbot-2025.1.1-py3-none-any.whl -
Subject digest:
3abb8567acc79d6fb9c5377063f02f84a6b9049aa1023e618e53e436d7b8176f - Sigstore transparency entry: 347887814
- Sigstore integration time:
-
Permalink:
sourcebots/sbot@78b2ab0312189c7d4c5a9ac641677c220740a786 -
Branch / Tag:
refs/tags/2025.1.1 - Owner: https://github.com/sourcebots
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test_build.yml@78b2ab0312189c7d4c5a9ac641677c220740a786 -
Trigger Event:
push
-
Statement type: