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.
Python SDK for LEGO WeDo 2.0
License: MIT License
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.
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?
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
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)
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.