Skip to main content

Robotics.dev AI robotics app builder

Project description

ROBOTICS.DEV App Builder

Run P2P AI Robotics.dev apps anywhere!

ROS2 topic namespacing is configured per robot in the robotics.dev portal (rosNamespace), not in SDK connect options. See CHANGELOG.md.

WebRTC ICE servers are fetched from GET /webrtc/ice-servers on connect (STUN by default). TURN relay requires turnRelayEnabled: true on your Firestore user document (users/{uid}) — a paid add-on (billing coming soon). All paid users share the same server-side Metered.ca credentials.

pip install robotics-dev

Usage:

await robotics.connect({
    'server': 'ws://192.168.0.47:3001',
    'robot': 'eeeaa722-...-9a53-c945a5822b60',
    'token': '5a66b323-...-9169-77a95014f339'
}, handle_message)

robotics.speak('eeeaa722-...-9a53-c945a5822b60', 'this is a test')

robotics.twist('eeeaa722-...-9a53-c945a5822b60', forward_twist)

Here's an example python script:

import asyncio
import signal
import base64
import sys
from pathlib import Path

# Add the src directory to Python path for local testing
src_path = Path(__file__).parent.parent / 'src'
sys.path.append(str(src_path))

# Import for local testing
from robotics_dev.robotics import robotics
# For production, use:
# from robotics_dev import robotics

# Create twist message for moving forward at 20% speed
forward_twist = {
    "linear": {
        "x": 0.2,  # 20% forward velocity
        "y": 0.0,
        "z": 0.0
    },
    "angular": {
        "x": 0.0,
        "y": 0.0,
        "z": 0.0
    }
}

# Create stop twist message
stop_twist = {
    "linear": {
        "x": 0.0,
        "y": 0.0,
        "z": 0.0
    },
    "angular": {
        "x": 0.0,
        "y": 0.0,
        "z": 0.0
    }
}

one_time = True

async def handle_message(ros_message):
    global one_time
    # ros_message is already parsed by the SDK
    print('Received p2p data:', ros_message)

    if one_time:
        one_time = False
        await robotics.speak('eeeaa722-...-9a53-c945a5822b60', 'this is a test')

        print('Moving robot forward at 20% speed...')
        await robotics.twist('eeeaa722-...-9a53-c945a5822b60', forward_twist)

        # Stop after 5 seconds
        await asyncio.sleep(5)
        print('Stopping robot...')
        await robotics.twist('eeeaa722-...-9a53-c945a5822b60', stop_twist)

async def main():
    # Set up signal handlers for graceful shutdown
    loop = asyncio.get_running_loop()
    for sig in (signal.SIGINT, signal.SIGTERM):
        loop.add_signal_handler(sig, lambda: asyncio.create_task(cleanup()))

    try:
        # Connect to robotics.dev
        await robotics.connect({
            'server': 'ws://192.168.0.47:3001',
            'robot': 'eeeaa722-...-9a53-c945a5822b60',
            'token': '5a66b323-...-9169-77a95014f339'
        }, handle_message)

        # Keep running until interrupted
        while True:
            await asyncio.sleep(1)

    except asyncio.CancelledError:
        print("Shutdown requested...")
    except Exception as e:
        print(f"Error: {e}")

async def cleanup():
    print("Disconnecting...")
    await robotics.disconnect()
    # Stop the event loop
    loop = asyncio.get_running_loop()
    loop.stop()

if __name__ == "__main__":
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotics_dev-0.0.19.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robotics_dev-0.0.19-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file robotics_dev-0.0.19.tar.gz.

File metadata

  • Download URL: robotics_dev-0.0.19.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for robotics_dev-0.0.19.tar.gz
Algorithm Hash digest
SHA256 d44ad44ec85f0fe670308621693b801596b5b493dd91584ac7fd50fb7740a6bd
MD5 8ab9c78714cc275e6625749c34dd4d9b
BLAKE2b-256 5624f364f791d181d39094a316a82aa1bf841d246aa1c13a7dbb201ba60e78cc

See more details on using hashes here.

File details

Details for the file robotics_dev-0.0.19-py3-none-any.whl.

File metadata

  • Download URL: robotics_dev-0.0.19-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for robotics_dev-0.0.19-py3-none-any.whl
Algorithm Hash digest
SHA256 b607e075a203eb5a5fc4f20560a99562c75a96a83a7a4f04df8017cdcf4b1a08
MD5 91f53aa65ea13ecc5437f99198827359
BLAKE2b-256 5d2bb2ead35446ee474f4986b203f184ea0796d20ce15b3b4008faaf438fa01f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page