Coder Social home page Coder Social logo

lego-wedo-2.0-python-sdk's Introduction

Python SDK for LEGO WeDo 2.0

A Python SDK, which provides an API for connecting and controlling LEGO WeDo 2.0 Smarthubs.

Requires BLED112 Bluetooth LE module.

Read the Wiki for more info about using the SDK.

lego-wedo-2.0-python-sdk's People

Contributors

jannopet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lego-wedo-2.0-python-sdk's Issues

Tilt sensor

Hello,
congratulations on your project, it's amazing!
I am not sure if you are still following this repository. If you still are,I have a problem with the get_tilt() function
Sometimes (i am not sure why) the function crashes and i get the following message

Traceback (most recent call last):
File "wedo_tilt.py", line 12, in
a = hub1.get_tilt()
File "/home/teacher/.local/lib/python3.6/site-packages/wedo2/smarthub.py", line 228, in get_tilt
angle = tilt_sensor.get_angle()
File "/home/teacher/.local/lib/python3.6/site-packages/wedo2/services/tilt_sensor.py", line 81, in get_angle
if len(data_set_numbers) == 2:
TypeError: object of type 'NoneType' has no len()

this is in a while that constantly checks the tilt value
Am I doing something wrong? Is there a way to avoid the crash?

Cannot connect through Bluetooth

Dear @jannopet,

My sister and I would like to use your library to control our Wedo 2.0 for First Lego League.

However, we keep getting this error: pygatt.exceptions.NotConnectedError: Unable to reconnect with USB device after rebooting when initing the Smart Hub.

May I ask if you can help us with this problem?

Thank you very much!

Antoni and Ariana

Bothersome issues

First off let me say WOW. Thank you. I am a newbie and attempting to help my daughter connect her wedo2 to her raspberry pi. We are learning python together. We installed your SDK, and were successful at connection the hub to the pi. However, we get this error message and can't figure out what it means. Anybody's thoughts, comments or help would be greatly appreciated.

hub = Smarthub()
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/.local/lib/python2.7/site-packages/wedo2/smarthub.py", line 29, in init
device_address = devices[0]['address']
IndexError: list index out of range
hub = Smarthub()
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/.local/lib/python2.7/site-packages/wedo2/smarthub.py", line 32, in init
self.service_manager = ServiceManager(self.io)
File "/home/pi/.local/lib/python2.7/site-packages/wedo2/bluetooth/service_manager.py", line 15, in init
self.find_available_services()
File "/home/pi/.local/lib/python2.7/site-packages/wedo2/bluetooth/service_manager.py", line 26, in find_available_services
self.create_services(self.services_data)
File "/home/pi/.local/lib/python2.7/site-packages/wedo2/bluetooth/service_manager.py", line 31, in create_services
service = LegoServiceFactory.create(connect_info, self.io)
TypeError: unbound method create() must be called with LegoServiceFactory instance as first argument (got ConnectInfo instance instead)

A minor issue

I have a connection issue. It turned out that in my environment too many devices which have stronger signal than wedo2 motor, even wedo2 is very close to my computer. So I made a workaround below.

Is there any better way to determine wedo2 motor?
Thanks,
Ray

class Smarthub:

def __init__(self, dev_addr = None):

    device_address = dev_addr
    if device_address == None:
        devices = adapter.scan(1)
        devices = sorted(devices, key=lambda k: k['rssi'], reverse=True)
        device_address = devices[0]['address']

from wedo2.smarthub import Smarthub    
hub = Smarthub('xx.xx.xx.xx.xx')
hub.turn_motor(80)

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.