webots-grpc
This project is a simple gateway convert from gRPC to webots socket IPC API. It follow some rules.
- webots extern controller
- synchronous simulation
graph LR
A[Webots] <-->|API| B[Python extern controller gRPC service gateway]
B <-->|gRPC| D[Python gRPC client app]
B <-->|gRPC| C[CPP gRPC client app]
run gateway (gRPC server)
for the most simple way
export WEBOTS_HOME=/usr/local/webots
uvx --from webots-grpc webots-grpc-gateway --robot-name="{ROBOT_NAME}"
development
gateway (gRPC server)
uv run python -m webots_grpc --robot-name="{ROBOT_NAME}"
uv run webots-grpc-gateway --robot-name="{ROBOT_NAME}"
# pipx run --spec . webots-grpc-gateway --robot-name="{ROBOT_NAME}"
# uvx --from git+https://github.com/existedinnettw/webots-grpc.git webots-grpc-gateway --robot-name="{ROBOT_NAME}"
webots-grpc-gateway is actually a wrapper for script, webots_grpc/server.py. webots-grpc-gateway will find webots controller automatically based on WEBOTS_HOME and execute the script automatically.
For development purpose, you can run the script though webots controller directly.
build
Create service from proto file,
uv run python -m grpc_tools.protoc -I ./protos --python_out=./webots_grpc/generated --pyi_out=./webots_grpc/generated --grpc_python_out=./webots_grpc/generated ./protos/*.proto
or generate document by protoc-gen-doc plugin at the same time
uv run python -m grpc_tools.protoc -I ./protos --python_out=./webots_grpc/generated --pyi_out=./webots_grpc/generated --grpc_python_out=./webots_grpc/generated --doc_out=./doc --doc_opt=html,index.html ./protos/*.proto
Fix python import issue
uv run protol --create-package --in-place --python-out ./webots_grpc/generated protoc --protoc-path "uv run python -m grpc_tools.protoc" --proto-path=./protos ./protos/*.proto
compile executable
And if want to build exe file,
Configure additional module search paths, like PYTHONPATH #9168 option to specify a project root directory to be added to the python path
PYTHONPATH="${WEBOTS_HOME}/lib/controller/python" uv run python -m nuitka --include-module=controller --onefile --assume-yes-for-downloads ./webots_grpc/server.py --jobs=8
execution on linux
Modify your own robot name.
export WEBOTS_HOME=/usr/local/webots
uv run "${WEBOTS_HOME}/webots-controller" --robot-name='robot' ./webots_grpc/server.py
execution on windows
If you use MSYS2 as state, export WEBOTS_HOME=C:\Program Files\Webots
I don't find out way to integrate
WEBOTS_HOMEyet
Or using uv directly config python path,
; .env
PYTHONPATH=C:\Program Files\Webots\lib\controller\python
uv run "C:\Program Files\Webots\msys64\mingw64\bin\webots-controller.exe" --robot-name='robot' .\webots_grpc\server.py
client
There are cpp and python client API support with unittests, plz refer python test tests/README.md for more information.
PYTHON
uv run python -m pytest
CPP
Check cpp client test src/tests
conan build . --build=missing
Metadata
Release files for webots-grpc 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| webots_grpc-0.1.3.tar.gz | 13.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| webots_grpc-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.0 MB
Release files / webots_grpc-0.1.3.tar.gz
| Download URL | webots_grpc-0.1.3.tar.gz |
|---|---|
| Size | 13.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61fa6813fcb73a881e22ae05ec95b56e3596a22d47cb8b56999dc2a96e0c499b
|
|
BLAKE2b-256 checksum How to use checksums |
169901a352ad091ed230df80831367f46d696657ddc284497f06c46602897434
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / webots_grpc-0.1.3-py3-none-any.whl
| Download URL | webots_grpc-0.1.3-py3-none-any.whl |
|---|---|
| Size | 36.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e6839d4412ff07e4c7400070615faf0dc9d6cad2fb1534f0a8ffddffb96b0a5
|
|
BLAKE2b-256 checksum How to use checksums |
85dc92987bcf95b827cfa0a17642687f32f4060c3cfed75339b260f11ab4625a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|