This is a collection of python scripts that transform jpg and and svg files into into a list of coordinates. The output is normalized: coordinates range from 0 to 1, vertically and horizontally. The scripts write the result in csv file and in rtf (robot text files) files. You can upload rtf files to the classic MINDSTORMS EV3 graphic software interface.
The csv file is for use with pybricks/python scripts that can also drive the vertical plotter.
You can build your own vertical plotter with some dental floss and a single kit of LEGO MINDSTORMS EV3, using the Vertical Plotter Building Instructions.
- Instal Visual Studio Code
- Install the LEGO MINDSTORMS Extension
- Git clone this repository by opening a new vs code window and selecting 'Clone Git Repository...'
- Install required python libs. I prefer to run my generator scripts inside
pipenv shell
. On MacOS, I installed pipenv with Homebrew. But you can also just plainlypip3 install pillow
.
- Burn a microsd card with the latest ev3dev.
- Boot your MINDSTORMS brick with that card.
Open the any of the four generate_* scripts and edit the parameters, and input file names before running them.
Once you have created the coords.csv file, you can send them to the MINDSTORMS brick and plot them. The easiest way is with ev3dev.
- Create a NEW VS Code window and open the subdirectory 'pybricks_plot_csv'.
- Connect to your MINDSTORMS EV3 brick in the ev3dev device browser.
- Press F5 (Run and debug).
- The robot will beep when the script has booted.
- With the direction keys you can run the motors.
- Ensure the pen is just above the paper.
- Ensure geomtry settings in the
main.py
script are correct. - Press center button to start plotting.
The repository contains three generator scripts. They produce a csv file for use with a python plotter. The scripts can also produce x.rtf and y.rtf files for use with the classic MINDSTORMS software.
I find it the easiest to run the scripts with the run button in the top right corner in Visual Studio Code.
The CSV file has normalized coordinates. That means the numbers are between 0.0 and 1.0. When the first coordinate is -1.0, the second coordinate tells the pen to lift (0) or write (1). The python plotting script can also handle 3 long-tuples. So 0.5, 0.5, 1
would tell the plotter to move to the middle of the paper with the pen down.
Examples:
-1,0
lifts the pen
0.5, 0.5
moves to the center of the canvas.
0.5, 0.0, 1
moves to the top center of the canvas and then lowers the pen
Find dark pixels and connect them with lines.
Parses simple, single line svg files and creates a list of coordinates
Create the coordinate lists for squares and circles etc.
Script adapted from linedraw.py