basic_bot.commons.constants
basic_bot.commons.constants can be imported to access the constants used by basic_bot services. The constants are set by default and all can be overridden by setting environment variables.
If you are using bb_start to start the services, you can set the BB_ environment variables in the basic_bot.yml file. See the bb_start documentation
BB_ENV
Test runner will set this to "test".
Set this to "production" on the onboard computer to run the bot in production mode. See Getting Started Guide for more information.
BB_LOG_ALL_MESSAGES
Set this to True to log all messages sent and received by services to each of their respective log files.
BB_LOG_DEBUG
Set this to True to write all log.debug
to the log file. Note that log.debug
calls
are also written to the log file when BB_ENV is "development" or "test".
BB_HUB_HOST
The websocket host that the central hub is running.
BB_HUB_PORT
The websocket port that the central_hub service listens on.
BB_HUB_URI
This is the full URI to connect to the central_hub service websocket.
BB_MOTOR_I2C_ADDRESS
Used by basic_bot.services.motor_control_2w to connect to the i2c motor controller.
BB_LEFT_MOTOR_CHANNEL
default: 1
BB_RIGHT_MOTOR_CHANNEL
default: 2
BB_SERVO_CONFIG_FILE
See api docs for servo control services
BB_SYSTEM_STATS_SAMPLE_INTERVAL
In seconds, the interval at which the system stats service samples the system and publishes system stats to the central hub.
BB_CAMERA_MODULE
default: "basic_bot.commons.camera_opencv" or "basic_bot.test_helpers.camera_mock" when BB_ENV=test
When using a ribbon cable camera on a Raspberry Pi 4/5, set this to "basic_bot.commons.camera_picamera".
BB_CAMERA_CHANNEL
The camera channel to use. 0 is the default camera.
BB_CAMERA_ROTATION
The camera rotation in degrees. 0 is the default rotation.
BB_CAMERA_FPS
The camera setting frames per second.
BB_VISION_WIDTH
In pixels, this is the width of the camera frame to capture.
BB_VISION_HEIGHT
In pixels, this is the height of the camera frame to capture.
BB_VISION_FOV
The field of view of the camera in degrees. Depends on camera; RPi v2 cam is 62 deg.
BB_OBJECT_DETECTION_THRESHOLD
The object detection threshold percentage 0 - 1; higher = greater confidence.
BB_ENABLE_CORAL_TPU
Set this to True to enable the Coral USB TPU for object detection.
BB_TFLITE_MODEL
Which model to use for object detection when BB_ENABLE_CORAL_TPU is false. Default is the model from the coral site which is faster than the model from the tensorflow hub
BB_TFLITE_MODEL_CORAL
Which model to use for object detection when BB_ENABLE_CORAL_TPU is true.
BB_TFLITE_THREADS
Number of threads to use for tflite detection. Testing object detection on a Rasberry PI 5, without any other CPU or memory pressure, 4 tflite threads was only 1 fps faster (29.5fps) than 3 threads (28.6fps). 2 threads was 22fps.
Warning: Setting this too high can actually reduce the object detection frame rate. In the case of daphbot_due, which has a pygame based onboard UI service that has a configurable render frame rate, the tflite detection running on 4 threads was reduced to about 12 fps when the render frame rate was set to 30fps.
BB_VISION_HOST
The IP address that the vision service is running on for REST api and video streaming.
BB_VISION_PORT
The HTTP port that the vision service listens on for video streaming and REST api.
BB_MJPEG_VIDEO_PORT
The HTTP port that the vision service listens on for video MJPEG streaming.
BB_VISION_URI
The full URI to connect to the vision service REST and video streaming.
BB_DISABLE_RECOGNITION_PROVIDER
Set this to True to disable the recognition provider.
BB_VIDEO_PATH
The path where the vision service saves recorded video.
BB_LEGACY_RECORD_VIDEO
Set this to True to use the legacy video recording method which buffers frames directly from the camera module instead of using WebRTC.
BB_USE_ARECORD
Set this to True to use arecord for audio capture instead of PulseAudio (Linux only). Provides lower latency audio streaming via direct ALSA access.
BB_AUDIO_BUFFER_SIZE
Buffer size for arecord audio capture. Smaller values reduce latency but may cause audio dropouts. Only used when BB_USE_ARECORD is True.
BB_AUDIO_PERIOD_SIZE
Period size for arecord audio capture. Smaller values reduce latency. Only used when BB_USE_ARECORD is True.
BB_AUDIO_SAMPLE_RATE
Sample rate for arecord audio capture. Lower values reduce processing overhead and latency. 22050 provides good quality with minimal latency. Only used when BB_USE_ARECORD is True.
BB_AUDIO_CHANNELS
Number of audio channels for arecord capture. 1=mono, 2=stereo. Mono reduces processing overhead and latency. Only used when BB_USE_ARECORD is True.
BB_WEB_PUBLIC
The path to the directory containing the web application's static files. The web server will serve files from this directory.