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]
for the most simple way
export WEBOTS_HOME=/usr/local/webots
uvx --from webots-grpc webots-grpc-gateway --robot-name="{ROBOT_NAME}"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.
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/*.protoor 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/*.protoFix 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/*.protoAnd 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=8Modify your own robot name.
export WEBOTS_HOME=/usr/local/webots
uv run "${WEBOTS_HOME}/webots-controller" --robot-name='robot' ./webots_grpc/server.pyIf 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\pythonuv run "C:\Program Files\Webots\msys64\mingw64\bin\webots-controller.exe" --robot-name='robot' .\webots_grpc\server.py
There are cpp and python client API support with unittests, plz refer python test tests/README.md for more information.
uv run python -m pytestCheck cpp client test src/tests
conan build . --build=missing