Computational Xmas Tree lights!

Overview

Computational Xmas Tree

This repo contains the code for the computational illumination of a Christmas Tree!

It is based on the work by Matt Parker from @standupmaths, and his video "I wired my tree with 500 LED lights and calculated their 3D coordinates".

This version contains an original LED 3D calibration routine developed by @range-et based on Matt's explanations on the video, Grasshopper + C# scripts to generate animated light sequences developed by @garciadelcastillo, and python scripts for the Raspberry Pi to load and run them on the tree.

The main difference is that Matt's approach uses custom Python scripts with sequences ran directly on the RPi, whereas this workflow "bakes" the animations to CSV files that can then be ran from the RPi. The advantage of this approach is that the CSV sequences can be parsed on any graphics environment and displayed/simulated without needing to compile Python code. The downside is that the coordinates of the LEDs need to be known a priori before generating the CSV file (CSV files become tree-specific).

Jose Luis did a video series on ParametricCamp explaining (most of) this workflow: https://youtu.be/ma4JF6b4Dqk

Usage

Calibration

If you set a physical Christmas tree with lights, you can get an estimate of their 3D position using the following:

  1. Run imageCapture.py from a Raspberry Pi with a webcam and connected to the tree. The script will take one image per LED for angle 0: $ sudo python3 imageCapture.py
  2. Repeat this process by physically rotating the tree 45, 90, 135, 180, 225, 270 & 315 degrees, and correspondingly updating the MASTERDIR variable in the script. A sample dataset is provided.
  3. Run mapper.ipynb to process all the images and generate the coordinates of the tree. This may take some time!
  4. Run adjuster.ipynb to correct some of the outliers.

A version of the final outcome from our test tree is provided in file coords_adjusted.txt. If you don't have a tree yourself, feel free to use these as the starting point.

Questions, suggestions and PRs can be directed to @range-et!

Sequencing

Once 3D coordinates are available, the following C# Scripts can be used as inspiration to generate sequences:

  1. (optional) The Grasshopper files use a version of the tree coordinates where X and Y are normalized between -1 and 1, and Z is proportionally scaled from 0 to whatever. Additionally, the coordinates are in CSV format. Use the xmas_tree_coord_normalizer.gh script to translate between the two syntaxes.
  2. The xmas_tree_sequences_3d.gh and xmas_tree_sequences_no_3d.gh contain scripts to generate a few animated sequences, both spatially-aware (tree-specific) and not respectively.
  3. (optional) If you only want to simulate already baked sequences, use xmas_tree_simulation.gh

Execution

A few scripts, based on Matt's original code, are provided to load the CSV sequences and run them on the tree.

  1. Copy the content of the execution folder to the RPi, as well as a few of the CSV sequences.
  2. To run a sequence: $ sudo python3 run.py light-sequence.csv
  3. To run all the sequences in a folder: $ sudo python3 run-folder.py seq-folder/ 3 30. The optional number 3 indicates that each sequence will be looped 3 times before moving on to the next, and the optional 30 indicates that sequences will be blended over 30 frames.
  4. If you stop a sequence and want to turn off the tree, run $ sudo python3 flush.py
  5. If you need to fine calibrate the tree, you can turn on specific lights by ID running $ sudo python3 turnon.py 0 99 199 299 399 499.

Contributions

This repo is just a snapshot of the work we did in the Fall 2021 edition of the GSD-6338 course. Unfortunately, we do not have the resources to maintain, manage or extend it beyond what is available. If you want to ask questions, discuss standards, contribute new code, features and add new sexy goodness, please refer to Matt's repo or start your own fork. Crediting is always welcome, thank you!

Credits

Thanks to the superstar roster of TAs Indrajeet, Amelia and Jessica for putting together the tree and writing the foundational calibration code.

Big 💯 to all the students who gave it a try to write sequences for the tree!

Project led by Jose Luis Garcia del Castillo y Lopez as part of our work at GSD-6338: Introduction to Computational Design at the Harvard University Graduate School of Design.

Original idea by Matt Parker from @standupmaths.

Comments
  • Use RGB color ordering

    Use RGB color ordering

    The LEDs never were taking the values in GRB order. However, the library thought they were (because of a tricky default), so it was changing the order before sending it to the LEDs, which made it look like you had to set the colors in GRB order. You never have to if you initialize the library with the correct color ordering.

    This initializes the library with the right color order setting, and removes the work-around.

    opened by JasperHorn 3
  • Live trees with WASM

    Live trees with WASM

    You can't currently watch a livestream on this christmas tree, but I think you could allow people to use WASM binaries that use imports of HTTPS Requests (and import a request executor, and have support for websockets), and then timing functions (like requestAnimationFrame, and some utility functions/datas (setLight(s), lightPositions) to then compute on-the-fly while not needing to worry about dependencies (because they can all be compiled in). This could also let you program a 3D Clock, event countdown, etc! And because it's WASM, it'll work on any tree!

    (And also, for security reasons, display to the tree-owner the urls the script needs to access)

    opened by AlexBigCheese 0
  • Player

    Player

    I made a player for the CSV files: image

    https://github.com/Diggsey/xmas_tree

    You just need Rust.

    cargo run --bin xmas_tree_player --release -- sequences/barber_pole.csv
    
    opened by Diggsey 10
  • 2 scans and done method

    2 scans and done method

    Were I to scan a tree, I would do one front facing as normal and a second from above looking down the axis to capture the radius and angle of each light, from which the remaining 2 dimensions are obtained in one stroke, so all one needs from the first scan is the height. Faster scanning, more accurate estimates and surely, faster compiling, will be the result. A routine to compile the location estimates based on this type of data structure would be needed (I am not a programmer and new to GitHub) Richard

    opened by feralmathematician 3
  • Rewritten the python runners to be more robust and add FRAME_TIME column

    Rewritten the python runners to be more robust and add FRAME_TIME column

    This rewrites the python run.py and run-folder.py quite dramatically.

    Previously the CSV parsing code assumed that the columns were positional which meant adding more columns was impossible and would break if the colums were not in the "correct" order. This version reads the headers to find where they are. It will also populate any missing column with default values.

    It also adds an optional FRAME_TIME column so that the user can specify how long each frame should remain for. If this is not defined it will run the frames as fast as the hardware will run them.

    Fixes #2

    opened by gentlegiantJGC 33
