Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

Conversation

@programer19
Copy link

@programer19 programer19 commented Dec 26, 2021

I had problems with running sequences, so I decided to write code for buildin tree emulation. Just add path of a tree map file as second (optional) param (txt where each row is like "[r, b, g]" or csv where each ro is like "r,g,b") and enjoy.
example:

python3 run.py sequence.csv map.csv

Also some OOP refactoring involved for easier maintaining.

@BoostCookie
Copy link

Oh thank you so much! This is so much better than using the proprietary grasshopper program which does not even have a Linux port.

@programer19
Copy link
Author

programer19 commented Dec 26, 2021

I forgot to mention that you can also rotate the tree by pushing left mouse button and dragging left or right. Dragging up and down scales the tree

@garciadelcastillo
Copy link
Member

This sounds awesome, really cool initiative.

The contribution sounds quite deep. I suggest detaching it from the run.py command, meant to simply run a sequence on the actual tree, and make it a stand-alone visualize.py script just for simulation purposes. I would just move everything to a new folder 04_visualization with a dedicated README with dependency instructions and author credits. Once this is in, I'd be more than happy to merge the PR.

Btw, ran into this error trying to run your code:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\ProgramData\Anaconda3\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\JLX\Desktop\XmasTree-main\03_execution\ledsAdapters\VisualLedsAdapter.py", line 23, in startOpenGlThread
    glutInit()
  File "C:\ProgramData\Anaconda3\lib\site-packages\OpenGL\GLUT\special.py", line 333, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
  File "C:\ProgramData\Anaconda3\lib\site-packages\OpenGL\platform\baseplatform.py", line 425, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

@programer19
Copy link
Author

You need to install OpenGL (almost certain it is already installed), PyOpenGL PyOpenGL_accelerate with pip3. I assume this is why it doesn't work for you.

Ok, I will make one more commit to move visualization to visualize.py

@programer19
Copy link
Author

programer19 commented Dec 26, 2021

Oh! But now I have realized that visualization uses much code from 03_execution. What should I do in this case? My options are:

  1. to not move visualization.py to a different directory and leave it here
  2. copy the whole bunch of files from 03_execution to 04_visualization
  3. make a shared directory and move common files to it.

I think the option 1 is the best but it is up to you :)

@garciadelcastillo
Copy link
Member

I am fine with leaving the visualization.py file inside 03, although I don't see it using the other files as dependencies?

I still get the same error with this update: #3 (comment). Fyi, I cannot find a OpenGL module:

$ pip3 install opengl
ERROR: Could not find a version that satisfies the requirement opengl (from versions: none)
ERROR: No matching distribution found for opengl
WARNING: You are using pip version 20.0.2; however, version 21.3.1 is available.
You should consider upgrading via the 'c:\programdata\anaconda3\python.exe -m pip install --upgrade pip' command.

Lastly, this code is not working on the CSV files that contain a first ID column.

@programer19
Copy link
Author

programer19 commented Dec 27, 2021

About opengl, sorry, my fault. I meant you need to install OpenGL on your machine, not in pip. But it might be already installed, just skip it.
about visualization.py, it's done. Now I am changing the readme file and work is finished
about the error that you have mentioned earlier (missing glut functions). I have found information in the web that "glut" is not installed "by default" in windows unlike linux. And people say that putting the dll file (freeglut.dll) from this archive https://www.transmissionzero.co.uk/files/software/development/GLUT/freeglut-MSVC.zip near the py file shall help. Sadly, I haven't got any windows machine to try it myself. If you don't mind I would be very greatful if you try it for me :)
This script definitely works on linux (I have been successfuly using it for 2 days already) but it will be much better to make the script work on windows too.

@Aonodensetsu
Copy link

Aonodensetsu commented Dec 27, 2021

I made visualizer.py that relies on matplotlib so it should run basically everywhere.
It takes a python script currently as input so I'll add csv to it in a few minutes.
I included PR#4 since it automatically generates csv files too so I'll clean that up a bit.
https://github.com/Aonodensetsu/xmas-tree-visualizer

Edit: when given coordinates will work with either csv or py effects, will create a csv from a py effect, will work without coordinates only with a py script since csv is tree-specific

@programer19
Copy link
Author

"Lastly, this code is not working on the CSV files that contain a first ID column." - solved
"although I don't see it using the other files as dependencies?" - it uses the abstraction "LedsAdapter", and it also needs to have access to the animation file readers because it uses the same animation readers as run.py

@Aonodensetsu Aonodensetsu mentioned this pull request Dec 28, 2021
@programer19
Copy link
Author

programer19 commented Dec 28, 2021

I believe I found an answer to the GLUT problem on windows (at least for anaconda users).
https://anaconda.org/conda-forge/freeglut
you can install freeglut through it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants