Getting started with Arbalet

Prerequisites

In this notebook we learn how to start lightning our first pixels with Arbalet. This can be used to control the simulation, the physical table or both at a time. So even if you just want to play or are waiting for your electronic order to be delivered, follow the tutorial, you'll save time ;-)

You should have read the software prerequisites to install the Python SDK on you Linux computer first. A non-properly installed SDK will raise an ImportError exception in the first cell.

ipython notebook

If you are not familiar with ipython notebook, just remind that all the code below is executable step-by-step by pressing Alt+Enter. Follow the explanations preceeding each cell and execute it as we go along, you can also change some parameters and re-execute them! However this doesn't work if you read this online since there is no Python interpreter on our servers ;) Read software prerequisites to checkout your local ipython notebook.

Let's go

Let's start by importing a basic class...

The class Arbalet we are about to import is the main controller allowing to communicate with Arbalet hardware and software, we will use it all the time. It is located within the core submodule of the top module arbalet. The core contains the entire Arbalet SDK. Other submodules exist, tools and apps, containing respectively handy tools (server, gui, sequencer...) and the applications themselves (games and light animations).


In [ ]:
from arbalet.core import Arbalet

Now we declare an instance of the Arbalet() controller. We can specify here if we connect to a simulated or a real table, just set hardware to True if you have the real table connected, the simulation is enabled by default and must pop up.


In [ ]:
arbalet = Arbalet(hardware=False)

Within the arbalet object, there is instance of class Model representing a view to display on the table. A model is a snapshot of all pixels at a given time. Several models can overlap, so they have different names. Yours is called user_model and by default it is fully black, corresponding to all pixels off.

Let's set the color deep pink to all pixels of this model thanks the method set_all :


In [ ]:
arbalet.user_model.set_all("deeppink")

If everything went well your simulation and/or your hardware must be coloured in pink.

We can also colorize pixels individually by providing their coordinates (h, w) where h is the row between 0 and 14 and w is the column between 0 and 9. Any coordinate outside this range will likely raise an error.

Let's colorize the pixel at coordinates 0, 0 in cyan:


In [ ]:
arbalet.user_model.set_pixel(0, 0, 'cyan')

This pixel has now switched from pink to cyan. Since it's the pixel at coordinates 0, 0 it means that the origin of coordinate system is top left.

Congratulations you have displayed your first colors with Arbalet(), but before ending the program don't forget to close arbalet by executing the last cell below. This call ensures that all hardware and software resources used to run Arbalet are released properly in order not to conflict for your next program. Forgetting this call might making your table behaving odd!


In [ ]:
arbalet.close()

N.B.: Although it causes the simulator to shut down, closing does not mean that the hardware will switch off, it only means that the pixels are no longer controlled by your computer, they kept the same colour until the table is unplugged from power.

Now you can re-open the "IPython Dashboard" tab and follow the next tutorial 2. Pixels, size, and colors to learn more about playing in the pixelised and colorful world of Arbalet!