Skip to main content

A client SDK for communicating with Ticos Server

Project description

Ticos Client Python SDK

A Python SDK for communicating with Ticos Server. This client SDK allows you to create applications that can send messages, handle motion and emotion commands, and maintain a heartbeat connection with the server.

Note: Check the latest SDK version at GitHub Releases

Installation

pip install ticos-client==0.1.7

Usage

from ticos_client import TicosClient
import time

def message_handler(message):
    print(f"Received message: {message}")

def motion_handler(parameters):
    print(f"Received motion command with parameters: {parameters}")

def emotion_handler(parameters):
    print(f"Received emotion command with parameters: {parameters}")

def main():
    # Create and start the client
    client = TicosClient(port=9999)
    
    # Set message handlers
    client.set_message_handler(message_handler)
    client.set_motion_handler(motion_handler)
    client.set_emotion_handler(emotion_handler)
    
    # Start the client
    if not client.start():
        print("Failed to start client")
        return
    
    try:
        # Example: Send a heartbeat message
        client.send_message({
            "name": "heartbeat",
            "parameters": {
                "timestamp": time.time()
            }
        })

        # Example: Send a motion command
        client.send_message({
            "name": "motion",
            "parameters": {
                "id": "1",
                "speed": 1.0,
                "repeat": 3
            }
        })

        # Example: Send an emotion command
        client.send_message({
            "name": "emotion",
            "parameters": {
                "id": "1",
                "intensity": 0.8,
                "duration": 2.5
            }
        })
        
        # Keep the main thread running
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print("Stopping client...")
    finally:
        client.stop()

if __name__ == "__main__":
    main()

API Reference

TicosClient

Constructor

client = TicosClient(port: int)

Creates a new Ticos client instance.

Methods

  • start() -> bool

    • Start the client
    • Returns True if startup successful
  • stop()

    • Stop the client and clean up resources
  • send_message(message: dict) -> bool

    • Send a message to the server
    • message: A dictionary containing the message data
    • Returns True if message sent successfully
  • set_message_handler(handler: Callable[[dict], None])

    • Set handler for general messages
    • handler: Function that takes a message dictionary as parameter
  • set_motion_handler(handler: Callable[[dict], None])

    • Set handler for motion commands
    • handler: Function that takes a parameters dictionary as parameter
  • set_emotion_handler(handler: Callable[[dict], None])

    • Set handler for emotion commands
    • handler: Function that takes a parameters dictionary as parameter

Message Format

Messages should be dictionaries with the following structure:

{
    "name": str,        # The name of the message (e.g., "motion", "emotion", "heartbeat")
    "parameters": dict  # A dictionary of parameters specific to the message type
}

Motion Message Parameters

{
    "id": str,         # The motion ID
    "speed": float,    # Motion speed (optional, default: 1.0)
    "repeat": int      # Number of times to repeat (optional, default: 1)
}

Emotion Message Parameters

{
    "id": str,           # The emotion ID
    "intensity": float,  # Emotion intensity (optional, default: 1.0)
    "duration": float    # Duration in seconds (optional)
}

Features

  • Simple and intuitive API for sending and receiving messages
  • Automatic handling of connection management
  • Thread-safe operations
  • Support for different message types (general messages, motion commands, emotion commands)
  • Built-in heartbeat mechanism

Development

  1. Clone the repository
  2. Install development dependencies:
    pip install -r requirements-dev.txt
    

For more examples, check out the examples/python directory.

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

ticos_client-0.1.7.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

ticos_client-0.1.7-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file ticos_client-0.1.7.tar.gz.

File metadata

  • Download URL: ticos_client-0.1.7.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for ticos_client-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9122dcbc9e30804fbd69cda5db717524176ce0c583d7600986d0bc32b11746dc
MD5 56b6f4a71f1011f5aa581f1c90abc239
BLAKE2b-256 0f19e6e8e4ce94254948b62ef7b1fed5db67c314fc4de0674fee845b79ee12d0

See more details on using hashes here.

File details

Details for the file ticos_client-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: ticos_client-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for ticos_client-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 966e6499f3718852b6c914ff855dd5265d6f736abfd6a09581e28242cff59c30
MD5 f5cd07480f29dcc624b30689cbf24336
BLAKE2b-256 49adfc0ef66e37093d19f2e2cc3d7e0211e75ff029c76c0cf4c0235210dcf3c6

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