Owner
GSD6338
Projects from the course GSD-6338: Introduction to Computational Design, at the Harvard Graduate School of Design
GSD6338
This app finds duplicate to near duplicate images by generating a hash value for each image stored with a specialized data structure called VP-Tree which makes searching an image on a dataset of 100Ks almost instantanious

Offline Reverse Image Search Overview This app finds duplicate to near duplicate images by generating a hash value for each image stored with a specia

null 53 Nov 15, 2022
Xmas-Tree-GIF-Tool - Convert any given animated gif file into an animation in GIFT CSV format

This repo is made to participate in Matt Parker's XmasTree 2021 event. Convert a

Aven Zitzelberger 2 Dec 30, 2021
Build Xmas cards with user inputs

Automatically build Xmas cards with user inputs

Anand 9 Jan 25, 2022
Christmas face app for Decathlon xmas coding party!

Christmas Face Application Use this library to create the perfect picture for your christmas cards! Done by Hasib Zunair, Guillaume Brassard and Samue

Hasib Zunair 4 Dec 20, 2021
Use your Philips Hue lights as Racing Flags. Works with Assetto Corsa, Assetto Corsa Competizione and iRacing.

phue-racing-flags Use your Philips Hue lights as Racing Flags. Explore the docs » Report Bug · Request Feature Table of Contents About The Project Bui

null 50 Sep 3, 2022
Custom component to calculate estimated power consumption of lights and other appliances

Custom component to calculate estimated power consumption of lights and other appliances. Provides easy configuration to get virtual power consumption sensors in Home Assistant for all your devices which don't have a build in power meter.

Bram Gerritsen 552 Dec 28, 2022
A hand tracking demo made with mediapipe where you can control lights with pinching your fingers and moving your hand up/down.

HandTrackingBrightnessControl A hand tracking demo made with mediapipe where you can control lights with pinching your fingers and moving your hand up

Teemu Laurila 19 Feb 12, 2022
An OSINT tool that searches for devices directly connected to the internet (IoT) with a user specified query. It returns results for Webcams, Traffic lights, Refridgerators, Smart TVs etc.

An OSINT tool that searches for devices directly connected to the internet (IoT) with a user specified query. It returns results for Webcams, Traffic

Richard Mwewa 48 Nov 20, 2022
Addon to give a keybind to automatically enable contact shadows on all lights in a scene

3-2-1 Contact(Shadow) An easy way to let you enable contact shadows on all your lights, because Blender doesn't enable it by default, and doesn't give

TDV Alinsa 3 Feb 2, 2022
A simple Python script for toggling Philips Hue Lights by clapping

LightsClap A simple Python script for toggling Philips Hue Lights by clapping Usage pip3 install -r requirements.txt python3 main.py and press the Ent

Flux Industries 2 Nov 16, 2021
An open source bias lighting program which syncs up colored lights to the contents of your screen.

About Firelight Firelight is an open source bias lighting program which syncs up colored lights to the contents of your screen or TV, providing an imm

Roshan 18 Dec 18, 2022
Python api wrapper for JellyFish Lights

Python api wrapper for JellyFish Lights The hope is to make this a pip installable package Current capabalilities: Connects to a local JellyFish Light

null 10 Dec 18, 2022
Unsupervised text tokenizer focused on computational efficiency

YouTokenToMe YouTokenToMe is an unsupervised text tokenizer focused on computational efficiency. It currently implements fast Byte Pair Encoding (BPE)

VK.com 847 Dec 19, 2022
Unsupervised text tokenizer focused on computational efficiency

YouTokenToMe YouTokenToMe is an unsupervised text tokenizer focused on computational efficiency. It currently implements fast Byte Pair Encoding (BPE)

VK.com 718 Feb 18, 2021
ReproZip is a tool that simplifies the process of creating reproducible experiments from command-line executions, a frequently-used common denominator in computational science.

ReproZip ReproZip is a tool aimed at simplifying the process of creating reproducible experiments from command-line executions, a frequently-used comm

null 267 Jan 1, 2023
House-GAN++: Generative Adversarial Layout Refinement Network towards Intelligent Computational Agent for Professional Architects

House-GAN++ Code and instructions for our paper: House-GAN++: Generative Adversarial Layout Refinement Network towards Intelligent Computational Agent

null 122 Dec 28, 2022
null 131 Jun 25, 2021
null 189 Jan 2, 2023
null 190 Jan 3, 2023
Natural language computational chemistry command line interface.

nlcc Install pip install nlcc Must have Open-AI Codex key: export OPENAI_API_KEY=<your key here> then nlcc key bindings ctrl-w copy to clipboard (Note

Andrew White 37 Dec 14, 2022