Giter VIP home page Giter VIP logo

pythonsphero's Introduction

Python Sphero Examples & Tutorials

This repository contains materials for easy learning of programming Sphero using Python language and the Sphero Kulka API by Karol Szuster. It is designed for a total programming/Python/robotics newbie.

Directory tutorials contains a complete guide that introduces each Sphero function step by step with explanation, hints, scaffolding code and microtasks, meanwhile examples is a place, where fully functional and standalone examples are placed for your experiments.

Configuration

Make sure that Python is installed on your machine, as well as Python Sphero client module:

pip install kulka

Add Sphero device to the OS (double tap the Orb to wake it up and pair it to your PC via bluetooth). Then, You may use the kulka to connect with the device (knowing it's mac address) in such way:

from kulka import Kulka
from random import randint

with Kulka('01:02:03:04:05:06') as kulka:
    kulka.set_inactivity_timeout(3600)
    kulka.roll(randint(0, 255), randint(0, 359))

Should the Sphero be properly paired and the Sphero's device mac correctly set, you can go ahead, run the code and have fun with it!

Usage

Examples

Run examples with:

python spheroCircle.py

After you've finished games & stuff, tell the Sphero to go to sleep:

python spheroSleep.py

Tutorials

Basically, each main directory beginning with a number is a group of smaller tasks, that utilize a specific area of Sphero programming. Explore four sections, namely:

    1. Hello Sphero
    1. Sphero basics
    1. Advanced movement
    1. Sphero guess game

Each small task is to be done one by one, beginning from the first task. To start the tutorial, open the 1_<taskname>.py file in Sublime, ekhm I meant some good text editor you surely have. There is a description of each task with microtask listed. You may freely modify each file and run it over and over again using simply python sometask.py.

Those examples will guide you through communicating with Sphero, modifying its state (colors or backled light), rotating it and rolling. Last task is also a good practice for Python beginners, where a goal is to implement a game of guessing the number, step by step using feature-oriented programming, where each new functionality is added to the old ones in each and only step.

In order to promote an awesome Polish language, all comments and namings are Polish words ;) A jeżeli rozumiesz co tutaj jest napisane, zapraszam Cię na świetne szkolenia dla początkujących programistów Pythona (i nie tylko) organizowanych przez Geek Girls Carrots, gdzie na żywo prowadzimy uczestników przez te zadania.

Notes

This software has been tested on Windows and Linux with Sphero1/2 and has code improvements that significantly reduced problems with timeouts and connection drops. Moreover, it is Python 2.x and Python 3.x compatible. There's a known issue with running this code on OS X, that is related to limited compatibility of bluetooth connector with this platform. If you would like to try this code on OS X, please checkout our first release using default Sphero API lib (beware, it is Python 2.x compatible only). For more sphero-experience check out awesome educational materials on the official Sphero's Education site that partially inspired the code snippets here. Aw, did I mention that Sphero is really cool for playing and learning and (playing and learning)?

License

CC

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.