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.6

Usage

from ticos_client import TicosClient
import time

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

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

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

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({
            "type": "heartbeat",
            "timestamp": time.time()
        })
        
        # 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[[str], None])

    • Set handler for motion commands
    • handler: Function that takes a motion ID string as parameter
  • set_emotion_handler(handler: Callable[[str], None])

    • Set handler for emotion commands
    • handler: Function that takes an emotion ID string as parameter

Message Format

Messages should be dictionaries with the following structure:

{
    "type": str,      # Message type (e.g., "heartbeat", "motion", "emotion")
    "timestamp": float,  # Optional timestamp
    "data": dict      # Optional additional data
}

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.6.tar.gz (4.2 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.6-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ticos_client-0.1.6.tar.gz
  • Upload date:
  • Size: 4.2 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.6.tar.gz
Algorithm Hash digest
SHA256 22ee11987e3a6e407435a63c675160c8e0132017348672d2a20043b2e1b34a00
MD5 c8d5ea82720f7217e0769ca7e9425d27
BLAKE2b-256 7666af6f73bc5306d4650e61a76486fef1ec0ee6b32cc32efe4b4261065f7b37

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ticos_client-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 43e7f15b72e6ebd30e51bc99177c7dd948eab3ee7ec42c829b91ac67139c9f2a
MD5 8933c153234729a27eb7e23bacc33638
BLAKE2b-256 d812892ce4f1f7e9ff7420386b0111aa0217d9178c11ae48f5260727e0c995c3

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