Skip to main content

embodied-city-python-sdk

A Simple Python SDK to interact with the Embodied City API. Users can easily achieve perception and control of drone agents through the following functions. When the command is issued via the API, changes in the agent's first-person view will be observed in the Console.

Installation

pip install embodiedcity

Usage

Acquire ID and token

Before you can use the SDK, you need to acquire a drone and obtain its token. You can get one by signing up at Embodied City.

In the website, you should go to the "Console" page, choose an available drone, and click on the "Acquire" button. After that, you will see a token with the drone ID.

ATTENTION: The token is a secret key that should not be shared with anyone.

ATTENTION: The token will expire after a certain period of time if you do not use it. (the time constrain will be notified in the website)

Initialize the client

from embodiedcity import DroneClient, ImageType, CameraID

base_url = "https://embodied-city.fiblab.net"
drone_id = "xxx"
token = "xxxxxxxx"
client = DroneClient(base_url, drone_id, token)

Move the drone

# Move the drone forward by 10 meter (Short movement distance may result in action failure)
client.move_back_forth(10)

Obtain the RGB image of the front camera

# Get a RGB image from the front-center camera
image = client.get_image(ImageType.Scene, CameraID.FrontCenter)

Get the depth image

# Get an image of the depth from the front-center camera
image = client.get_image(ImageType.DepthPlanar, CameraID.FrontCenter)

Release the drone

After you finish using the drone, you should release it to make it available for others.

You can do this by clicking on the "Release" button in the "Console" page.

FAQ

After invoking the control action, the drone did not move.

It is possible that the drone collided with a building. Try issuing a command to move the drone in a direction without obstacles. Alternatively, use the function DroneClient.move_to_position to force it to a specified location.

What should I do if I need the drone to perform more complex operations?

Please download and install the full embodiedcity simulator.

HTTP Protocol

POST /api/call-function

Body:

{
    "droneId": "drone ID",
    "action": "action string",
    "args": [arg1, arg2, ...],
    "token": "(optional) token for authorization"
}

Status code is 200 if the action is successful.

Action string, arg, return value:

Action Args Description Return Description
move_back_forth [distance: float] Move the drone back (<0) and forth (>0) by a certain distance (unit: meters) None -
move_horizontal [distance: float] Move the drone left (>0) and right (<0) by a certain distance (unit: meters) None -
move_vertical [distance: float] Move the drone up (>0) and down (<0) by a certain distance (unit: meters) None -
move_by_yaw [yaw: float] Rotate the drone by a certain angle. Positive values mean rotating counterclockwise, negative values mean rotating clockwise. (unit: radians) None -
get_image [image_type: int, camera_id: str] Get an image from the specified camera. image_type can be 0 (Scene), 1 (DepthPlanar), 2 (Segmentation). camera_id can be 0 (FrontCenter), 1 (FrontRight), 2 (FrontLeft), 3 (BottomCenter), 4 (BackCenter) image: bytes The image data in bytes (MIME: image/jpeg)
get_current_state [] Get the current state of the drone [[x, y, z], [pitch, roll, yaw]] The current state of the drone
move_to_position [x: float, y: float, z: float] Move the drone to the specified position None -
set_vehicle_pose [x: float, y: float, z: float, pitch: float, roll: float, yaw: float] Set the pose of the drone None -

Metadata

Release files for embodiedcity 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for embodiedcity 0.3.0
File Size Uploaded Provenance
embodiedcity-0.3.0.tar.gz 6.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for embodiedcity 0.3.0
File Interpreter ABI Platform
embodiedcity-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.3 kB

Release files / embodiedcity-0.3.0.tar.gz

Download URL embodiedcity-0.3.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f8db0c76054fba59f079085003ea2e6a4ec8c6d202fca1871c16036a62f1f0e4
BLAKE2b-256 checksum
How to use checksums
1f556d2306c3a567f50bccf91f5ec3b3836ed6c00de14abdabbe9ae3ac545fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / embodiedcity-0.3.0-py3-none-any.whl

Download URL embodiedcity-0.3.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83dee5c1bec2916495305b27ee2ba425c859ca02c54e76261d19e29786d040e6
BLAKE2b-256 checksum
How to use checksums
cac8a07e8e9d842904cdab826dedcefcb33abeed9c561045b7bc6c0387fd80ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Security for embodiedcity 0.3.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page