Skip to content

Commit da1e1d6

Browse files
PCrnjakclaude
andcommitted
Import the Sim2Bot Python client
The client, the local bridge relay it can start for you, the protocol fixtures every implementation is tested against, and ten runnable examples. Extracted from the Sim2Bot monorepo as a fresh tree rather than filtered history: the application that runs the physics stays closed source, and this repository is the part people write code against. It is the source of truth for the `sim2bot` package on PyPI. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Source Robotics <30388414+PCrnjak@users.noreply.github.com>
0 parents  commit da1e1d6

54 files changed

Lines changed: 5340 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Bug report
2+
description: Something does not work as documented
3+
labels: ["bug"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Most reports turn out to be about the Sim2Bot application or the bridge
9+
rather than the Python code, so the version and the bridge log below are
10+
what make a report actionable. Report it here either way — it gets
11+
routed.
12+
13+
- type: textarea
14+
id: what-happened
15+
attributes:
16+
label: What happened
17+
description: What you expected, and what happened instead.
18+
validations:
19+
required: true
20+
21+
- type: textarea
22+
id: reproduce
23+
attributes:
24+
label: Smallest script that shows it
25+
description: Python that someone else can run. Include the robot you loaded.
26+
render: python
27+
validations:
28+
required: true
29+
30+
- type: input
31+
id: package-version
32+
attributes:
33+
label: sim2bot package version
34+
description: "`pip show sim2bot`, or the SDK line printed by `sim2bot doctor`"
35+
placeholder: "0.1.0"
36+
validations:
37+
required: true
38+
39+
- type: input
40+
id: app-version
41+
attributes:
42+
label: Sim2Bot app version
43+
description: Shown in the app under Help. Say "not used" if the app was not involved.
44+
placeholder: "1.4.0 (9f2c1ab)"
45+
validations:
46+
required: true
47+
48+
- type: textarea
49+
id: bridge-log
50+
attributes:
51+
label: Bridge output
52+
description: >
53+
The terminal output of the bridge while the problem happened, and the
54+
output of `sim2bot doctor`.
55+
render: shell
56+
57+
- type: input
58+
id: environment
59+
attributes:
60+
label: Python and operating system
61+
placeholder: "Python 3.12.4, Ubuntu 24.04"
62+
validations:
63+
required: true
64+
65+
- type: dropdown
66+
id: transport
67+
attributes:
68+
label: Transport
69+
options:
70+
- WebSocket (default)
71+
- UDP
72+
- Raw TCP
73+
- Not relevant
74+
validations:
75+
required: true

‎.github/ISSUE_TEMPLATE/config.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Documentation
4+
url: https://docs.sim2bot.com/
5+
about: Guides, the Python API reference and the protocol description.
6+
- name: Question about using Sim2Bot
7+
url: https://github.com/Source-Robotics/sim2bot-python/discussions
8+
about: Ask here rather than opening an issue.
9+
- name: Security problem
10+
url: https://github.com/Source-Robotics/sim2bot-python/blob/main/SECURITY.md
11+
about: Email info@source-robotics.com instead of opening a public issue.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Feature request
2+
description: Something the client should be able to do
3+
labels: ["enhancement"]
4+
body:
5+
- type: textarea
6+
id: problem
7+
attributes:
8+
label: What are you trying to do
9+
description: The task, not the API you have in mind. It often has a shorter route.
10+
validations:
11+
required: true
12+
13+
- type: textarea
14+
id: proposal
15+
attributes:
16+
label: What you would like
17+
description: Sketch the call you would want to write.
18+
render: python
19+
20+
- type: dropdown
21+
id: side
22+
attributes:
23+
label: Where do you think this lives
24+
description: A guess is fine.
25+
options:
26+
- The Python client
27+
- The bridge
28+
- The Sim2Bot application (new protocol message)
29+
- Not sure
30+
validations:
31+
required: true
32+
33+
- type: textarea
34+
id: workaround
35+
attributes:
36+
label: What you do today
37+
description: The workaround, if you have one.

‎.github/pull_request_template.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## What this changes
2+
3+
<!-- One or two sentences. Link the issue if there is one. -->
4+
5+
## Why
6+
7+
<!-- The problem it solves, or the behaviour it makes possible. -->
8+
9+
## Checks
10+
11+
- [ ] `pytest` passes locally
12+
- [ ] Commits are signed off (`git commit -s`) — see CONTRIBUTING.md
13+
- [ ] Docstrings updated where the behaviour changed
14+
15+
## Protocol
16+
17+
- [ ] This does not change the wire format
18+
19+
If it does: which fixture in `fixtures/v1/` changed, and what the Sim2Bot
20+
application has to ship for it to work.

‎.github/workflows/ci.yml‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ci-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
test:
17+
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest]
23+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
24+
include:
25+
# The bridge binds sockets and spawns a server process, so check the
26+
# other two platforms on one version rather than the whole matrix.
27+
- os: macos-latest
28+
python-version: "3.12"
29+
- os: windows-latest
30+
python-version: "3.12"
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
cache: pip
38+
39+
- name: Install
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install -e ".[dev]"
43+
44+
- name: Test
45+
run: pytest -q
46+
47+
package:
48+
name: Build and check the package
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- uses: actions/setup-python@v5
54+
with:
55+
python-version: "3.12"
56+
cache: pip
57+
58+
- name: Build
59+
run: |
60+
python -m pip install --upgrade pip build twine
61+
python -m build
62+
63+
- name: Check metadata
64+
run: twine check dist/*
65+
66+
- uses: actions/upload-artifact@v4
67+
with:
68+
name: distributions
69+
path: dist/

‎.github/workflows/publish.yml‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish to PyPI
2+
3+
# Runs when a release is published in GitHub. Publishing uses PyPI trusted
4+
# publishing (OpenID Connect), so no API token is stored in this repository.
5+
#
6+
# Set up once on PyPI: Project -> Publishing -> add a GitHub publisher with
7+
# owner Source-Robotics, repository sim2bot-python, workflow publish.yml and
8+
# environment pypi.
9+
10+
on:
11+
release:
12+
types: [published]
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
build:
19+
name: Build distributions
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
28+
- name: Build
29+
run: |
30+
python -m pip install --upgrade pip build twine
31+
python -m build
32+
33+
- name: Check metadata
34+
run: twine check dist/*
35+
36+
- name: Confirm the tag matches the package version
37+
run: |
38+
tag="${GITHUB_REF_NAME#v}"
39+
version="$(python -c 'import tomllib,pathlib; print(tomllib.loads(pathlib.Path("pyproject.toml").read_text())["project"]["version"])')"
40+
if [ "$tag" != "$version" ]; then
41+
echo "tag $tag does not match pyproject version $version" >&2
42+
exit 1
43+
fi
44+
45+
- uses: actions/upload-artifact@v4
46+
with:
47+
name: distributions
48+
path: dist/
49+
50+
publish:
51+
name: Publish
52+
needs: build
53+
runs-on: ubuntu-latest
54+
environment:
55+
name: pypi
56+
url: https://pypi.org/p/sim2bot
57+
permissions:
58+
id-token: write # the OIDC token that PyPI trusts instead of a password
59+
steps:
60+
- uses: actions/download-artifact@v4
61+
with:
62+
name: distributions
63+
path: dist/
64+
65+
- uses: pypa/gh-action-pypi-publish@release/v1

‎.gitignore‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.egg-info/
5+
.eggs/
6+
build/
7+
dist/
8+
9+
# Environments
10+
.venv/
11+
venv/
12+
env/
13+
14+
# Tooling
15+
.pytest_cache/
16+
.mypy_cache/
17+
.ruff_cache/
18+
.coverage
19+
htmlcov/
20+
21+
# Editors and OS
22+
.DS_Store
23+
.idea/
24+
.vscode/
25+
*.swp

‎CHANGELOG.md‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Changelog
2+
3+
All notable changes to the `sim2bot` package are recorded here. The format
4+
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions
5+
follow [Semantic Versioning](https://semver.org/).
6+
7+
Each release states the Sim2Bot application versions it was verified against,
8+
because the protocol is what the two share.
9+
10+
## [Unreleased]
11+
12+
## [0.1.0] — unreleased
13+
14+
First public release: the client, the local bridge and the protocol fixtures,
15+
extracted from the Sim2Bot monorepo.
16+
17+
### Added
18+
19+
- `Robot` client: joint position and velocity targets, Cartesian targets via the
20+
browser's IK, timed joint trajectories, gripper, mobile and aerial base
21+
velocity, reset and stop.
22+
- Telemetry with joint position, velocity, acceleration and jerk, TCP pose,
23+
twist, acceleration and jerk, gripper state and room devices, read
24+
latest-value.
25+
- Camera subscriptions with JPEG and raw codecs, decoded to numpy images with
26+
the `[cv2]` extra.
27+
- Scene discovery (`describe`, `cameras`, `room_devices`) with stable robot IDs.
28+
- Debug markers: spheres, boxes, arrows, lines, text, axes and point clouds.
29+
- Rooms, so one script pairs with one browser tab.
30+
- WebSocket, raw TCP and UDP control transports.
31+
- The local bridge, runnable as `sim2bot bridge` or started automatically with
32+
`Robot(auto_bridge=True)`.
33+
- CLI: `bridge`, `doctor`, `list-robots`, `open`.
34+
- `fixtures/v1/`, the published wire-format contract.
35+
36+
### Changed
37+
38+
- `sim2bot open` now opens <https://app.sim2bot.com> by default. Set
39+
`SIM2BOT_APP_URL` to point it elsewhere, such as a development server.
40+
41+
### Verified against
42+
43+
- Sim2Bot app: *(fill in at release)*
44+
45+
[Unreleased]: https://github.com/Source-Robotics/sim2bot-python/compare/v0.1.0...HEAD
46+
[0.1.0]: https://github.com/Source-Robotics/sim2bot-python/releases/tag/v0.1.0

‎CODE_OF_CONDUCT.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Code of conduct
2+
3+
## The short version
4+
5+
Be respectful. Assume the person on the other side is trying to build something
6+
and is short on time, as you are.
7+
8+
Not welcome here: personal attacks, harassment of any kind, demeaning comments
9+
about who someone is, publishing someone's private information, or persistent
10+
disruption of a discussion.
11+
12+
## Where this applies
13+
14+
Everywhere this project happens: issues, pull requests, discussions, and any
15+
place someone is representing the project in public.
16+
17+
## Reporting
18+
19+
Report a problem to <info@source-robotics.com>. Reports are handled privately.
20+
Maintainers may edit or remove comments, close issues, or block accounts, and
21+
will explain why when they do.
22+
23+
This is a short-form adaptation of the [Contributor Covenant](https://www.contributor-covenant.org/),
24+
version 2.1.

0 commit comments

Comments
 (0)