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.18.tar.gz (12.6 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.18-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for robotics_dev-0.0.18.tar.gz
Algorithm Hash digest
SHA256 aa494fcd38f1d73499d352967716cc19bcac85560e0b0d958cec17ee2c05328e
MD5 be35a477d9dc37b55e31edf6f039439a
BLAKE2b-256 473a4f4529f0d1f0dcef11772708826b869476c6812e483645edf17e1bca9e5b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for robotics_dev-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 3d2eebb40401e5771029719d6dfa53217c37adcb714628456df3cc18dd22b65e
MD5 ad19e4b55389975073b42606a8e469ca
BLAKE2b-256 99662eabebba42c58bd44e4c761b116c80b5b6cb65da4166df0e8434e095cc44

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