bodyjim
comma body gymnasium environment API.
Installation
To install bodyjim run the following command:
pip install bodyjim
Package requires comma body with comma three/threex running openpilot 0.9.6 or newer.
Usage
Just like other gymnasium environments, bodyjim is easy to use. Base BodyEnv accepts ip address of the body, list of cameras to stream (valid values: driver - driver camera, road - front camera, wideRoad - front wide angle camera) and list of cereal services to stream (list of services).
Environment's step method accepts action in x, y direction coordinates and retrieves next observation in form of a dict with latest camera frames and cereal messages (structure definitions) received so far. Additional info dictionary contains information about message creation timestamps and validity (which are None, if they haven't been received yet).
from bodyjim import BodyEnv
body_address = ... # body ip address, pass localhost if running locally on the body
env = BodyEnv(body_address, ["driver"], ["accelerometer", "gyroscope"], render_mode="human")
env.reset()
# action coordinates assuming the front is the screen-facing side
# x-axis: Forward (negative) / Backwards (positive)
# y-axis: Left (positive) / Right (negative)
action = (1.0, 0.0) # (x, y)
obs, reward, done, truncated, info = env.step(action)
# obs = { "cameras": { "driver": np.ndarray }, "accelerometer": {...}, "gyroscope": {...} }
# info = { "times": <dict_of_ns_timestamps_for_each_service>, "valid": <dict_of_message_validity_for_each_service> }
driver_image = obs["camera"]["driver"] # nd.ndarray
accelerometer, accelerometer_t = obs["accelerometer"], info["times"]["accelerometer"]
By default body environment always returns reward = 0 and done = False. Subclasses can customize this behavior by overriding reward and is_done methods:
class CustomBodyEnv(BodyEnv):
def reward(self, obs: Optional[ObsType], action: ActType, next_obs: ObsType) -> float:
# obs - latest observations, action - most recently executed actions, next_obs - observations after executing such action
...
def is_done(self, obs: Optional[ObsType], action: ActType, next_obs: ObsType) -> bool:
# same as for reward
...
BodyEnv supports two rendering modes for visualization purposes:
rgb_array- returns image formed by horizontally stacking frames from each requested camerahuman- displays pygame window with live view from cameras
Examples
Repository comes with few examples, showcasing how to use the library.
You can use the body-jim library either on the body itself or from a remote computer. These examples are meant to be ran remotely and require additional dependencies, which can be installed using:
pip install bodyjim[examples]
To control the body with wasd:
python3 examples/wasd.py body_ip_address [CAMERA...]
To perform "random walk":
python3 examples/random_walk.py body_ip_address [CAMERA...]
To try follow person mode, which uses YOLOv5 to detect and follow the tallest person in the frame:
python3 examples/follow_human.py body_ip_address
To have the body roam around using our GPT policy (GPU required):
python3 examples/roam.py body_ip_address
Metadata
Release files for bodyjim 1.0.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 | Provenance | Actions |
|---|---|---|---|---|
| bodyjim-1.0.3.tar.gz | 12.4 kB | Without provenance | Details for bodyjim-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bodyjim-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for bodyjim-1.0.3-py3-none-any.whl |
Total release size: 22.2 kB
Release files / bodyjim-1.0.3.tar.gz
| Download URL | bodyjim-1.0.3.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8299c067608276f945f0edfce0dca011c2477936fa6d0dd3a018b87e00a2f6b4
|
|
BLAKE2b-256 checksum How to use checksums |
be61159de92956a03f84951aaf844b63b787060d37e073237c332e94ddfc27bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.9
|
Release files / bodyjim-1.0.3-py3-none-any.whl
| Download URL | bodyjim-1.0.3-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbef614ab54ebb468f96f6625909fa42059d8217fb2171f5c01f12a0124693e3
|
|
BLAKE2b-256 checksum How to use checksums |
daa2efc32fc2350fc17d6eea209ee86c7fffa312cf7590fac212f3138a8741f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.9
|
Security for bodyjim 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.