All Projects → undera → Pylgbst

undera / Pylgbst

Licence: mit
Python library for LEGO® PoweredUp devices

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Pylgbst

Cherry Autonomous Racecar
Implementation of the CNN from End to End Learning for Self-Driving Cars on a Nvidia Jetson TX1 using Tensorflow and ROS
Stars: ✭ 294 (-21.18%)
Mutual labels:  robotics
Gpd
Detect 6-DOF grasp poses in point clouds
Stars: ✭ 330 (-11.53%)
Mutual labels:  robotics
Handeye calib camodocal
Easy to use and accurate hand eye calibration which has been working reliably for years (2016-present) with kinect, kinectv2, rgbd cameras, optical trackers, and several robots including the ur5 and kuka iiwa.
Stars: ✭ 364 (-2.41%)
Mutual labels:  robotics
Ros Sensor Fusion Tutorial
An in-depth step-by-step tutorial for implementing sensor fusion with robot_localization! 🛰
Stars: ✭ 306 (-17.96%)
Mutual labels:  robotics
Floam
Fast LOAM: Fast and Optimized Lidar Odometry And Mapping for indoor/outdoor localization (Lidar SLAM)
Stars: ✭ 326 (-12.6%)
Mutual labels:  robotics
Gym Miniworld
Simple 3D interior simulator for RL & robotics research
Stars: ✭ 338 (-9.38%)
Mutual labels:  robotics
Dreamerv2
Mastering Atari with Discrete World Models
Stars: ✭ 287 (-23.06%)
Mutual labels:  robotics
Kimera Semantics
Real-Time 3D Semantic Reconstruction from 2D data
Stars: ✭ 368 (-1.34%)
Mutual labels:  robotics
Gopigo
The GoPiGo Robot for Raspberry Pi
Stars: ✭ 329 (-11.8%)
Mutual labels:  robotics
Yarp
YARP - Yet Another Robot Platform
Stars: ✭ 358 (-4.02%)
Mutual labels:  robotics
Ikpy
An Inverse Kinematics library aiming performance and modularity
Stars: ✭ 311 (-16.62%)
Mutual labels:  robotics
Ai Deadlines
⏰ AI conference deadline countdowns
Stars: ✭ 3,852 (+932.71%)
Mutual labels:  robotics
Dynamic robot localization
Point cloud registration pipeline for robot localization and 3D perception
Stars: ✭ 339 (-9.12%)
Mutual labels:  robotics
Reward Learning Rl
[RSS 2019] End-to-End Robotic Reinforcement Learning without Reward Engineering
Stars: ✭ 310 (-16.89%)
Mutual labels:  robotics
Robotics Toolbox Python
Robotics Toolbox for Python
Stars: ✭ 369 (-1.07%)
Mutual labels:  robotics
Orb slam 2 ros
A ROS implementation of ORB_SLAM2
Stars: ✭ 294 (-21.18%)
Mutual labels:  robotics
Matlabrobotics
MATLAB sample codes for mobile robot navigation
Stars: ✭ 332 (-10.99%)
Mutual labels:  robotics
Ifopt
An Eigen-based, light-weight C++ Interface to Nonlinear Programming Solvers (Ipopt, Snopt)
Stars: ✭ 372 (-0.27%)
Mutual labels:  robotics
Hexapod
Blazing fast hexapod robot simulator for the web.
Stars: ✭ 370 (-0.8%)
Mutual labels:  robotics
Awesome Self Supervised Learning
A curated list of awesome self-supervised methods
Stars: ✭ 4,492 (+1104.29%)
Mutual labels:  robotics

Python library to interact with Move Hub / PoweredUp Hubs

Move Hub is central controller block of LEGO® Boost Robotics Set.

In fact, Move Hub is just a Bluetooth hardware piece, and all manipulations with it are made by commands passed through Bluetooth Low Energy (BLE) wireless protocol. One of the ways to issue these commands is to write Python program using this library.

The best way to start is to look into demo.py file, and run it (assuming you have installed library).

If you have Vernie assembled, you might run scripts from examples/vernie directory.

Demonstrational Videos

Vernie Programmed Laser Engraver Color Sorter Face Tracker Color Pin Bot BB-8 Joystick

Features

Usage

Please note that this library requires one of Bluetooth backend libraries to be installed, please read section here for details.

Install library like this:

pip install -U pylgbst

Then instantiate MoveHub object and start invoking its methods. Following is example to just print peripherals detected on Hub:

from pylgbst.hub import MoveHub

hub = MoveHub()

for device in hub.peripherals:
    print(device)

Each peripheral kind has own methods to do actions and/or get sensor data. See features list for individual doc pages.

Bluetooth Backend Prerequisites

You have following options to install as Bluetooth backend (some of them might require sudo on Linux):

  • pip install pygatt - pygatt lib, works on both Windows and Linux
  • pip install gatt - gatt lib, supports Linux, does not work on Windows
  • pip install gattlib - gattlib - supports Linux, does not work on Windows, requires sudo
  • pip install bluepy - bluepy lib, supports Linux, including Raspbian, which allows connection to the hub from the Raspberry PI
  • pip install bleak - bleak lib, supports Linux/Windows/MacOS

Running on Windows requires Bluegiga BLED112 Bluetooth Smart Dongle hardware piece, because no other hardware currently works on Windows with Python+BLE.

Please let author know if you have discovered any compatibility/preprequisite details, so we will update this section to help future users

Depending on backend type, you might need Linux sudo to be used when running Python.

Bluetooth Connection Options

There is an optional parameter for MoveHub class constructor, accepting instance of Connection object. By default, it will try to use whatever get_connection_auto() returns. You have several options to manually control that:

  • use get_connection_auto() to attempt backend auto-detection
  • use get_connection_bluegiga() - if you use BlueGiga Adapter (pygatt library prerequisite)
  • use get_connection_gatt() - if you use Gatt Backend on Linux (gatt library prerequisite)
  • use get_connection_gattool() - if you use GattTool Backend on Linux (pygatt library prerequisite)
  • use get_connection_gattlib() - if you use GattLib Backend on Linux (gattlib library prerequisite)
  • use get_connection_bluepy() - if you use Bluepy backend on Linux/Raspbian (bluepy library prerequisite)
  • use get_connection_bleak() - if you use Bleak backend (bleak library prerequisite)
  • pass instance of DebugServerConnection if you are using Debug Server (more details below).

All the functions above have optional arguments to specify adapter name and Hub name (or mac address). Please take a look at functions source code for details.

If you want to specify name for Bluetooth interface to use on local computer, you can pass that to class or function of getting a connection. Then pass connection object to MoveHub constructor. Like this:

from pylgbst.hub import MoveHub
from pylgbst import get_connection_gatt

conn = get_connection_gatt(hub_mac='AA:BB:CC:DD:EE:FF')
hub = MoveHub(conn)

Debug Server

Running debug server opens permanent BLE connection to Hub and listening on TCP port for communications. This avoids the need to re-start Hub all the time.

There is DebugServerConnection class that you can use with it, instead of BLEConnection.

Starting debug server is done like this (you may need to run it with sudo, depending on your BLE backend):

python -c "import logging; logging.basicConfig(level=logging.DEBUG); \
                import pylgbst; pylgbst.start_debug_server()"

Then push green button on MoveHub, so permanent BLE connection will be established.

Roadmap & TODO

  • validate operations with other Hub types (train, PUP etc)
  • make connections to detect hub by UUID instead of name
  • document all API methods
  • make debug server to re-establish BLE connection on loss

Links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].