SpiBerry banner

SpiBerry

16 devlogs
28h 19m 33s

Updated Project: A middleware to add a Raspberry Pi to your LEGO SPIKE robot. Also it has some built-in vision capabilities and a dedicated VS Code extension.

This project uses AI

Copilot for code completion, debugging and writing examples
Gemini Nano banana for logo generation
ChatGPT for research on picamera2 library

Demo Repository

Loading README...

Efe

Shipped this project!

Hours: 9.41
Cookies: 🍪 222
Multiplier: 23.56 cookies/hr

Since the day I started this project I have been trying to make it as easy to setup and use as possible. And I believe with the PyPI package and the VS Code extension I really achieved this!

Efe

RGBLED wrapper class

Added a wrapper class for RGBLED to be able to disable RGB from the config file. If you set rgb_led_enabled in GPIO section to false in the config the RGB led won’t be used

Attachment
0
Efe

PyPI package

Finally, I managed to refactor the code to be clean and DRY enough and created a python package.
Now installation is as easy as installing any python package!
Things done:

  • Refactor the virtual environment and code path handling. Everything was in a set location (~/spiberry/), now, with the config file it is much more flexible
  • The main stuff: Created pyproject.toml and added CLI commands with cli.py
  • Move service installation to be a standalone thing. You can run spiberry install-service if you are using the cli or it just asks you if you are using the old version.
  • Fixed some bugs with the config file
Attachment
0
Efe

Core engine changes

  • __main__.py was trying to import the main module from the wrong location. Fixed that.
  • Brought back set-pins cli argument (and other args necessary for it), it wasn’t reasonable to remove them in the first place pf
  • Moved the code and raspi_functions into the parent spiberry directory

Extension changes

  • Improved code upload path handling: configuration file from the raspberry pi is now used to determine the correct path

Devlog note: there are no visible changes for an image

Attachment
0
Efe

Better Configuration

For some reason, I was completely depending on cli arguments for configuration of all kinds. I realized that was not really easy to maintain. So, I migrated to using a ini config file. It lives in home directory and contains all the configuration Spiberry needs.

Attachment
0
Efe

Wrapping up

Just made the final touches in the READMEs, updated the Github release, and published a Youtube video for the demo!

Other Changes:

  • Added build-pyz.bat for easier deployment
  • Added logo to VS Code extension
Attachment
0
Efe

vsc extension update and bugfix

  • Added a service section into the sidebar (and commands)
    • Start/stop the service
    • Enable/disable the service
    • Follow the service logs (journal)
  • Fixed the utility classes insertion. For some reason the markers didn’t work when they are not at the top of the file, so I moved them there!
Attachment
Attachment
0
Efe

VS Code extension update

  • Added a sidebar
  • Created new icon for the sidebar
  • Separated the ssh logic
Attachment
0
Efe

Extension update

Add command to insert raspberry pi utility classes to cursor location
Also refactored the raspi-util-class.py a bit

1

Comments

Efe
Efe 20 days ago

Correct video for this devlog: https://tinyurl.com/52bc7jun
I accidentally uploaded one of the previous videos

Efe

Some refactoring

I used a bit of AI to refactor the function parsing logic.

  • Now JSON is used for serial com
  • Added util class for vision module, I had forgotten this previously!
    Devlog note: This is a code refactor, so there is *literally *nothing I can use for devlog image other than images of the code.
Attachment
Attachment
0
Efe

Shipped this project!

Hours: 18.91
Cookies: 🍪 343
Multiplier: 18.11 cookies/hr

I built this because I wanted to connect a Raspberry Pi to a LEGO SPIKE and there was nothing I can do that with (there is a raspberry pi hat but it doesn’t have enough ports). The most challenging part with making these updates was the computer vision part, I had to remember cv2!

Efe

VS Code extension vsc

Introduced a VS Code extension to more easily use Spiberry.

  • Easy installation
  • No need for the SPIKE IDE for intellisense any more
  • Easy code transfer to Raspberry Pi

Core Engine changes tw_gear

  • Added a starter pin (GPIO21) that needs to be grounded to start the engine. This can be bypassed with IGNORE_STARTER_PIN=1 environment variable
  • Restructure raspi_functions as a module
0
Efe

TL;DR

Added remote drive capabilities: now you can control the robot from the desktop app or via a game controller, and also get a record of the actions the robot took.

Remote Drive

  • Refactored the main code to object oriented style so it could also be used in the remote drive module.
  • Added RemoteDriveController which can run in two modes: socket (desktop app) or controller.
  • Introduced device code that enables robot control and records the actions to be run later.
  • Created a simple desktop app with tkinter that is used for the socket-based control.

WIP: Still need to compile the received “code” into actual code
Devlog note: First time video editing, apologies for the quality.

0
Efe

This devlogs mostly consists of two 11.59 PM sleep deprived coding sessions. So I don’t remember much other than fixing some issues with the vision module. This is an AI review of the last changes:

  • Added a retry mechanism that automatically extends HSV color ranges if no objects are detected.
  • Refactored color range extension logic to correctly handle multi-part ranges (e.g., red hue wrapping).
  • Enhanced detect_contours to support specific color filtering and more robust area-based filtering.
  • Added explicit error handling for unsupported picture-taking methods in the camera module.
  • Updated fallback vision configurations and improved type safety for detection filters.
Attachment
0
Efe
  • Added interactive pin configuration
  • There were a few issues with installation paths and virtual environment checks. Fixed those. It was much harder than it sounds exhausted
  • Some enhancements to the vision module
Attachment
0
Efe
  • Created a setup interface that will enable user to select which libraries they want to install. Currently it only has the libraries that are used in the vision module but many integration will come.
  • Optimized merge_close_contours function with the help of Claude
  • Added configuration options for Camera module compatible with both rpicam-apps and picamera2
  • Added examples for vision and camera modules
  • Modified the readme to include new camera capabilities
  • Made some bug fixes and improvements in ContourDetectorclass
Attachment
Attachment
Attachment
0
Efe

Vision Module

I started working on the vision module. Added,

  • Object detection
  • Contour detection (to find a single colored continuous area)
    Also fixed a few bugs (I don’t remember exactly what) and handled the installation of vision libraries
Attachment
Attachment
0
Efe

I started working on this project again. I am planning to add object detection and maybe some other cv capabilities.

Current change

Since the day I started this project I am trying to make it portable and easy to setup. I changed the project structure a bit and now I will be producing a .pyz file that will be the only thing necessary for running this project! yay

Attachment
0