The RGB panel is a new module designed to be suitable for the e-puck robot. It is comprised of:
- 9 RGB LEDs
- 8 infrareds
- PIC18F6722 microcontroller (datasheet)
Every LED is independent from each other, so it's possible to turn on the LEDs with different colors in the RGB color space (additive color mixing), as shown in the following figures.
The infrareds are thought as identification sensors, this means that the robots can be recognized by an external device such as a camera observing their combination of infrareds turned on and off; for instance using 8 IRs it's possible to identify 256 different robots.
The communication between the e-puck and the module is via the I2C bus. Color commands are sent from the robot to the RGB panel (nothing is sent in the opposite way); this let us, for example, program the robot with a pre-fixed sequence of commands to send to the panel, resulting in a color animation. Other more elaborate demos could be implemented, reacting for example to the environment and nearby robots.
Another possibility is to develop a demo running on a computer and connecting the computer to the e-puck through Bluetooth (the e-puck and the module are connected through I2C as before); in practice the robot receives commands from the PC and forwards them to the RGB panel. This forwarding is implemented in the e-puck firmware, presented afterwards.
2 Electrical schema
The circuit diagram of the rgb panel e-puck extension is available to the community on the following link electrical schema.
3.1 E-puck firmware
In order to play with the RGB extension for the e-puck robot you need to load the official e-puck firmware and set the selector on position 3 (advanced sercom protocol), refer to section E-Puck Standard firmware. Basically the firmware contains a command to setup the color of each led and the state of each infrared sensor; in particular there are two commands (binary mode): 'W' and 'w'; the first one is used to set a single led or infrared sensor, the second is used to set all actuators at once.
3.2 RGB panel firmware
Also the module requires a firmware running on it in order to handle the I2C communication and interpret the commands needed to turn on and off the sensors and color leds. The firmware can be downloaded from the following links (panel-MPLAB, panel-hex).
3.3 Demo - PC side
A basic demo running on a computer was developed to control manually all the LEDs color and IRs state through a Bluetooth connection. The application is implemented with Qt. A snapshot of this demo is shown hereafter:
Download RGB Panel Basic Demo (Multiplatform), built with Qt-5.10.1.
To play with the e-puck2 robot and RGB extension you can run the same PC side application that is used with the e-puck1. In this case the e-puck2 robot must be programmed with the factory firmware and the selector must be placed in position 3.
A Python example is also available in the following link set_rgb_panel.py in order to control the RGB panel from the computer via Bluetooth.
Beware that in order to change the selector postion, both the e-puck2 and RGB panel must have the selector in the same position, this means that if you want the position 3 selected, then both the selector of the robot and the selector of the RGB panel must be placed in position 3.
If you want to control the RGB extension directly from the e-puck2, then you can do it by using the I2C bus (see chapter Registers). An example is provided to help you getting started, have a look at the following repository https://github.com/e-puck2/e-puck2_rgb_panel.
The LEDs and IRs are controlled by writing appropriate registers; the value within the registers represents the duty cycle that a LED/IR will reach, that is its brightness. The following table shows the registers used to configure the various LEDs and IRs.
X RedX BlueX GreenX IRX Parameter registers 0 0x00 0x08 0x10 0xA4 1 0x01 0x09 0x11 0xA5 2 0x02 0x0A 0x12 0xA6 3 0x03 0x0B 0x13 0xA7 4 0x04 0x0C 0x14 0xA8 5 0x05 0x0D 0x15 0xA9 6 0x06 0x0E 0x16 0xAA 7 0x07 0x0F 0x17 0xAB 8 0x92 0x93 0x94 -
The RGB panel can be controlled through either ASCII or binary commands. The following example illustrates the sequence of commands that must be
issued to turn on the LED0 at maximum brightness (all 3 R,G and B at maximum) using a terminal and the e-puck programmed with the standard firmware:
W, 176, 0, 128 [set red led0 max] W, 176, 8, 128 [set blue led0 max ] W, 176, 16, 128 [set green led0 max] W, 176, 145, 1 [set command register (command terminator)]
where in the first line W is the command (I2C write), 176 is the I2C address of the RGB panel (fixed), 0 is the register address and 128 the brightness value. The last line contains a special command that is sent to the module when it's required to update the LEDs and IRs with the new values; this means that even if the first command is sent to the RGB panel, nothing will change until the last command is sent.
The binary version (a bit faster), using the -w command, of the previous sequence is:
... init communication ... sprintf(buffer, 5, "%c%c%c%c",-‘W’, 176, 0, 128); sprintf(&buffer, 5, "%c%c%c%c",-‘W’, 176, 8, 128); sprintf(&buffer, 5, "%c%c%c%c",-‘W’, 176, 16, 128); sprintf(&buffer, 5, "%c%c%c%c",-‘W’, 176, 145, 1); ... send buffer ...
The robot changes color basing itself on what his small camera sees, just like a real chameloen. This system is based on the standard e-puck on the bottom, the new 3x3 RGB display on top and a proper demo.
You can download the source code of this demo in the following link epuck-demo-chamaleon.
Artistic pattern formation with multiple robots.