Python API for the Cobalt perception stack
Project description
Cobalt SDK
Python SDK containing utilities and useful extensions when working with the cobalt perception stack.
At the moment, this is more of an API intended for talking to a backend perception pipeline, but eventually it will be extended with more advanced features.
Features
- WebSocket connections to Cobalt perception stack
- Object detection data structures with ctypes for efficient binary data handling
- Support for subscribing to object detection streams
- Async/await support for real-time data processing
Installation
From PyPI (when published)
pip install cobalt-sdk
From source
git clone https://github.com/ceptontech/cobalt.git
cd cobalt/cobalt-sdk
pip install .
Using requirements.txt
pip install -r requirements.txt
Development Installation
For development work, install the package in editable mode with development dependencies:
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Or using requirements files
pip install -r requirements-dev.txt
pip install -e .
Development Dependencies
The development environment includes:
pytest>=7.0- Testing frameworkblack>=22.0- Code formatterflake8>=4.0- Lintingmypy>=0.950- Type checking
Usage
API Reference
Connection Functions
-
proto_connect()- Connect to protocol WebSocket (port 24787) -
data_connect()- Connect to data WebSocket (port 9030) -
subscribe_objects(ws)- Subscribe to object detection data on a WebSocket connection -
subscribe_foreground_cloud(ws)- Subscribe to point cloud from target objects -
subscribe_background_cloud(ws)- Subscribe to point cloud from non-target objects -
subscribe_ground_cloud(ws)- Subscribe to point cloud from the ground -
subscribe_base_cloud(ws)- Subscribe to total point cloud -
subscribe_zones(ws)- Subscribe to updates of the zone settings -
subscribe_clusters(ws)- Subscribe to cluster point cloud data with full point clouds
Unitility Class
CobaltClient- Event driven API, which parse and handle data received within an event loop. Please see samples/client_example.py for the details
Data Structures
Object - Represents a single detected object:
x,y,z(float) - 3D position coordinatesvx,vy(float) - horizontal velocitieslength,width,height(float) - Object dimensionstheta(float) - Rotation angleclassification(uint32) - Object classification IDobject_id(uint32) - Unique object identifier
Objects - Frame containing multiple objects:
magic- Frame identifier ("COBJ")num_objects(uint32) - Number of objects in framesequence_id(uint32) - Frame sequence numberobjects- List of Object instances
ClusterPointCloud - Single cluster metadata:
timestamp(int64) - Cluster timestamp in microsecondsnum_points(uint32) - Number of points in the clusterheight(float) - Cluster heightradius(float) - Cluster radius
ClusterPointClouds - Frame containing multiple cluster point clouds:
magic- Frame identifier ("CLSP")num_clusters(uint32) - Number of clusters in frameclusters- List of cluster dictionaries with keys:timestamp(int64) - Cluster timestampnum_points(uint32) - Number of pointsheight(float) - Cluster heightradius(float) - Cluster radiuspoints(numpy.ndarray) - Point cloud data shaped (num_points, 3)
ForegroundCloud - Frame of a foreground point cloud:
magic- Frame identifier ("FGCL")num_points(uint32) - Number of points in framesequence_id(uint32) - Frame sequence numberpositions- NumPy array of each points' coordinates [[x, y, z], ...]
BackgroundCloud - Frame of a background point cloud:
-
magic- Frame identifier ("BGCL")...the rest is the same as ForegroundCloud
GroundCloud - Frame of a ground point cloud:
-
magic- Frame identifier ("GRCL")...the rest is the same as ForegroundCloud
BaseCloud - Frame of a point cloud:
-
magic- Frame identifier ("HCLD")...the rest is the same as ForegroundCloud
ZoneSettings - Zones` information in the Cobalt
zones- A list ofZoneclass instance
Zone - An area on the xy plane, for specific objective
name- Name of the zonepoints- A list of coordinates of verticestype-ZoneType
ZoneType - An Enum for type of the zone, which indicates its objective
Event- Detect debris insideExclusion- Exclude points inside itselfInclusion- Exclude points OUTSIDE itselfCustom- Define by the user on the Cobalt Web App
Development
Running Tests
pytest
Code Formatting
black src/ samples/
Linting
flake8 src/ samples/
Type Checking
mypy src/
Requirements
- Python >= 3.8
- websockets library for WebSocket connections
- NumPy library for point clouds manipulation
Examples
See the samples/ directory for complete examples:
connection_example.py- Basic connection and object subscription example
License
MIT License - see LICENSE file for details
Contributing
- Install development dependencies:
pip install -e ".[dev]" - Make your changes
- Run tests:
pytest - Format code:
black . - Check linting:
flake8 - Submit a pull request
Support
For issues and questions, please visit: https://github.com/ceptontech/cobalt/issues
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 cobalt_sdk-0.6.0.tar.gz.
File metadata
- Download URL: cobalt_sdk-0.6.0.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec2ce09bc9c9897c2935148923d2a1dd6781db96e81a9b329321181f7f77d848
|
|
| MD5 |
2a3b93c553978787bb15bebf887392f6
|
|
| BLAKE2b-256 |
65f960bb3298830faadfa503d6e09f03501772b85a8f6115a3dcfbe2cb84d0f3
|
File details
Details for the file cobalt_sdk-0.6.0-py3-none-any.whl.
File metadata
- Download URL: cobalt_sdk-0.6.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22780ded1005697529c1bdb046f4658e7eabc5a67cd13c4027ff1937480b00fb
|
|
| MD5 |
5cf695f58cfe1a88e3faef488a3d6054
|
|
| BLAKE2b-256 |
79d7f7a05bfaee8642c9879ee1e3b01e2b6fd1260176c72ba92455186c136e0a
|