Coder Social home page Coder Social logo

temi's Introduction

Temi Python API

(Unofficial) Python library for remote-controlling the Temi robot, via WebSocket.

A corresponding server needs to be installed on Temi. You can find it here.

Installation

pip install temi

Usage

Basics

This library uses asyncio to perform the operations. The minimum structure is as follows:

import asyncio
from temi import Temi

async def connect_temi():
    temi = Temi('ws://YOUR_TEMI_IP:8175')
    await temi.connect()
    await temi.speak(sentence='Hello!').run()

asyncio.get_event_loop().run_until_complete(connect_temi())

Note that each call needs to be await-ed, and must end with a run().

Sending multiple commands at once

Sometimes, you need temi to do multiple things at once, while other times you may want Temi to do things sequentially. It is easy to mix both in you code. Just do it like such:

# Temi will go to the door, uttering "I hear someone at the door" along the way.
# When Temi arrives, it will ask the question "Hello! What's your name?"
await temi.speak(sentence='I hear someone at the door.').goto(location='Front Door').run()
await temi.ask(sentence="Hello! What's your name?").run()

Timeout

All commands support a timeout parameter. If it is specified, the await will terminate after the timeout, regardless of execution state.

# The call will return after three seconds, regardless of Temi's location.
# Temi may continue walking to the door, but you can command it to stop in the following code.
await temi.goto(location='Front Door', timeout=3).run()

API

Currently, the following APIs are implemented:

# Speak a sentence.
await temi.speak(sentence="Sentence to say", timeout=None).run()

# Ask a question, then return the reply.
reply = await temi.ask(sentence="Question to ask", timeout=None).run()

# Go to a location
await temi.goto(location="Location name", timeout=None).run()

# Turn by an angle
await temi.turn(angle=angle, timeout=None).run()

# Tilt screen to an angle (-25 ~ 55)
await temi.turn(angle=angle, timeout=None).run()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.