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.8
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",
"arguments": {
"timestamp": time.time()
}
})
# Example: Send a motion command
client.send_message({
"name": "motion",
"arguments": {
"motion_tag": "hug",
"speed": 1.0,
"repeat": 3
}
})
# Example: Send an emotion command
client.send_message({
"name": "emotion",
"arguments": {
"emotion_tag": "smile",
"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")
"arguments": dict # A dictionary of parameters specific to the message type
}
Motion Message Parameters
{
"name": str, # The motion ID
"arguments": dict # Motion speed (optional, default: 1.0)
}
Emotion Message Parameters
{
"name": str, # The emotion ID
"arguments": dict # Emotion intensity (optional, default: 1.0)
}
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
- Clone the repository
- Install development dependencies:
pip install -r requirements-dev.txt
For more examples, check out the examples/python directory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ticos_client-0.1.8.tar.gz.
File metadata
- Download URL: ticos_client-0.1.8.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19ba0aec5fc8b8990c75cae7c8b632e0d6e56806786ff94d2b0245a73d064281
|
|
| MD5 |
a452b46931c4100a30c37a1ae0191ff7
|
|
| BLAKE2b-256 |
60bfcfaa6f341fd85ee749ffbf94d8381972c5014587d3eb350b8a286636f682
|
File details
Details for the file ticos_client-0.1.8-py3-none-any.whl.
File metadata
- Download URL: ticos_client-0.1.8-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1533d82b818be7542ac55567d325951a647dfe4fa8244b3a19398f689ec9a6f4
|
|
| MD5 |
7d97b0f1ff244fa7439b38b3fd6d5d9e
|
|
| BLAKE2b-256 |
3af1568e740252d08f4be2aa8719e2815345111f28374e40f829feb8c397fc55
|