Skip to main content

srobot

Lint & build PyPI version MIT license Bees

srobot - 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 srobot

To install the full package, including openCV, you can install with:

pip install srobot[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.

  • tuple is 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.SerialWrapper handles automatic reconnection to the serial port if the connection is lost and impleents 3 retries on any serial operation before raising a BoardDisconnectionError.
  • The old API is still available under sbot.historic, though this might change.

Metadata

Release files for srobot 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for srobot 0.0.1
File Size Uploaded Provenance
srobot-0.0.1.tar.gz 69.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for srobot 0.0.1
File Interpreter ABI Platform
srobot-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 141.3 kB

Release files / srobot-0.0.1.tar.gz

Download URL srobot-0.0.1.tar.gz
Size 69.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7909f1cab9cf900e108cb44a30d3eaf760c17a71a1daf75ec3e6ba907e62463b
BLAKE2b-256 checksum
How to use checksums
87c3afc7349e57dfeda79cf6106834f0f527e73637548443c1cabd92a8853208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 29, 2026.

Transparency log

Release files / srobot-0.0.1-py3-none-any.whl

Download URL srobot-0.0.1-py3-none-any.whl
Size 72.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b7a3e74715c8db295ba106615d842457a67a0df76187d85ebf898da6e3c1a04
BLAKE2b-256 checksum
How to use checksums
ab347f420a90b41dfa5c5b226acf475374d7f09da5b809019d4c0fe65baabb20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 29, 2026.

Transparency log

Security for srobot 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for srobot-0.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page