Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Expand howto-control-rpi-poweredup.md #177

Merged
merged 16 commits into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions code/pybricks-test01/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pybricks.parameters import Color, Port
from pybricks.pupdevices import ColorDistanceSensor, Motor
from pybricks.tools import wait

# Say hello :)
print("Hello, Pybricks!")

motor = Motor(Port.A)
# dial = Motor(Port.A)
sensor = ColorDistanceSensor(Port.B)
# Sensor light will be set to Color.GREEN when measuring distance
sensor.light.off()

# First, we'll move the dial to zero.
# dial.run_target(500, 0, Stop.COAST)

while True:
# Set the speed based on sensor distance
dist = sensor.distance()
sensor.light.on(Color.RED)
speed = dist * 5
if abs(speed) < 100:
speed = 0
print("dist=", dist, ", speed=", speed)
# speed = dial.angle() * 3

# Run motor at desired speed
motor.run(speed)

# Wait briefly, then repeat
wait(100)

# EOF
1 change: 1 addition & 0 deletions code/pybricks-test01/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pybricks
18 changes: 17 additions & 1 deletion docs/bibliography.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* [Powered Up - A tear down...](https://www.eurobricks.com/forum/index.php?/forums/topic/162288-powered-up-a-tear-down/) - Eurobricks Forum, 2018-06-07
* Reverse Engineering the LEGO BOOST Move Hub: <https://github.com/JorgePe/BOOSTreveng>
* Python for LEGO BOOST: <https://github.com/JorgePe/pyb00st>
* [Build and Code Creative Robots with LEGO BOOST](https://www.packtpub.com/product/build-and-code-creative-robots-with-lego-boost/9781801075572) by Ashwin Shah. Packt Publishing, November 2021
* Book: [Build and Code Creative Robots with LEGO BOOST](https://www.packtpub.com/product/build-and-code-creative-robots-with-lego-boost/9781801075572) by Ashwin Shah. Packt Publishing, November 2021
* [Glossario by Italian LEGO&reg; Users Group](https://itlug.org/glossario/)
* [Smart Robotics with LEGO MINDSTORMS Robot Inventor](https://www.packtpub.com/product/smart-robotics-with-lego-mindstorms-robot-inventor/9781800568402) by Aaron Maurer. Packt Publishing, May 2021

Expand All @@ -37,6 +37,22 @@
* [LEGO Wireless Protocol 3.0.00](https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#document-index)
* [Python library to interact with Move Hub / PoweredUp Hubs](https://github.com/undera/pylgbst)

New links to check and sort out:

* Google Search: "[Powered Up Python library](https://www.google.com/search?q=Powered+Up+Python+library&oq=powered+up+Python+library)"
* Thread on StackExchange.com: [Which programming environments or APIs are available for the LEGO BOOST?](https://bricks.stackexchange.com/questions/10786/which-programming-environments-or-apis-are-available-for-the-lego-boost)
* [Hack Lego Boost with Raspberry Pi](https://magpi.raspberrypi.com/articles/hack-lego-boost-with-raspberry-pi) - The MagPi Magazine, 2019-xx-xx
* **pylgbst** - Python library to interact with Move Hub / PoweredUp Hubs
- GitHub repository: <https://github.com/undera/pylgbst>
- LibHunt: Pylgbst Alternatives: <https://www.libhunt.com/r/pylgbst>
* **BrickNil** - A Python async library for PoweredUp/Boost
- GitHub repository: <https://virantha.github.io/bricknil>
- Discussion on Eurobricks.com: <https://www.eurobricks.com/forum/index.php?/forums/topic/170945-bricknil-a-python-async-library-for-poweredupboost/>
* <https://github.com/DietrichChristopeit/project-cimino/>
* <https://magpi.raspberrypi.com/articles/hack-lego-boost-with-raspberry-pi>
* <https://www.bricklink.com/v2/catalog/catalogitem.page?P=bb0961c01#T=C>
* <https://LEGO.com/devicecheck>

## Python and Machine Learning

* [Advanced Deep Learning with Python](https://www.packtpub.com/product/advanced-deep-learning-with-python/9781789956177) by Ivan Vasilev. Packt Publishing, December 2019
Expand Down
43 changes: 41 additions & 2 deletions docs/howto/howto-control-rpi-poweredup.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,49 @@
# HOWTO Control a LEGO Powered Up Hub from a Raspberry Pi
# HOWTO Control a LEGO Powered Up Hub for the ARNEIS Project

## Introduction

This document explains how to install a use a Python script to control a LEGO Powered Up Hub through BLE.

## Step-by-step instructions
## Using the "LEGO&reg; TECHNIC&trade; CONTROL+" App

Install the "LEGO&reg; TECHNIC&trade; CONTROL+" app from

* Google Play Store: <https://play.google.com/store/apps/details?id=com.lego.technic.controlplus>
* Apple Store: TODO

Launch the app and select set "Liebherr 9800".

Connect 2x XL motor and 1x L motor to the Hub.

Follow the instructions displayed by the app and update the firmware if requested.

TODO

## Using Pybricks

### Install the Pybricks firmware

Instructions at <https://pybricks.com/install/technic-boost-city/>

Before you begin, turn the hub off. The update works best with fresh batteries.
If you use the City Hub, you must unplug all motors and sensors. Follow these steps:

1. Go to [Pybricks Code](https://code.pybricks.com/).
2. Press and hold the hub button. Wait for a blinking pink light.
3. While you hold it, click the _firmware update_ button.
4. Select the _LEGO Bootloader_ and click _Pair_.
5. Wait until the light turns off, and then blinks red/green/blue.
6. Release the button and wait for the installation to finish.

### Load some Python program

From the [Pybricks Code](https://code.pybricks.com/) web interface, create or open a MicroPython source file and upload it to the LEGO Technics BT Hub. You may find some examples under the `/code` folder of the [ARNEIS repository on GitHub](https://github.com/B-AROL-O/ARNEIS).

TODO

## Controlling from a Raspberrry Pi

### Install undera/pylgbst on the Raspberry Pi

<!-- (2022-01-27 16:45 CET) -->

Expand Down