Others Extensions and RGB Panel: Difference between pages

From GCtronic wiki
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
=Range and bearing=
=Overview=
<span class="plainlinks">[http://www.gctronic.com/doc/images/randb-1-small.jpg <img height=150 src="http://www.gctronic.com/doc/images/randb-1.jpg">][http://www.gctronic.com/doc/images/randb-2-small.jpg <img height=150 src="http://www.gctronic.com/doc/images/randb-2.jpg">]</span><br/>
The RGB panel is a new module designed to be suitable for the e-puck robot. It is comprised of:
The board allows situated agents to communicate locally, obtaining at the same time both the range and the bearing of the emitter without the need of any centralized control or any external reference. Therefore, the board allows the robots to have an embodied, decentralized and scalable communication system. The system relies on infrared communications with frequency modulation and is composed of two interconnected modules for data and power measurement.<br/>
* 9 RGB LEDs
* 8 infrareds
* [http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010316 PIC18F6722 microcontroller] ([http://ww1.microchip.com/downloads/en/DeviceDoc/39646c.pdf 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.<br/>
<span class="plainlinks">[http://www.gctronic.com/doc/images/RGBpanel1.png <img height=200 src="http://www.gctronic.com/doc/images/RGBpanel1.png">]</span>
<span class="plainlinks">[http://www.gctronic.com/doc/images/RGBpanel2.png <img height=200 src="http://www.gctronic.com/doc/images/RGBpanel2.png">]</span>
<span class="plainlinks">[http://www.gctronic.com/doc/images/Rgb-panel1.jpg <img height=200 src="http://www.gctronic.com/doc/images/Rgb-panel1.jpg">]</span>
<span class="plainlinks">[http://www.gctronic.com/doc/images/Rgb-panel2.jpg <img height=200 src="http://www.gctronic.com/doc/images/Rgb-panel2.jpg">]</span>


The documentation and hardware files are available in the following links:
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.
* [https://projects.gctronic.com/randb/eRandB_Ed.D_Schematics.pdf Schematics (pdf)]
* [https://projects.gctronic.com/randb/eRandB_Ed.D_Assembling.pdf Assembling (pdf)]
* [https://projects.gctronic.com/randb/eRandB_Ed.D_BillOfMaterials.xls Bill of Materials (xls)]
* [https://projects.gctronic.com/randb/eRandB_Ed.D_PCB.pdf PCB (pdf)]
* [https://projects.gctronic.com/randb/eRandB_Ed.D_HardwareSourceFiles.zip Hardware source files(zip)]
* [https://projects.gctronic.com/randb/eRandB_Ed.D_Fabrication.zip Fabrication: Gerber, pick and place, ... (zip)]
* [https://projects.gctronic.com/randb/eRandB_manual.pdf e-RandB manual (pdf)]
* [https://projects.gctronic.com/randb/eRandB_firmware.zip e-RandB firmware (zip)]
* [https://projects.gctronic.com/randb/eRandB_software.tgz e-puck software and examples (tgz)]


You can find more information about this board in the following links: [http://www.e-puck.org/index.php?option=com_content&view=article&id=35&Itemid=23 http://www.e-puck.org/index.php?option=com_content&view=article&id=35&Itemid=23].
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.<br/>
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.


The following table lists the I2C the registers map:
=Electrical schema=
The circuit diagram of the rgb panel e-puck extension is available to the community on the following link [https://projects.gctronic.com/rgb-panel/rgb-ext-electrical-schema.pdf electrical schema].
 
=Software=
==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 [http://www.gctronic.com/doc/index.php/E-Puck#Standard_firmware 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.
 
==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 ([https://projects.gctronic.com/rgb-panel/panel-firmware.zip panel-MPLAB], [https://projects.gctronic.com/rgb-panel/panel-firmware.hex panel-hex]).
 
==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 [https://www.qt.io/download Qt]. A snapshot of this demo is shown hereafter:<br/>
<span class="plainlinks">[http://www.gctronic.com/doc/images/LEDTurretDemo.png <img width=400 src="http://www.gctronic.com/doc/images/LEDTurretDemo.png">]</span>
 
[http://www.gctronic.com/doc/images/LEDsTurret1.7.zip Download RGB Panel Basic Demo (Multiplatform)], built with Qt-5.10.1.
 
==e-puck2==
To play with the e-puck2 robot and RGB extension you can run the same [https://www.gctronic.com/doc/index.php?title=RGB_Panel#Demo_-_PC_side PC side application] that is used with the e-puck1. In this case the e-puck2 robot must be programmed with the [https://www.gctronic.com/doc/index.php?title=e-puck2#Factory_firmware factory firmware] and the selector must be placed in position 3.
A Python example is also available in the following link [https://projects.gctronic.com/epuck2/set_rgb_panel.py 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, <b>both the e-puck2 and RGB panel must have the selector in the same position</b>, 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 [https://www.gctronic.com/doc/index.php?title=RGB_Panel#Registers 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 https://github.com/e-puck2/e-puck2_rgb_panel].
 
=Programming=
==Registers==
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.
<blockquote>
<blockquote>
{| border="1" cellpadding="10" cellspacing="0"
{| border="1" cellpadding="10" cellspacing="0"
!Address !!Read !!Write
!X !! RedX !! BlueX !! GreenX !! IRX
|-
|+ align="bottom" style="color:#e76700;" |''Parameter registers''
|0 || 1 if data available, 0 otherwise || -
|-
|1 || data MSB || -
|-
|2 || data LSB || -
|-
|-
|3 || bearing MSB || -
|0 || 0x00 || 0x08 || 0x10 || 0xA4
|-
|-
|4 || bearing LSB: <code>double((MSB<<8)+LSB)*0.0001</code> to get angle in degrees|| -
|1 || 0x01 || 0x09 || 0x11 || 0xA5
|-
|-
|5 || range MSB || -
|2 || 0x02 || 0x0A || 0x12 || 0xA6
|-
|-
|6 || range LSB || -
|3 || 0x03 || 0x0B || 0x13 || 0xA7
|-
|-
|7 || max peak (adc reading) MSB || -
|4 || 0x04 || 0x0C || 0x14 || 0xA8
|-
|-
|8 || max peak (adc reading) LSB || -
|5 || 0x05 || 0x0D || 0x15 || 0xA9
|-
|-
|9 || sensor that received the data (between 0..11) || -
|6 || 0x06 || 0x0E || 0x16 || 0xAA
|-
|-
|12 || - || Set transmission power (communication range): between 0 (max range) and 255 (min range)
|7 || 0x07 || 0x0F || 0x17 || 0xAB
|-
|13 || - || data LSB (prepare)
|-
|14 || - || data MSB (send <code>(MSB<<8)+LSB</code>)
|-
|16 || - || 0 store light conditions (calibration)
|-
|17 || - || 1=onboard calculation, 0=host calculation
|-
|-
|8 || 0x92 || 0x93 || 0x94 || -
|}
|}
</blockquote>
</blockquote>


==e-puck 1==
==Example==
A simple [https://projects.gctronic.com/randb/test-eRandB.zip MPLAB project] was created to let start using these modules. With the selector it's possible to choose whether the robot is an emitter (selector in position 0) or a receiver (selector in position 1). The receiver will send the information (data, bearing, distance, sensor) through Bluetooth.
 
==e-puck 2==
The e-puck2 standard firmware contains a demo example to use the range and bearing extension. When the selector is in position 4 then the robot is the receiver, when in position 5 then the robot is the transmitter. The receiver will print (you need to connect the USB cable and open the USB serial port) the data received, the bearing, the distance and the sensor id; while the transmitter will send continously <code>0xAAFF</code>.<br/>
You can download the pre-built firmware from [https://projects.gctronic.com/epuck2/e-puck2_main-processor_randb.elf e-puck2_main-processor_randb.elf]; the source code is available form the repo [https://github.com/e-puck2/e-puck2_main-processor https://github.com/e-puck2/e-puck2_main-processor].<br/>
Beware that the only communication channel available between the robot and the range and bearing extension is the I2C bus, the UART channel is not available with e-puck 2.
 
=Ground sensors=
<span class="plainlinks">[http://www.gctronic.com/doc/images/E-puck-groundsensors.jpg <img width=200 src="http://www.gctronic.com/doc/images/E-puck-groundsensors.jpg">]</span>
 
The factory firmware of both the e-puck1 and e-puck2 supports the ground sensors extension: for e-puck1 refer to the section [https://www.gctronic.com/doc/index.php?title=E-Puck#Standard_firmware Standard firmware], for e-puck2 refer to section [https://www.gctronic.com/doc/index.php?title=e-puck2#Factory_firmware Factory firmware].
 
Once the robot is programmed with its factory firmware, you can get the values from the ground sensors through Bluetooth by putting the selector in position 3 and issueing the command <code>m</code> that will return 5 values, the first 3 values are related to the ground sensors (left, center, right), the last 2 values are related to the cliff extension (if available).<br/>
For more information about the Bluetooth connection refer to section [https://www.gctronic.com/doc/index.php?title=E-Puck#Getting_started Getting started] (e-puck1) or [https://www.gctronic.com/doc/index.php?title=e-puck2_PC_side_development#Connecting_to_the_Bluetooth Connecting to the Bluetooth] (e-puck2).<br/>
For more information about the Bluetooth protocol refer to section [https://www.gctronic.com/doc/index.php?title=Advanced_sercom_protocol Advanced sercom protocol].
 
If you couple the e-puck extension for Gumstix Overo with the ground sensor refer to the section [http://www.gctronic.com/doc/index.php/Overo_Extension#Ground_sensor http://www.gctronic.com/doc/index.php/Overo_Extension#Ground_sensor] to have an example on how to read the sensor values.
 
You can find more information about the ground sensors extension module in the following link [http://www.e-puck.org/index.php?option=com_content&view=article&id=17&Itemid=18 http://www.e-puck.org/index.php?option=com_content&view=article&id=17&Itemid=18].<br/>
 
==Assembly for e-puck2==
<span class="plainlinks"><table><tr><td align="center">[1]</td><td align="center">[2]</td><td align="center">[3.1]</td><td align="center">[3.2]</td><td align="center">[3.3]</td><td align="center">[3.4]</td></tr><tr><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-1.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-1_small.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-2.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-2_small.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.1.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.1_small.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.2.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.2.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.3.jpeg <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.3_small.jpeg">][https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.4.jpeg <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.4_small.jpeg">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.5.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-3.5.png">]</td></tr><tr><td align="center">[4]</td><td align="center">[5.1]</td><td align="center">[5.2]</td><td align="center">[5.3]</td><td align="center">[5.4]</td><td align="center">[6]</td></tr><tr><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-4.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-4_small.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-5.1.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-5.1_small.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-5.2.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-5.2_small.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-5.3.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-5.3_small.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-5.4.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-5.4_small.png">]</td><td align="center">[https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-6.png <img height=200 src="https://projects.gctronic.com/epuck2/wiki_images/ground-assembly-6_small.png">]</td></tr></table></span>
# Unscrew the 3 spacers and remove the battery.
# Remove the top side from the case body gently.
# Detach the plastic camera adapter from the camera with the help of pliers; be careful to not stress the camera flex cable. Then you need to cut off the two protruding pieces (see 3.2) on the back of the plastic adapter; for this operation you can use nippers (see 3.3). Take the adapter (now is flat on the back as shown in 3.4) and insert it as before.
# Plug the ground module into its connector on the e-puck2; make the cable pass through the battery contact.
# First push the ground module within its slot in the body case, then slide in also the top side of the robot paying attention to the motors wires position: the back battery contact must remain between the body and motors wires and make sure the wires aren't stuck in the springs. Both the ground cable and camera flex cable must bend forming an "S" shape.
# Push the top all way down, then remount the spacers and plug in the battery. You're done.
 
=Cliff sensor=
The cliff module extends the capability of the groundsensor with two additional sensors placed in front of the wheels. One possible application is that the e-puck can now detect the end of a table and react accordingly. Moreover this module can be coupled with the automatic charger for the e-puck, that could let the robot autonomously charge itself when needed. The two spring contacts adapt only to the cliff module.
 
==Assembly==
<span class="plainlinks"><table><tr><td align="center">[1]</td><td align="center">[2]</td><td align="center">[3]</td><td align="center">[4.1]</td><td align="center">[4.2]</td></tr><tr><td>[http://www.gctronic.com/doc/images/cliff-mounting-1.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-1-small.jpg">]</td><td>[http://www.gctronic.com/doc/images/cliff-mounting-2.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-2-small.jpg">]</td><td>[http://www.gctronic.com/doc/images/cliff-mounting-3.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-3-small.jpg">]</td><td>[http://www.gctronic.com/doc/images/cliff-mounting-4-1.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-4-1-small.jpg">]</td><td>[http://www.gctronic.com/doc/images/cliff-mounting-4-2.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-4-2-small.jpg">]</td></tr><tr><td align="center">[5.1]</td><td align="center">[5.2]</td><td align="center">[6]</td><td align="center">[7]</td><td align="center">[8]</td></tr><tr><td>[http://www.gctronic.com/doc/images/cliff-mounting-5-1.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-5-1-small.jpg">]</td><td>[http://www.gctronic.com/doc/images/cliff-mounting-5-2.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-5-2-small.jpg">]</td><td>[http://www.gctronic.com/doc/images/cliff-mounting-6.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-6-small.jpg">]</td><td>[http://www.gctronic.com/doc/images/cliff-mounting-7.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-7-small.jpg">]</td><td>[http://www.gctronic.com/doc/images/cliff-mounting-8.jpg <img height=200 src="http://www.gctronic.com/doc/images/cliff-mounting-8-small.jpg">]</td></tr></table></span>
# Unscrew the 3 screws, unmount the e-jumper (top piece where there is the speaker) and unscrew the 3 spacers
# Remove the pcb from the case body gently
# Detach the two parts, cliff and ground pcb
# Plug the ground module into its connector on the e-puck
# Attach the cliff module to the ground module being careful to leave the battery contact in the middle
# Push the ground module within its slot in the body case, the cliff module will remain external
# Once both the modules are aligned, push them down
# The modules will remain really close to the case bottom; once the modules are fitted remount the spacers, the e-jumper and the screws
 
==Electrical schema==
The circuit diagram of the e-puck cliff extension is available to the community on the following link [https://projects.gctronic.com/cliff-sensor/CliffSensorV1.0.pdf electrical schema].


==Software==
The RGB panel can be controlled through either ASCII or binary commands. The following example illustrates the sequence of commands that must be
===e-puck firmware===
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: <br/>
Refers to the section [http://www.gctronic.com/doc/index.php/E-Puck#Standard_firmware E-Puck Standard firmware] for the firmware that need to be uploaded to the robot.
<pre>
Essentially the standard ''asercom'' demo (selector 3) released with the e-puck robot is extended in order to request and visualize 5 sensors values instead of 3 when issueing the ''m'' command; the sequence is: ground left, ground center, ground right, cliff right, cliff left. In order to enable the cliff sensors you need to ''define CLIFF_SENSORS'' in the ''asercom.c'' file in order to build the code parts related to this module.
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)]
</pre>
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.


===e-puck demos===
The binary version (a bit faster), using the ''-w'' command, of the previous sequence is:  
To demonstrate the capabilities of the cliff sensors module here is an MPLAB project [https://projects.gctronic.com/cliff-sensor/Demo-cliff-autocharge.zip Demo-cliff-autocharge.zip] that contains two demos:
<pre>
* selector 0: in this demo the robot is eventually piloted to the charger station autonomously after moving around for some time aovoiding obstacles; the demo is shown in the [http://www.gctronic.com/doc/index.php/Others_Extensions#Videos video section].<br/>
... init communication ...  
* selector 1: this is a cliff avoidance demo in which the robot is moved forward until it detects the end of the table and tries to avoid it moving back and rotating; the demo is shown in the [http://www.gctronic.com/doc/index.php/Others_Extensions#Videos video section].


===Extension firmware===
sprintf(buffer, 5, "%c%c%c%c",-‘W’, 176, 0, 128);  
The ground sensor fimrware developed at EPFL (can be downloaded at the [http://www.e-puck.org http://www.e-puck.org] site from [http://www.e-puck.org/index.php?option=com_phocadownload&view=category&id=9:ground-sensors&Itemid=38 this page]) was extended to interact with the additional two sensors. The source code can be downloaded from [https://projects.gctronic.com/cliff-sensor/pic18_floor_sensor_c18-cliff.zip cliff-firmware]; it is an MPLAB project and the MPLAB C Compiler for PIC18 MCUs is needed to build the project.<br/>
sprintf(&buffer[5], 5, "%c%c%c%c",-‘W’, 176, 8, 128);
The communication between the e-puck and the module is handled through I2C (address 0xC0) and the following registers are defined:
sprintf(&buffer[10], 5, "%c%c%c%c",-‘W’, 176, 16, 128);
* 0x00: reflected light, left IR sensor - high byte
sprintf(&buffer[15], 5, "%c%c%c%c",-‘W’, 176, 145, 1); 
* 0x01: reflected light, left IR sensor - low byte
* 0x02: reflected light, center IR sensor - high byte
* 0x03: reflected light, center IR sensor - low byte
* 0x04: reflected light, right IR sensor - high byte
* 0x05: reflected light, right IR sensor - low byte
* 0x06: ambient light, left IR sensor - high byte
* 0x07: ambient light, left IR sensor - low byte
* 0x08: ambient light, center IR sensor - high byte
* 0x09: ambient light, center IR sensor - low byte
* 0x0A: ambient light, right IR sensor - high byte
* 0x0B: ambient light, right IR sensor - low byte
* 0x0C: software revision number
* 0x0D: reflected light, right cliff sensor - high byte
* 0x0E: reflected light, right cliff sensor - low byte
* 0x0F: reflected light, left cliff sensor - high byte
* 0x10: reflected light, left cliff sensor - low byte
* 0x11: ambient light, right cliff sensor - high byte
* 0x12: ambient light, right cliff sensor - low byte
* 0x13: ambient light, left cliff sensor - high byte
* 0x14: ambient light, left cliff sensor - low byte


===e-puck2 demos===
... send buffer ...
The same demo developed for the e-puck1 that let the robot autonomously reach the charging station and charge itself is available also for the e-puck2. You can find the source code in the following repository [https://github.com/e-puck2/e-puck2_cliff_autocharge https://github.com/e-puck2/e-puck2_cliff_autocharge].
</pre>


==Images==
=Videos=
Robot equipped with the cliff sensor: <br/>
{{#ev:youtube|7S3qxfLEKTg}}
<span class="plainlinks">[http://www.gctronic.com/doc/images/Cliff+charger.jpg <img width=300 src="http://www.gctronic.com/doc/images/Cliff+charger.jpg">]</span> <br/>


The robot can be easily moved to the charging station as shown in the following figure: <br/>
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.<br/>
<span class="plainlinks">[http://www.gctronic.com/doc/images/Cliff-charging.jpg <img width=300 src="http://www.gctronic.com/doc/images/Cliff-charging.jpg">]</span> <br/>
You can download the source code of this demo in the following link [https://projects.gctronic.com/rgb-panel/epuck-demo4.zip epuck-demo-chamaleon].


The following figure shows the two additional sensors (near the wheels) mounted on the cliff module and the three frontal sensors of the ground module: <br/>
{{#ev:youtube|pJVS-9sMiVY}}
<span class="plainlinks">[http://www.gctronic.com/doc/images/Cliff-zoom.jpg <img width=300 src="http://www.gctronic.com/doc/images/Cliff-zoom.jpg">]</span> <br/>


==Videos==
Artistic pattern formation with multiple robots.
{{#ev:youtube|7iFmLBng3qg}}
{{#ev:youtube|NYOcb1QoUTM}}

Revision as of 14:11, 3 December 2021

Overview

The RGB panel is a new module designed to be suitable for the e-puck robot. It is comprised of:

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.

Electrical schema

The circuit diagram of the rgb panel e-puck extension is available to the community on the following link electrical schema.

Software

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.

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).

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.

e-puck2

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.

Programming

Registers

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 -

Example

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], 5, "%c%c%c%c",-‘W’, 176, 8, 128); 
sprintf(&buffer[10], 5, "%c%c%c%c",-‘W’, 176, 16, 128);
sprintf(&buffer[15], 5, "%c%c%c%c",-‘W’, 176, 145, 1);  

... send buffer ...

Videos

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.