Difference between pages "Pi-puck" and "e-puck2"

From GCtronic wiki
(Difference between pages)
Jump to: navigation, search
(WiFi configuration)
 
(Firmware update)
 
Line 1: Line 1:
=Overview=
+
=Hardware=
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/pipuck-overview.jpg <img width=600 src="http://projects.gctronic.com/epuck2/wiki_images/pipuck-overview-small.jpg">]</span><br/>
+
==Overview==
Features:
+
<span class="plainlinks">[http://www.gctronic.com/doc/images/e-puck2-overview.png <img width=500 src="http://www.gctronic.com/doc/images/e-puck2-overview_small.png">]</span>
* Raspberry Pi zero W (rPi) connected to the robot via I2C
+
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/e-puck2-features.png <img width=600 src="http://projects.gctronic.com/epuck2/wiki_images/e-puck2-features_small.png">]</span><br/>
* interface between the robot base camera and the rPi via USB
 
* 1 digital microphone and 1 speaker
 
* USB hub connected to the rPi with 2 free ports
 
* uUSB cable to the rPi uart port. Also ok for charging
 
* 2 chargers. 1 for the robot battery and 1 for the auxiliary battery on top of the extension
 
* charging contact points in front for automatic charging. External docking station available
 
* several extension options. 6 i2C channels, 2 ADC inputs
 
* several LED to show the status of the rPi and the power/chargers
 
  
=Getting started=
+
The following figures show the main components offered by the e-puck2 robot and where they are physically placed:<br/>
This introductory section explains the minimal procedures needed to work with the Raspberry Pi Zero W mounted on the Pi-puck extension board and gives a general overview of the available basic demos and scripts shipped with the system flashed on the micro SD. More advanced demos are described in the following separate sections (e.g. ROS), but the steps documented here are fundamental, so be sure to fully understand them. <br/>
+
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/epuck2-components-position.png <img width=800 src="http://projects.gctronic.com/epuck2/wiki_images/epuck2-components-position_small.png">]</span><br/>
  
The extension is mostly an interface between the e-puck robot and the Raspberry Pi, so you can exploit the computational power of a Linux machine to extend the robot capabilities.<br/>
+
==Specifications==
 +
The e-puck2 robot maintains full compatibility with its predecessor e-puck (e-puck HWRev 1.3 is considered in the following table):
 +
{| border="1"
 +
|'''Feature'''
 +
|'''e-puck1.3'''
 +
|'''e-puck2'''
 +
|'''Compatibility'''
 +
|'''Additional'''
 +
|-
 +
|Size, weight
 +
|70 mm diameter, 55 mm height, 150 g
 +
|Same form factor: 70 mm diameter, 45 mm, 130 g
 +
|style="text-align:center;" | <img width=40 src="http://www.gctronic.com/doc/images/ok.png">
 +
|No e-jumper required
 +
|-
 +
|Battery, autonomy
 +
|LiIPo rechargeable battery (external charger), 1800 mAh. <br/>About 3 hours autonomy. Recharging time about 2-3h.
 +
|Same battery; USB charging, recharging time about 2.5h.
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|USB charging
 +
|-
 +
|Processor
 +
|16-bit dsPIC30F6014A @ 60MHz (15 MIPS), DSP core for signal processing
 +
|32-bit STM32F407 @ 168 MHz (210 DMIPS), DSP and FPU, DMA
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|~10 times faster
 +
|-
 +
|Memory
 +
|RAM: 8 KB; Flash: 144 KB
 +
|RAM: 192 KB; Flash: 1024 KB
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|RAM: 24x more capable<br/>Flash:~7x more capable
 +
|-
 +
|Motors
 +
|2 stepper motors with a 50:1 reduction gear; 20 steps per revolution; about 0.13 mm resolution
 +
|Same motors
 +
|style="text-align:center;" | <img width=40 src="http://www.gctronic.com/doc/images/ok.png">
 +
|
 +
|-
 +
|Wheels
 +
|Wheels diamater = 41 mm <br/>Distance between wheels = 53 mm
 +
|Same wheels
 +
|style="text-align:center;" | <img width=40 src="http://www.gctronic.com/doc/images/ok.png">
 +
|
 +
|-
 +
|Speed
 +
|Max: 1000 steps/s (about 12.9 cm/s)
 +
|Max: 1200 steps/s (about 15.4 cm/s)
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|20% faster
 +
|-
 +
|Mechanical structure
 +
|Transparent plastic body supporting PCBs, battery and motors
 +
|Same mechanics
 +
|style="text-align:center;" | <img width=40 src="http://www.gctronic.com/doc/images/ok.png">
 +
|
 +
|-
 +
|Distance sensor
 +
|8 infra-red sensors measuring ambient light and proximity of objects up to 6 cm
 +
|Same infra-red sensors <br/>Front real distance sensor, Time of fight (ToF), up to 2 meter.
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|ToF sensor
 +
|-
 +
|IMU
 +
|3D accelerometer and 3D gyro
 +
|3D accelerometer, 3D gyro, 3D magnetometer
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|3D magnetometer
 +
|-
 +
|Camera
 +
|VGA color camera; typical use: 52x39 or 480x1
 +
|Same camera; typical use: 160x120
 +
|style="text-align:center;" | <img width=40 src="http://www.gctronic.com/doc/images/ok.png">
 +
|Bigger images handling
 +
|-
 +
|Audio
 +
|3 omni-directional microphones for sound localization<br/>speaker capable of playing WAV or tone sounds
 +
|4 omni-directional microhpones (digital) for sound localization<br/>speaker capable of playing WAV or tone sounds
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
| +1 front microphone
 +
|-
 +
|LEDs
 +
|8 red LEDs around the robot, green body light, 1 strong red LED in front
 +
|4 red LEDs and 4 RGB LEDs around the robot, green light, 1 strong red LED in front
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|4x RGB LEDs
 +
|-
 +
|Communication
 +
|RS232 and Bluetooth 2.0 for connection and programming
 +
|USB Full-speed, Bluetooth 2.0, BLE, WiFi
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|WiFi, BLE
 +
|-
 +
|Storage
 +
|Not available
 +
|Micro SD slot
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|Micro SD
 +
|-
 +
|Remote Control
 +
|Infra-red receiver for standard remote control commands
 +
|Same receiver
 +
|style="text-align:center;" | <img width=40 src="http://www.gctronic.com/doc/images/ok.png">
 +
|
 +
|-
 +
|Switch / selector
 +
|16 position rotating switch
 +
|Same selector
 +
|style="text-align:center;" | <img width=40 src="http://www.gctronic.com/doc/images/ok.png">
 +
|
 +
|-
 +
|Extensions
 +
|Ground sensors, range and bearing, RGB panel, Gumstix extension, omnivision, your own
 +
|All extension supported
 +
|style="text-align:center;" | <img width=40 src="http://www.gctronic.com/doc/images/ok.png">
 +
|
 +
|-
 +
|Programming
 +
|Free C compiler and IDE, Webots simulator, external debugger
 +
|Free C compiler and IDE, Webots simulator, onboard debugger (GDB)
 +
|style="text-align:center;" | <img width=30 src="http://www.gctronic.com/doc/images/plus.png">
 +
|Onboard debugger
 +
|}
 +
 
 +
This is the overall communication schema:<br/>
 +
<span class="plainlinks">[http://www.gctronic.com/doc/images/comm-overall-e-puck2E.jpg <img width=700 src="http://www.gctronic.com/doc/images/comm-overall-e-puck2E.jpg">]</span><br/>
 +
 
 +
==Documentation==
 +
* '''Main microcontroller''': STM32F407, [http://projects.gctronic.com/epuck2/doc/STM32F407xx_datasheet.pdf datasheet], [http://projects.gctronic.com/epuck2/doc/STM32F407_reference-manual.pdf reference-manual]
 +
* '''Programmer/debugger''': STM32F413, [http://projects.gctronic.com/epuck2/doc/STM32F413x_datasheet.pdf datasheet], [http://projects.gctronic.com/epuck2/doc/STM32F413_reference-manual.pdf reference-manual]
 +
* '''Radio module''': Espressif ESP32, [http://projects.gctronic.com/epuck2/doc/esp32_datasheet_en.pdf datasheet], [http://projects.gctronic.com/epuck2/doc/esp32_technical_reference_manual_en.pdf reference-manual]
 +
* '''Camera''': PixelPlus PO8030D CMOS image sensor, [http://projects.gctronic.com/E-Puck/docs/Camera/PO8030D.pdf datasheet], no IR cut filter
 +
: From about July 2019, the camera mounted on the e-puck2 robot is the Omnivision OV7670 CMOS image sensor, [http://projects.gctronic.com/epuck2/doc/OV7670.pdf datasheet]
 +
* '''Microphones''': STM-MP45DT02, [http://projects.gctronic.com/epuck2/doc/mp45dt02.pdf datasheet]
 +
* '''Optical sensors''': Vishay Semiconductors Reflective Optical Sensor, [http://projects.gctronic.com/epuck2/doc/tcrt1000.pdf datasheet]
 +
* '''ToF distance sensor''': STM-VL53L0X, [http://projects.gctronic.com/epuck2/doc/VL53L0X-Datasheet.pdf datasheet], [http://projects.gctronic.com/epuck2/doc/VL53L0X-UserManual-API.pdf user-manual]
 +
* '''IMU''': InvenSense MPU-9250, [http://projects.gctronic.com/epuck2/doc/MPU-9250-product-specification.pdf product-specification], [http://projects.gctronic.com/epuck2/doc/MPU-9250-Register-Map.pdf register-map]
 +
* '''Motors''': [http://www.e-puck.org/index.php?option=com_content&view=article&id=7&Itemid=9 details]
 +
* '''Speaker''': Diameter 13mm, power 500mW, 8 Ohm, DS-1389 or PSR12N08AK or similar
 +
* '''IR receiver''': TSOP36230
 +
 
 +
==Migrating from e-puck1.x to e-puck2==
 +
The e-puck2 robot maintains full compatibility with its predecessor e-puck, but there are some improvements that you should be aware of.<br/>
 +
 
 +
First of all the e-jumper, that is the small board that is attached on top of the e-puck1.x, isn't anymore needed in the e-puck2. The components available on the e-jumper are integrated directly in the robot board. On top of the e-puck2 you'll see a quite big free connector, this is used to attach the extensions board designed for the e-puck1.x that are fully compatible with the e-puck2; you must not connect the e-jumper in this connector.<br/>
 +
 +
Secondly you don't need anymore to unplug and plugin the battery for charging, but instead you can charge the battery (up to 1 ampere) directly by connecting the USB cable. If you want you can still charge the battery with the e-puck1.x external charger, in case you have more than one battery.<br/>
 +
 
 +
Moreover you don't need anymore a special serial cable (with probably an RS232 to USB adapter) to be able to communicate with the robot, but you can use the USB cable. Once connected to the computer a serial port will be available that you can use to easily exchange data with the robot.
 +
 
 +
==Extensions==
 +
All the extensions (ground sensors, range and bearing, RGB panel, gumstix and omnvision) are supported by the e-puck2 robot, this means that if you have some extensions for the e-puck1.x you can still use them also with e-puck2.<br/>
 +
For more information about using the gumstix extension with e-puck2 robot refer to [http://www.gctronic.com/doc/index.php?title=Overo_Extension#e-puck2 http://www.gctronic.com/doc/index.php?title=Overo_Extension#e-puck2].
 +
 
 +
=Getting Started=
 +
The e-puck2 robot features 3 chips onboard:
 +
* the main microcontroller, that is responsible for handling the sensors and actuators and which runs also the demos/algorithms
 +
* the programmer, that provides programming/debugging capabilties and moreover it configures the USB hub and is responsible for the power management (on/off of the robot and battery measure)
 +
* radio module, that is responsible for handling the wireless communication (WiFi, BLE, BT), the RGB LEDs and the user button (the RGB LEDs and button are connected to the radio module due to the pin number limitation on the main microcontroller)
 +
 
 +
The robot is shipped with the last firmware version programmed on all 3 chips, so you can immediately start using the robot.<br/>
 +
The following sections explain the basic usage of the robot, <b>all the users should read this chapter completely in order to have a minimal working system ready to play with the e-puck2 robot</b>. Some sections will have more detailed information that can be read by following the links provided.
  
In most cases, the Pi-puck extension will be attached to the robot, but it's interesting to note that it can be used also alone when the interaction with the robot isn't required.<br/>
+
When required, dedicated informations are given for all platforms (Windows, Linux, Mac). The commands given for Linux are related to the Ubuntu distribution, similar commands are available in other distributions.  
The following sections assume the full configuration (robot + extension), unless otherwise stated.
 
  
==Requirements==
+
==Turn on/off the robot==
The robot must be programmed with a special firmware in order to communicate via I2C bus with the Raspberry Pi mounted on the Pi-puck extension. The same I2C bus is shared by all the devices (camera, IMU, distance sensor, others extensions), the main microcontroller and the Raspberry Pi. Since the Raspberry Pi acts as I2C master, these devices will not be anymore reachable directly from the robot main microcontroller that will act instead as I2C slave.
+
To turn on the robot you need to press the power button (blue button) placed on the bottom side of the board, near the speaker, as shown in the following figures:
 +
::<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/e-puck2-btn-on-off2.jpg <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/e-puck2-btn-on-off2-small.jpg">][http://projects.gctronic.com/epuck2/wiki_images/e-puck2-btn-on-off.jpg <img width=300 src="http://projects.gctronic.com/epuck2/wiki_images/e-puck2-btn-on-off-small.jpg">]</span><br/>
 +
To turn off the robot you need to press the power button for 1 second.
  
===e-puck1===
+
==Meaning of the LEDs==
The e-puck1 robot must be programmed with the following firmware [https://raw.githubusercontent.com/yorkrobotlab/pi-puck/master/e-puck1/pi-puck-e-puck1.hex pi-puck-e-puck1.hex].
+
The e-puck2 has three groups of LEDs that are not controllable by the user.
  
===e-puck2===
+
::<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/e-puck2_top_leds.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/e-puck2_top_leds.png">]</span><br/>
The e-puck2 robot must be programmed with the following firmware [http://projects.gctronic.com/epuck2/gumstix/e-puck2_main-processor_extension_b346841_07.06.19.elf  e-puck2_main-processor_extension.elf (07.06.19)] and the selector must be placed in position 10.<br/>
+
::''Top view of the e-puck2''
  
==Turn on/off the extension==
+
*Charger: RED if charging, GREEN if charge complete and RED and GREEN if an error occurs
To turn on the extension you need to press the <code>auxON</code> button as shown in the follwoing figure; this will turn on also the robot (if not already turned on). Similarly, if you turn on the robot then also the extension will turn on automatically.<br/>
+
*USB: Turned ON if the e-puck2 detects a USB connection with a computer
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/pipuck_btn_on_off.jpg <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/pipuck_btn_on_off-small.jpg">]</span><br/>
+
*STATUS: Turned ON if the robot is ON and OFF if the robot is OFF. When ON, gives an indication of the level of the battery. Also blinks GREEN if the program is running during a debug session.
  
To turn off the Pi-puck you need to press and hold the <code>auxON</code> button for 2 seconds; this will initiate the power down procedure.<br>
+
Battery level indications (STATUS RGB LED):
 +
*GREEN if the system's tension is greater than 3.5V
 +
*ORANGE if the system's tension is between 3.5V and 3.4V
 +
*RED if the system's tension is between 3.4V and 3.3V
 +
*RED blinking if the system's tension is below 3.3V
  
Beware that by turning off the robot, the extension will not be turned off automatically if it is powered from another source like the micro usb cable or a secondary battery. You need to use its power off button to switch it off. Instead if there is no other power source, then by turning off the robot also the extension will be turned off (not cleanly).
+
The robot is automatically turned OFF if the system's tension gets below 3.2V during 10 seconds.
  
==Console mode==
+
==Connecting the USB cable==
The Pi-puck extension board comes with a pre-configured system ready to run without any additional configuration.<br/>
+
A micro USB cable (included with the robot in the package) is needed to connect the robot to the computer. There are two connectors, one placed on top of the robot facing upwards and the other placed on the side of the robot, as shown in the following figures. Both can be used to charge the robot (up to 1 ampere) or to communicate with it, but do not connect two cables at the same time. Connect the USB cable where is more comfortable to you.
In order to access the system from a PC in console mode, the following steps must be performed:<br/>
+
::<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/e-puck2-usb-conn.jpg <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/e-puck2-usb-conn-small.jpg">][http://projects.gctronic.com/epuck2/wiki_images/e-puck2-usb-conn2.jpg <img width=300 src="http://projects.gctronic.com/epuck2/wiki_images/e-puck2-usb-conn2-small.jpg">]</span><br/>
1. connect a micro USB cable from the PC to the extension module. If needed, the drivers are available in the following link [https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers USB to UART bridge drivers]<br/>
 
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/pipuck_usb.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/pipuck_usb-small.png">]</span><br/>
 
2. execute a terminal program and configure the connection with 115200-8N1 (no flow control). The serial device is the one created when the extension is connected to the computer<br/>
 
3. switch on the robot (the extension will turn on automatically); now the terminal should display the Raspberry Pi booting information. If the robot isn't present, then you can directly power on the extension board with the related button<br/>
 
4. login with <code>user = pi</code>, <code>password = raspberry</code><br/>
 
  
==Battery charge==
+
==Installing the USB drivers==
You can either charge the robot battery or the additional battery connected to the Pi-puck extension or both the batteries by simply plugging the micro USB cable.<br/>
+
The USB drivers must be installed only for the users of a Windows version older than Windows 10:
The following figure shows the connector for the additional battery.<br/>
 
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/pipuck_battery.jpg <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/pipuck_battery-small.jpg">]</span><br/>
 
  
The robot can also autonomously charge itself if the charging wall is available. The Pi-puck extension includes two spring contacts on the front side that let the robot easily make contact with the charging wall and charge itself. The charging wall and the spring contacts are shown in the following figures:<br/>
+
#Download and open [http://projects.gctronic.com/epuck2/zadig-2.3.exe zadig-2.3.exe]
<span class="plainlinks">[https://www.gctronic.com/img2/shop/pipuck-charger-robot.jpg <img width=250 src="https://www.gctronic.com/img2/shop/pipuck-charger-robot-small.jpg">]</span>
+
#Connect the e-puck2 with the USB cable and turn it on. Three unknown devices appear in the device list of the program, namely '''e-puck2 STM32F407''', '''e-puck2 GDB Server (Interface 0)''' and '''e-puck2 Serial Monitor (Interface 2)'''.
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/pipuck_contacts.jpg <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/pipuck_contacts-small.jpg">]</span><br/>
+
#For each of the three devices mentioned above, select the <code>USB Serial (CDC)</code> driver and click on the <code>Install Driver</code> button to install it. Accept the different prompts which may appear during the process. At the end you can simply quit the program and the drivers are installed. These steps are illustrated on Figure 3 below.
 +
::Note : The drivers installed are located in <code>C:\Users\"your_user_name"\usb_driver</code>
  
=How to communicate with the robot and its sensors=
+
:<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/Zadig_e-puck2_STM32F407.png <img width=500 src="http://projects.gctronic.com/epuck2/wiki_images/Zadig_e-puck2_STM32F407.png">]</span><br/>
==Communicate with the e-puck1==
+
::''Example of driver installation for e-puck2 STM32F407''
Refer to the repo [https://github.com/yorkrobotlab/pi-puck-e-puck1 https://github.com/yorkrobotlab/pi-puck-e-puck1].
 
  
==Communicate with the e-puck2==
+
The drivers are automatically installed with Windows 10, Linux and Mac OS.
An example showing how to exchange data between the robot and the Pi-puck extension is available in the Pi-puck repository; you can find it in the directory <code>/home/pi/Pi-puck/e-puck2/</code>.<br/>
+
 
You can build the program with the command <code>gcc e-puck2_test.c -o e-puck2_test</code>.<br/>
+
Anyway in Linux in order to access the serial ports, a little configuration is needed. Type the following command in a terminal session: <code>sudo adduser $USER dialout</code>. Once done, you need to log off to let the change take effect.
Now you can run the program by issueing <code>./e-puck2_test</code>; this demo will print the sensors data on the terminal and send some commands to the robot at 2 Hz.<br/>
+
 
===Packet format===
+
==Finding the USB serial ports used==
Extension to robot packet format, 20 bytes payload (the number in the parenthesis represents the bytes for each field):
+
Two ports are created by the e-puck2's programmer when the USB cable is connected to the robot (even if the robot is turned off):
{| border="1"
+
* '''e-puck2 GDB Server'''. The port used to program and debug the e-puck2.
| Left speed (2)  
+
* '''e-puck2 Serial Monitor'''. Serial communication between the PC and the radio module (used also to program the radio module).
| Right speed (2)
+
 
| Speaker (1)
+
A third port could be available depending on the code inside the e-puck2's microcontroller. With the factory firmware a port named '''e-puck2 STM32F407''' is created.
| LED1, LED3, LED5, LED7 (1)
+
===Windows===
| LED2 RGB (3)
+
#Open the Device Manager
| LED4 RGB (3)
+
#Under '''Ports (COM & LPT)''' you can see the virtual ports connected to your computer.
| LED6 RGB (3)
+
#Do a '''Right-click -> properties''' on the COM port you want to identify.
| LED8 RGB (3)
+
#Go under the '''details''' tab and select '''Bus reported device description''' in the properties list.
| Settings (1)
+
#The name of the port should be written in the text box below.
| Checksum (1)
+
#Once you found the desired device, you can simply look at its port number '''(COMX)'''.
|}
+
 
* Left, right speed: [-2000 ... 2000]
+
===Linux===
* Speaker id: [0, 1, 2]
+
:1. Open a terminal window (<code>ctrl+alt+t</code>) and enter the following command: <code>ls /dev/ttyACM*</code>
* LEDs on/off flag: bit0 for LED1, bit1 for LED3, bit2 for LED5, bit3 for LED7
+
:2. Look for '''ttyACM0''' and '''ttyACM1''' in the generated list, which are respectively '''e-puck2 GDB Server''' and '''e-puck2 Serial Monitor'''. '''ttyACM2''' will be also available with the factory firmware, that is related to '''e-puck2 STM32F407''' port
* RGB LEDs: [0 (off) ... 100 (max)]
+
Note : Virtual serial port numbering on Linux depends on the connections order, thus it can be different if another device using virtual serial ports is already connected to your computer before connecting the robot, but the sequence remains the same.
* Settings:
+
 
** bit0: 1=calibrate IR proximity sensors
+
===Mac===
** bit1: 0=disable onboard obstacle avoidance; 1=enable onboard obstacle avoidance (not implemented yet)
+
:1. Open a terminal window and enter the following command: <code>ls /dev/cu.usbmodem*</code>
** bit2: 0=set motors speed; 1=set motors steps (position)
+
:2. Look for two '''cu.usbmodemXXXX''', where XXXX is the number attributed by your computer. You should find two names, with a numbering near to each other, which are respectively '''e-puck2 GDB Server''' (lower number) and '''e-puck2 Serial Monitor''' (higher number). A third device '''cu.usbmodemXXXX''' will be available with the factory firmware, that is related to '''e-puck2 STM32F407''' port
* Checksum: Longitudinal Redundancy Check (XOR of the bytes 0..18)
+
 
 +
Note : Virtual serial port numbering on Mac depends on the physical USB port used and the device. If you want to keep the same names, you must connect to the same USB port each time.
 +
 
 +
==PC interface==
 +
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/monitor.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/monitor_small.png">]<br/>
 +
A PC application was developed to start playing with the robot attached to the computer via USB cable: you can have information about all the sensors, receive camera images and control the leds and motors.<br/>
 +
Beware that it's not mandatory to download this application in order to work with the robot, but it is a nice demo that gives you an overview of all the sensors and actuators available on the robot, this is a first step to gain confidence with the robot.<br/>
 +
 
 +
With the factory firmwares programmed in the robot, place the selector in position 8, attach the USB cable and turn on the robot. Enter the correct port (the one related to <code>e-puck2 STM32F407</code>) in the interface and click <code>connect</code>.
 +
 
 +
The source code is available from the repository [https://github.com/e-puck2/monitor https://github.com/e-puck2/monitor].<br/>
 +
 
 +
===Available executables===
 +
* [http://projects.gctronic.com/epuck2/monitor_win.zip Windows executable]: tested on Windows 7 and Windows 10
 +
* [http://projects.gctronic.com/epuck2/monitor_mac.zip Max OS X executable]
 +
* [http://projects.gctronic.com/epuck2/monitor_linux64bit.tar.gz Ubuntu 14.04 (or later) - 64 bit]
 +
On Linux remember to apply the configuration explained in the chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#Installing_the_USB_drivers Installing the USB drivers] in order to access the serial port.
 +
 
 +
==Installing the dependencies for firmwares updates==
 +
You can update the firmware for all 3 chips: the main microcontroller, the radio module and the programmer. For doing that, you need some tools to be installed on the system.
 +
 
 +
===Windows===
 +
To upload a new firmware in the microcontroller or in the radio module, you don't need to install anything, the packages provided include all the dependencies.
 +
 
 +
To upload a new firmware in the programmer you need to install an application called <code>DfuSe</code> released by STMicroelectronics. You can download it from [http://projects.gctronic.com/epuck2/en.stsw-stm32080_DfuSe_Demo_V3.0.5.zip DfuSe_V3.0.5.zip].
  
Robot to extension packet format, 47 bytes payload (the number in the parenthesis represents the bytes for each field):
+
===Linux===
{| border="1"
+
To upload a new firmware in the microcontroller or in the radio module, you need:
| 8 x Prox (16)
+
* Python (>= 3.4): <code>sudo apt-get install python3</code>
| 8 x Ambient (16)
+
* Python pip: <code>sudo apt-get install -y python3-pip</code>
| 4 x Mic (8)  
+
* pySerial (>= 2.5): <code>sudo pip3 install pyserial</code>
| Selector + button (1)
 
| Left steps (2)
 
| Right steps (2)
 
| TV remote (1)
 
| Checksum
 
|}
 
* Selector + button: selector values represented by 4 least significant bits (bit0, bit1, bit2, bit3); button state is in bit4 (1=pressed, 0=not pressed)
 
* Checksum: Longitudinal Redundancy Check (XOR of the bytes 0..45)
 
  
==Communicate with the IMU==
+
To upload a new firmware in the programmer you need:
===e-puck1===
+
* dfu-util: <code>sudo apt-get install dfu-util</code>
An example written in C showing how to read data from the IMU (LSM330) mounted on e-puck 1.3 is available in the Pi-puck repository; you can find it in the directory <code>/home/pi/Pi-puck/e-puck1/</code>.<br/>
 
You can build the program with the command <code>gcc e-puck1_imu.c -o e-puck1_imu</code>.<br/>
 
Now you can run the program by issueing <code>./e-puck1_imu</code> and then choose whether to get data from the accelerometer or gyroscope; this demo will print the sensors data on the terminal.<br/>
 
  
===e-puck2===
+
===Mac===
An example showing how to read data from the IMU (MPU-9250) is available in the Pi-puck repository; you can find it in the directory <code>/home/pi/Pi-puck/e-puck2/</code>.<br/>
+
Install the [https://brew.sh Homewbrew] package manager by opening a terminal and issueing:<br/>
You can build the program with the command <code>gcc e-puck2_imu.c -o e-puck2_imu</code>.<br/>
+
<code>/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"</code><br/>
Now you can run the program by issueing <code>./e-puck2_imu</code> and then choose whether to get data from the accelerometer or gyroscope; this demo will print the sensors data on the terminal.<br/>
+
and then:<br/>
 +
<code>brew upgrade</code><br/>
  
==Communicate with the ToF sensor==
+
To upload a new firmware in the microcontroller or in the radio module, you need:
The Time of Flight sensor is available only on the e-puck2 robot.<br/>
+
* Python (>= 3.4): <code>brew install python</code> (it will install also <code>pip</code>)
 +
* pySerial (>= 2.5): <code>pip3 install pyserial</code>  
  
First of all you need to verify that the VL53L0X Python package is installed with the following command: <code>python3 -c "import VL53L0X"</code>. If the command returns nothing you're ready to go, otherwise if you receive an <code>ImportError</code> then you need to install the package with the command: <code>pip3 install git+https://github.com/gctronic/VL53L0X_rasp_python</code>.<br/>
+
To upload a new firmware in the programmer you need:
 +
* dfu-util: <code>brew install dfu-util</code>
  
A Python example showing how to read data from the ToF sensor is available in the Pi-puck repository; you can find it in the directory <code>/home/pi/Pi-puck/e-puck2/</code>.<br/>
+
==PC side development==
You can run the example by issueing <code>python3 VL53L0X_example.py</code> (this is the example that you can find in the repository [https://github.com/gctronic/VL53L0X_rasp_python/tree/master/python https://github.com/gctronic/VL53L0X_rasp_python/tree/master/python]).
+
This section is dedicated to the users that develop algorithms on the PC side and interact with the robot remotely through a predefined communication protocol. These users don't modify the firmware of the robot, but instead they use the factory firmware released with the robot. They update the robot firmware only when there is an official update. <br/>
 +
The remote control of the robot, by receiving sensors values and setting the actuators, is done through the following channels: Bluetooth, Bluetooth Low Energy, WiFi, USB cable.<br/>
 +
Examples of tools/environment used by these users:
 +
# Aseba
 +
# Simulator (e.g. Webots)
 +
# ROS
 +
# iOS, Android apps
 +
# Custom PC application
 +
# IoT (e.g. IFTTT)
 +
If you fall into this category, then follow this section for more information: [http://www.gctronic.com/doc/index.php?title=e-puck2_PC_side_development PC side development].<br/>
  
==Capture an image==
+
=Main microcontroller=
The robot camera is connected to the Pi-puck extension as a USB camera, so you can access it very easily.<br/>
+
The e-puck2 robot main microcontroller is a 32-bit STM32F407 that runs at 168 MHz (210 DMIPS) and include DSP, FPU and DMA capabilities. The version chosen for the e-puck2 has 192 KB of total RAM and 1024 KB of flash, so there is a lot of memory to work with.<br/>
An example showing how to capture an image from the robot's camera using OpenCV is available in the Pi-puck repository; you can find it in the directory <code>/home/pi/Pi-puck/snapshot/</code>.<br/>
+
This chip is responsible for handling the sensors and actuators and runs also the demos and algorithms.
You can build the program with the command <code>g++ $(pkg-config --libs --cflags opencv) -ljpeg -o snapshot snapshot.cpp</code>.<br/>
 
Now you can run the program by issueing <code>./snapshot</code>; this will save a VGA image (JPEG) named <code>image01.jpg</code> to disk.<br/>
 
The program can accept the following parameters:<br/>
 
<code>-d DEVICE_ID</code> to specify the input video device from which to capture an image, by default is <code>0</code> (<code>/dev/video0</code>). This is useful when working also with the [http://www.gctronic.com/doc/index.php?title=Omnivision_Module_V3 Omnivision V3] extension that crates another video device; in this case you need to specify <code>-d 1</code> to capture from the robot camera.<br/>
 
<code>-n NUM</code> to specify how many images to capture (1-99), by default is 1<br/>
 
<code>-v</code> to enable verbose mode (print some debug information)<br/>
 
Beware that in this demo the acquisition rate is fixed to 5 Hz, but the camera supports up to 15 FPS.
 
  
==Communicate with the ground sensors extension==
+
==Factory firmware==
Both e-puck1 and e-puck2 support the [https://www.gctronic.com/doc/index.php?title=Others_Extensions#Ground_sensors ground sensors extension].<br/>
+
The main microcontroller of the robot is initially programmed with a firmware that includes many demos that could be started based on the selector position, here is a list of the demos with related position and a small description:
This extension is attached to the I2C bus and can be read directly from the Pi-puck.<br/>
+
* Selector position 0: Aseba
An example written in C showing how to read data from the ground sensors extension is available in the Pi-puck repository; you can find it in the directory <code>/home/pi/Pi-puck/ground-sensor/</code>.<br/>
+
* Selector position 1: Shell
You can build the program with the command <code>gcc groundsensor.c -o groundsensor</code>.<br/>
+
* Selector position 2: Read proximity sensors and when an object is near a proximity, turn on the corresponding LED
Now you can run the program by issueing <code>./groundsensor</code>; this demo will print the sensors data on the terminal.<br/>
+
* Selector position 3: Asercom protocol v2 (BT)
 +
* Selector positoin 4: Range and bearing extension (receiver)
 +
* Selector position 5: Range and bearing extension (transmitter)
 +
* Selector position 6: Move the robot back and forth exploiting the gyro, with LEDs animation
 +
* Selector position 7: Play a wav (mono, 16 KHz) named "example.wav" from the micro sd when pressing the button
 +
* Selector position 8: Asercom protocol v2 (USB)
 +
* Selector position 9: Local communication: transceiver
 +
* Selector position 10: this position is used to work with the Linux extensions. To work with gumstix refer to [http://www.gctronic.com/doc/index.php?title=Overo_Extension#e-puck2 Overo Extension: e-puck2] , to work with Pi-puck refer to [http://www.gctronic.com/doc/index.php?title=Pi-puck#Requirements Pi-puck: Requirements ].
 +
* Selector position 11: Simple obstacle avoidance + some animation
 +
* Selector position 12: Hardware test
 +
* Selector position 13: LEDs reflect orientation of the robot
 +
* Selector position 14: Compass
 +
* Selector position 15: WiFi mode
 +
The pre-built firmware is available here [http://projects.gctronic.com/epuck2/e-puck2_main-processor_16.04.20_a83c0a1.elf main microcontroller factory firmware (16.04.20)].
  
=How to work with the Pi-puck=
+
==Firmware update==
==Demos and scripts update==
+
Now and then there could be an official firmware update for the robot and it's important to keep the robot updated with the last firmware to get possibile new features, improvements and for bug fixes.<br/>
First of all you should update to the last version of the demos and scripts released with the system that you can use to start playing with the Pi-puck extension and the robot.<br/>
+
The onboard programmer run a GDB server, so we use GDB commands to upload a new firmware, for this reason a toolchain is needed to upload a new firmware to the robot.<br/>  
To update the repository follow these steps:<br/>
+
The following steps explain how to update the main microcontroller firmware:<br/>
1. go to the directory <code>/home/pi/Pi-puck</code><br/>
+
1. Download the package containing the required toolchain and script to program the robot: [http://projects.gctronic.com/epuck2/e-puck2-prog-main-micro-windows.zip Windows], Linux [http://projects.gctronic.com/epuck2/e-puck2-prog-main-linux32.tar.gz 32 bits]/[http://projects.gctronic.com/epuck2/e-puck2-prog-main-linux64.tar.gz 64 bits], [http://projects.gctronic.com/epuck2/e-puck2-prog-main-micro-macos.zip Mac OS]<br/>
2. issue the command <code>git pull</code><br/>
+
2. Download the last version of the [http://projects.gctronic.com/epuck2/e-puck2_main-processor_16.04.20_a83c0a1.elf main microcontroller factory firmware (16.04.20)], or use your custom firmware<br/>
Then to update some configurations of the system:<br/>
+
3. Extract the package and put the firmware file (with <code>elf</code> extension) inside the package directory; beware that only one <code>elf</code> file must be present inside this directory<br/>
1. go to the directory <code>/home/pi/Pi-puck/system</code><br/>
+
4. Attach the USB cable and turn on the robot<br/>
2. issue the command <code>./update.sh</code>; the system will reboot.<br/>
+
5. Run the script from the package directory:<br/>
You can find the Pi-puck repository here [https://github.com/gctronic/Pi-puck https://github.com/gctronic/Pi-puck].<br/>
+
:Windows: double click <code>program.bat</code><br/>
 +
:Linux/Mac: issue the following command in a terminal <code>./program.sh</code>. If you get permission errors, then issue <code>sudo chmod +x program.sh</code> to let the script be executable.<br/>
  
==Audio recording==
+
When the upload is complete you'll see an output like in the following figure:<br/>
Use the <code>arecord</code> utility to record audio from the onboard microphone. The following example shows how to record an audio of 2 seconds (<code>-d</code> parameter) and save it to a wav file (<code>test.wav</code>):<br/>
+
<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/f407-flashing.png <img width=400 src="http://projects.gctronic.com/epuck2/wiki_images/f407-flashing.png">]</span><br/>
<code>arecord -Dmic_mono -c1 -r16000 -fS32_LE -twav -d2 test.wav</code><br/>
+
The final lines should contain the entry <code>".data",</code>, this means that the upload was successfull. You can then close the terminal window if it is still open.
You can also specify a rate of 48 KHz with <code>-r48000</code>
 
  
==Audio play==
+
If you encounter some problem, try to unplug and plug again the USB cable and power cycle the robot, then retry.
Use <code>aplay</code> to play <code>wav</code> files and <code>mplayer</code> to play <code>mp3</code> files.
 
  
==Battery reading==
+
==Robot side development==
An example showing how to measure both the battery of the robot and the battery of the Pi-puck extension is available in the Pi-puck repository; you can find it in the directory <code>/home/pi/Pi-puck/battery/</code>.<br/>
+
If you are an embedded developer and are brave enough, then you have complete access to the source code running on the robot, so you can discover what happen inside the main microcontroller and modify it to accomodate your needs. Normally the users that fall into this category develop algorithms optimized to run directly on the microcontroller, such as:
The first time you need to change the mode of the script in order to be executable with the command <code>sudo chmod +x read-battery.sh</code>.<br/>
+
# onboard image processing
Then you can start reading the batteries value by issueing <code>./read-battery.sh</code>.; this demo will print the batteries values (given in Volts) on the terminal.
+
# swarm algorithms
 +
# fully autonomous behaviors
 +
# ...
 +
For more information about programming the robot itself, refer to section [http://www.gctronic.com/doc/index.php?title=e-puck2_robot_side_development Robot side development]
  
==WiFi configuration==
+
=Radio module=
Specify your network configuration in the file <code>/etc/wpa_supplicant/wpa_supplicant-wlan0.conf</code>.<br/>
+
The radio module chosen for the e-puck is the new ESP32 chip from [https://www.espressif.com/ Espressif], integrating a dual core that run up to 240 MHz, 4 MB of flash and 520 KB of RAM. It supports WiFi standards 802.11 b/g/n (access point mode supported), Bluetooth and Bluetooth LE 4.2. It is the successor of the ESP8266 chip. The following figure shows the various peripherals available on the ESP32:<br/>
Example:<br/>
+
<span class="plain links"><img width=400 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-peripherals.png"></span>
<pre>
 
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 
update_config=1
 
country=CH
 
network={
 
        ssid="MySSID"
 
        psk="9h74as3xWfjd"
 
}
 
</pre>
 
You can have more than one <code>network</code> parameter to support more networks.<br/>
 
Once the configuration is done, you can also connect to the Pi-puck with <code>SSH</code>.
 
  
===How to know your IP address===
+
This chip first of all is responsible for handling the wireless communication, moreover it handles also the RGB LEDs (with PWM) and the user button. The RGB LEDs and button are connected to the radio module due to the pin number limitation on the main microcontroller.
  
==File transfer==
+
==Factory firmware==
===USB cable===
+
The radio module of the robot is initially programmed with a firmware that supports Bluetooth communication.<br/>
You can transfer files via USB cable between the computer and the Pi-puck extension by using on of the <code>zmodem</code> protocol.<br/>
+
The pre-built firmware is available here [http://projects.gctronic.com/epuck2/esp32-firmware_11.12.18.zip radio module factory firmware (11.12.18)].
The <code>lrzsz</code> package is pre-installed in the system, thus you can use the <code>sx</code> and <code>rx</code> utilities to respectevely send files to the computer and receive files from the computer.<br/>
 
Example of sending a file to the computer using the <code>Minicom</code> terminal program:<br/>
 
1. in the Pi-puck console type <code>sx --zmodem fliename.ext</code>. The transfer should start automatically and you'll find the file in the home directory.<br/>
 
<!--2. to start the transfer type the sequence <code>CTRL+A+R</code>, then chose <code>xmodem</code> and finally enter the name you want to assign to the received file. You'll find the file in the home directory.<br/>-->
 
Example of receiving a file from the computer using the <code>Minicom</code> terminal program:<br/>
 
1. in the Pi-puck console type <code>rx -Z</code><br/>
 
2. to start the transfer type the sequence <code>CTRL+A+S</code>, then chose <code>zmodem</code> and select the file you want to send with the <code>spacebar</code>. Finally press <code>enter</code> to start the transfer.<br/>
 
===WiFi===
 
The Pi-puck extension supports <code>SSH</code> connections.<br/>
 
To exchange files between the Pi-puck and the computer, the <code>scp</code> tool (secure copy) can be used. An example of transferring a file from the Pi-puck to the computer is the following:<br/>
 
<code>scp pi@192.168.1.20:/home/pi/example.txt example.txt</code>
 
  
If you are working in Windows you can use [https://www.putty.org/ PuTTY].
+
==WiFi firmware==
 +
At the moment the factory firmware supports only Bluetooth, if you want to work with WiFi you need to program the radio with a dedicated firmware, refer to section [http://www.gctronic.com/doc/index.php?title=e-puck2_PC_side_development#WiFi PC side development: WiFi].
  
==Image streaming==
+
==BLE firmware==
 +
At the moment the factory firmware supports only calssic Bluetooth, if you want to work with Bluetooth Low Energy you need to program the radio with a dedicated firmware, refer to section [http://www.gctronic.com/doc/index.php?title=e-puck2_mobile_phone_development Mobile phone development].
  
 +
==Firmware update==
 +
In order to update the firmware of the ESP32 WiFi module you need to use a python script called <code>esptool</code> provided by [https://www.espressif.com/ Espressif] (manufacturer of the chip). This script was modified to work with the e-puck2 robot and is included in the provided package. The following steps explain how to update the radio module firmware:<br/>
 +
1. Download the package containing the required tools and script to program the robot: [http://projects.gctronic.com/epuck2/e-puck2-prog-radio-windows.zip Windows], [http://projects.gctronic.com/epuck2/e-puck2-prog-radio-macos.zip Linux / Mac]<br/>
 +
2. Download the last version of the [http://projects.gctronic.com/epuck2/esp32-firmware_11.12.18.zip radio module factory firmware (11.12.18)], or use another firmware (e.g. WiFi, BLE, your own). The firmware is composed by 3 files named <code>bootloader.bin</code>, <code>ESP32_E-Puck_2.bin</code> and <code>partitions_singleapp.bin</code><br/>
 +
3. Extract the package and put the firmware files inside the package directory; beware that the name of the <code>.bin</code> files must be the same as indicated in step 2<br/>
 +
4. Attach the USB cable and turn on the robot<br/>
 +
5. Run the script from the package directory:<br/>
 +
:Windows: double click <code>program.bat</code><br/>
 +
:Linux/Mac: issue the following command in a terminal <code>./program.sh</code>. If you get permission errors, then issue <code>sudo chmod +x program.sh</code> to let the script be executable.<br/>
  
==Bluetooth LE==
+
The upload should last about 10-15 seconds and you'll see the progress as shown in the following figure:<br/>
An example of a ''BLE uart service'' is available in the Pi-puck repository; you can find it in the directory <code>/home/pi/Pi-puck/ble/</code>.<br/>
+
<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/esp32-flashing1.png <img width=400 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-flashing1.png">]</span><br/>
To start the service you need to type: <code>python uart_peripheral.py</code>.<br/>
+
When the upload is complete you'll see that all 3 bin files are uploaded correctly as shown in the following figure:<br/>
Then you can use the ''e-puck2-android-ble app'' you can find in chapter [https://www.gctronic.com/doc/index.php?title=e-puck2_mobile_phone_development#Connecting_to_the_BLE Connecting to the BLE] in order to connect to the Pi-puck extension via BLE. Once connected you'll receive some dummy data for the proximity values and by clicking on the motion buttons you'll see the related action printed on the Pi-puck side. This is a starting point that you can extend based on your needs.
+
<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/esp32-flashing2.png <img width=400 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-flashing2.png">]</span><br/>
  
=Operating system=
+
Sometime you could encounter a timeout error as shown in the following figures; in these cases you need to unplug and plug again the USB cable and power cycle the robot, then you can retry.<br/>
The system is based on Raspbian Stretch and can be downloaded from the following link [http://projects.gctronic.com/epuck2/PiPuck/gctronic-stretch-ros-kinetic-opencv3.4.1_15.03.19.img.tar.gz gctronic-stretch-ros-kinetic-opencv3.4.1.img.tar.gz].
+
<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/esp32-flashing3.png <img width=400 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-flashing3.png">]</span>
 +
<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/esp32-flashing4.png <img width=400 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-flashing4.png">]</span><br/>
  
When booting the first time, the first thing to do is expanding the file system in order to use all the available space on the micro sd:<br/>
+
==Development==
1. <code>sudo raspi-config</code><br/>
+
Probably, you'll never need to touch the firmware running in the radio module, but in case you need to modify the code or you're simply curious about what is happening at the low level, then refer to the section [http://www.gctronic.com/doc/index.php?title=e-puck2_radio_module_development Radio module development].
2. Select <code>Advanced Options</code> and then <code>Expand Filesystem</code><br/>
 
3. reboot
 
  
==Desktop mode==
+
=Programmer=
The system starts in console mode, to switch to desktop (LXDE) mode issue the command <code>startx</code>.
+
The e-puck2 robot is equipped with an onboard programmer and debugger that let you update the firmware of the robot and debug your code easily using a standard USB interface. There is a dedicated STM32F413 microcontroller that acts as the programmer with built in GDB server, so you can control exactly what happens using the [https://www.gnu.org/software/gdb/ GNU Project Debugger] in your host machine.<br/>
===Camera viewer===
+
The programmer microcontroller is also in charge of handling various low level features such as the configuration of the USB hub and the power button.
  
==I2C communication==
+
==Factory firmware==
The communication between the Pi-puck extension and the robot is based on I2C. The system is configured to exploit the I2C hardware peripheral in order to save CPU usage, but if you need to use the software I2C you can enable it by modifying the <code>/boot/config.txt</code> file and removing the <code>#</code> symbol (comment) in front of the line with the text <code>dtparam=soft_i2c</code> (it is placed towards the end of the file).
+
The programmer is initially programmed with a firmware based on a '''''modified version''''' of [https://github.com/blacksphere/blackmagic/wiki Black Magic Probe programmer/debugger].<br/>
 +
The pre-built firmware is available here [http://projects.gctronic.com/epuck2/e-puck2_programmer_28.05.20_3b600ec.bin programmer-firmware.bin (28.05.20)]; it is also available in dfu format here [http://projects.gctronic.com/epuck2/e-puck2_programmer_28.05.20_3b600ec.dfu programmer-firmware.dfu (28.05.20)].
  
=ROS=
+
==Firmware update==
ROS Kinetic is integrated in the Pi-puck system.
+
The programmer's microcontroller features a factory bootloader that can be entered by acting on some special pins, the bootloader mode is called DFU (device firmware upgrade). You can enter DFU mode by contacting two pinholes together while inserting the USB cable (no need to turn on the robot). The two pin holes are located near the USB connector of the e-puck2, see the photo below.
==Initial configuration==
 
The ROS workspace is located in <code>~/rosbots_catkin_ws/</code><br/>
 
The e-puck2 ROS driver is located in <code>~/rosbots_catkin_ws/src/epuck_driver_cpp/</code><br/>
 
Remember to follow the steps in the section [http://www.gctronic.com/doc/index.php?title=Pi-puck#Requirements Requirements ] and section [https://www.gctronic.com/doc/index.php?title=Pi-puck#Demos_and_scripts_update Demos and scripts update], only once.<br/>
 
The PC (if used) and the Pi-puck extension are supposed to be configured in the same network.
 
  
==Running roscore==
+
::<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/e-puck2_top_leds_DFU_413.png <img width=200 src="http://projects.gctronic.com/epuck2/wiki_images/e-puck2_top_leds_DFU_413.png">]</span><br/>
<code>roscore</code> can be launched either from the PC or directly from the Pi-puck.<br/>
+
::''Location of the pin holes to put the programmer into DFU''
Before starting roscore, open a terminal and issue the following commands:
 
* <code>export ROS_IP=roscore-ip</code>
 
* <code>export ROS_MASTER_URI=http://roscore-ip:11311</code>
 
where <code>roscore-ip</code> is the IP of the machine that runs <code>roscore</code><br/>
 
Then start <code>roscore</code> by issueing <code>roscore</code>.
 
  
==Running the ROS node==
+
The programmer will be recognized as <code>STM Device in DFU Mode</code> device.
Before starting the e-puck2 ROS node on the Pi-puck, issue the following commands:
 
* <code>export ROS_IP=pipuck-ip</code>
 
* <code>export ROS_MASTER_URI=http://roscore-ip:11311</code>
 
where <code>pipuck-ip</code> is the IP of the Pi-puck extension and <code>roscore-ip</code> is the IP of the machine that runs <code>roscore</code> (can be the same IP if <code>roscore</code> runs directly on the Pi-puck).
 
  
To start the e-puck2 ROS node issue the command:<br/>
+
'''Note for Windows users''': the device should be recognized automatically (in all Windows versions), but in case it won't be detected then you need to install a <code>libusbK</code> driver for the DFU device.<br>
<code>roslaunch epuck_driver_cpp epuck_minimal.launch debug_en:=true ros_rate:=20</code><br/>
+
Follow the same procedure as explained in section [http://www.gctronic.com/doc/index.php?title=e-puck2#Installing_the_USB_drivers Installing the USB drivers] using <code>libusbK</code> driver instead of <code>USB Serial (CDC)</code>.
<!--
 
To start the e-puck2 ROS node issue the command:<br/>
 
<code>roslaunch epuck_driver_cpp epuck_controller.launch epuck_id:='3000'</code><br/>
 
This launch file will start the e-puck2 node and the camera node.
 
If you are using a PC, then you can start <code>rviz</code>:
 
* in a terminal issue the command <code>rviz rviz</code>
 
* open the configuration file named <code>single_epuck_driver_rviz.rviz</code> you can find in <code>epuck_driver_cpp/config/</code> directory
 
-->
 
  
The following graph shows all the topics published by the e-puck2 driver node:<br/>
+
===Linux/Mac===
<span class="plainlinks">[http://projects.gctronic.com/epuck2/wiki_images/ros-e-puck2_.jpg <img width=150 src="http://projects.gctronic.com/epuck2/wiki_images/ros-e-puck2_small.jpg">]</span>
+
In order to update the programmer firmware you need an utility called <code>dfu-util</code>, it should be already installed from section [http://www.gctronic.com/doc/index.php?title=e-puck2#Installing_the_dependencies_for_firmwares_updates Installing the dependencies for firmwares updates].<br/>
''<font size="2">Click to enlarge</font>''
+
To uplaod the firmware, issue the following command: <code>sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D programmer-firmware.bin</code>
  
==Get the source code==
+
===Windows===
The last version of the e-puck2 ROS node can be downloaded from the git: <code>git clone -b pi-puck https://github.com/gctronic/epuck_driver_cpp.git</code>
+
Start the <code>DfuSe</code> application (previously installed from section [http://www.gctronic.com/doc/index.php?title=e-puck2#Installing_the_dependencies_for_firmwares_updates Installing the dependencies for firmwares updates]). The programmer in DFU mode will be automatically detected as shown in figure 1. Then you need to open the compiled firmware by clicking on <code>choose</code> and then locating the file with <code>dfu</code> extension,  as shown in figure 2. Now click on the <code>upgrade</code> button, a warning message will be shown, confirm the action by clicking on <code>yes</code> as shown in figure 3. If all is ok you'll be prompted with a message saying that the upgrade was successfull as shown in figure 4.<br/>
 +
<span class="plainlinks">
 +
<table>
 +
<tr>
 +
<td align="center">[1]</td>
 +
<td align="center">[2]</td>
 +
<td align="center">[3]</td>
 +
<td align="center">[4]</td>
 +
</tr>
 +
<tr>
 +
<td>[http://projects.gctronic.com/epuck2/wiki_images/dfu1.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/dfu1.png">]</td>
 +
<td>[http://projects.gctronic.com/epuck2/wiki_images/dfu2.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/dfu2.png">]</td>
 +
<td>[http://projects.gctronic.com/epuck2/wiki_images/dfu3.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/dfu3.png">]</td>
 +
<td>[http://projects.gctronic.com/epuck2/wiki_images/dfu4.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/dfu4.png">]</td>
 +
</tr>
 +
</table>
 +
</span><br/>
  
=OpenCV=
+
==Development==
OpenCV 3.4.1 is integrated in the Pi-puck system.
+
The programmer code shouldn't be modified, but if you know what you're doing then refer to section [http://www.gctronic.com/doc/index.php?title=e-puck2_programmer_development Programmer development].

Revision as of 08:56, 12 November 2020

1 Hardware

1.1 Overview


The following figures show the main components offered by the e-puck2 robot and where they are physically placed:

1.2 Specifications

The e-puck2 robot maintains full compatibility with its predecessor e-puck (e-puck HWRev 1.3 is considered in the following table):

Feature e-puck1.3 e-puck2 Compatibility Additional
Size, weight 70 mm diameter, 55 mm height, 150 g Same form factor: 70 mm diameter, 45 mm, 130 g No e-jumper required
Battery, autonomy LiIPo rechargeable battery (external charger), 1800 mAh.
About 3 hours autonomy. Recharging time about 2-3h.
Same battery; USB charging, recharging time about 2.5h. USB charging
Processor 16-bit dsPIC30F6014A @ 60MHz (15 MIPS), DSP core for signal processing 32-bit STM32F407 @ 168 MHz (210 DMIPS), DSP and FPU, DMA ~10 times faster
Memory RAM: 8 KB; Flash: 144 KB RAM: 192 KB; Flash: 1024 KB RAM: 24x more capable
Flash:~7x more capable
Motors 2 stepper motors with a 50:1 reduction gear; 20 steps per revolution; about 0.13 mm resolution Same motors
Wheels Wheels diamater = 41 mm
Distance between wheels = 53 mm
Same wheels
Speed Max: 1000 steps/s (about 12.9 cm/s) Max: 1200 steps/s (about 15.4 cm/s) 20% faster
Mechanical structure Transparent plastic body supporting PCBs, battery and motors Same mechanics
Distance sensor 8 infra-red sensors measuring ambient light and proximity of objects up to 6 cm Same infra-red sensors
Front real distance sensor, Time of fight (ToF), up to 2 meter.
ToF sensor
IMU 3D accelerometer and 3D gyro 3D accelerometer, 3D gyro, 3D magnetometer 3D magnetometer
Camera VGA color camera; typical use: 52x39 or 480x1 Same camera; typical use: 160x120 Bigger images handling
Audio 3 omni-directional microphones for sound localization
speaker capable of playing WAV or tone sounds
4 omni-directional microhpones (digital) for sound localization
speaker capable of playing WAV or tone sounds
+1 front microphone
LEDs 8 red LEDs around the robot, green body light, 1 strong red LED in front 4 red LEDs and 4 RGB LEDs around the robot, green light, 1 strong red LED in front 4x RGB LEDs
Communication RS232 and Bluetooth 2.0 for connection and programming USB Full-speed, Bluetooth 2.0, BLE, WiFi WiFi, BLE
Storage Not available Micro SD slot Micro SD
Remote Control Infra-red receiver for standard remote control commands Same receiver
Switch / selector 16 position rotating switch Same selector
Extensions Ground sensors, range and bearing, RGB panel, Gumstix extension, omnivision, your own All extension supported
Programming Free C compiler and IDE, Webots simulator, external debugger Free C compiler and IDE, Webots simulator, onboard debugger (GDB) Onboard debugger

This is the overall communication schema:

1.3 Documentation

From about July 2019, the camera mounted on the e-puck2 robot is the Omnivision OV7670 CMOS image sensor, datasheet

1.4 Migrating from e-puck1.x to e-puck2

The e-puck2 robot maintains full compatibility with its predecessor e-puck, but there are some improvements that you should be aware of.

First of all the e-jumper, that is the small board that is attached on top of the e-puck1.x, isn't anymore needed in the e-puck2. The components available on the e-jumper are integrated directly in the robot board. On top of the e-puck2 you'll see a quite big free connector, this is used to attach the extensions board designed for the e-puck1.x that are fully compatible with the e-puck2; you must not connect the e-jumper in this connector.

Secondly you don't need anymore to unplug and plugin the battery for charging, but instead you can charge the battery (up to 1 ampere) directly by connecting the USB cable. If you want you can still charge the battery with the e-puck1.x external charger, in case you have more than one battery.

Moreover you don't need anymore a special serial cable (with probably an RS232 to USB adapter) to be able to communicate with the robot, but you can use the USB cable. Once connected to the computer a serial port will be available that you can use to easily exchange data with the robot.

1.5 Extensions

All the extensions (ground sensors, range and bearing, RGB panel, gumstix and omnvision) are supported by the e-puck2 robot, this means that if you have some extensions for the e-puck1.x you can still use them also with e-puck2.
For more information about using the gumstix extension with e-puck2 robot refer to http://www.gctronic.com/doc/index.php?title=Overo_Extension#e-puck2.

2 Getting Started

The e-puck2 robot features 3 chips onboard:

  • the main microcontroller, that is responsible for handling the sensors and actuators and which runs also the demos/algorithms
  • the programmer, that provides programming/debugging capabilties and moreover it configures the USB hub and is responsible for the power management (on/off of the robot and battery measure)
  • radio module, that is responsible for handling the wireless communication (WiFi, BLE, BT), the RGB LEDs and the user button (the RGB LEDs and button are connected to the radio module due to the pin number limitation on the main microcontroller)

The robot is shipped with the last firmware version programmed on all 3 chips, so you can immediately start using the robot.
The following sections explain the basic usage of the robot, all the users should read this chapter completely in order to have a minimal working system ready to play with the e-puck2 robot. Some sections will have more detailed information that can be read by following the links provided.

When required, dedicated informations are given for all platforms (Windows, Linux, Mac). The commands given for Linux are related to the Ubuntu distribution, similar commands are available in other distributions.

2.1 Turn on/off the robot

To turn on the robot you need to press the power button (blue button) placed on the bottom side of the board, near the speaker, as shown in the following figures:


To turn off the robot you need to press the power button for 1 second.

2.2 Meaning of the LEDs

The e-puck2 has three groups of LEDs that are not controllable by the user.


Top view of the e-puck2
  • Charger: RED if charging, GREEN if charge complete and RED and GREEN if an error occurs
  • USB: Turned ON if the e-puck2 detects a USB connection with a computer
  • STATUS: Turned ON if the robot is ON and OFF if the robot is OFF. When ON, gives an indication of the level of the battery. Also blinks GREEN if the program is running during a debug session.

Battery level indications (STATUS RGB LED):

  • GREEN if the system's tension is greater than 3.5V
  • ORANGE if the system's tension is between 3.5V and 3.4V
  • RED if the system's tension is between 3.4V and 3.3V
  • RED blinking if the system's tension is below 3.3V

The robot is automatically turned OFF if the system's tension gets below 3.2V during 10 seconds.

2.3 Connecting the USB cable

A micro USB cable (included with the robot in the package) is needed to connect the robot to the computer. There are two connectors, one placed on top of the robot facing upwards and the other placed on the side of the robot, as shown in the following figures. Both can be used to charge the robot (up to 1 ampere) or to communicate with it, but do not connect two cables at the same time. Connect the USB cable where is more comfortable to you.


2.4 Installing the USB drivers

The USB drivers must be installed only for the users of a Windows version older than Windows 10:

  1. Download and open zadig-2.3.exe
  2. Connect the e-puck2 with the USB cable and turn it on. Three unknown devices appear in the device list of the program, namely e-puck2 STM32F407, e-puck2 GDB Server (Interface 0) and e-puck2 Serial Monitor (Interface 2).
  3. For each of the three devices mentioned above, select the USB Serial (CDC) driver and click on the Install Driver button to install it. Accept the different prompts which may appear during the process. At the end you can simply quit the program and the drivers are installed. These steps are illustrated on Figure 3 below.
Note : The drivers installed are located in C:\Users\"your_user_name"\usb_driver

Example of driver installation for e-puck2 STM32F407

The drivers are automatically installed with Windows 10, Linux and Mac OS.

Anyway in Linux in order to access the serial ports, a little configuration is needed. Type the following command in a terminal session: sudo adduser $USER dialout. Once done, you need to log off to let the change take effect.

2.5 Finding the USB serial ports used

Two ports are created by the e-puck2's programmer when the USB cable is connected to the robot (even if the robot is turned off):

  • e-puck2 GDB Server. The port used to program and debug the e-puck2.
  • e-puck2 Serial Monitor. Serial communication between the PC and the radio module (used also to program the radio module).

A third port could be available depending on the code inside the e-puck2's microcontroller. With the factory firmware a port named e-puck2 STM32F407 is created.

2.5.1 Windows

  1. Open the Device Manager
  2. Under Ports (COM & LPT) you can see the virtual ports connected to your computer.
  3. Do a Right-click -> properties on the COM port you want to identify.
  4. Go under the details tab and select Bus reported device description in the properties list.
  5. The name of the port should be written in the text box below.
  6. Once you found the desired device, you can simply look at its port number (COMX).

2.5.2 Linux

1. Open a terminal window (ctrl+alt+t) and enter the following command: ls /dev/ttyACM*
2. Look for ttyACM0 and ttyACM1 in the generated list, which are respectively e-puck2 GDB Server and e-puck2 Serial Monitor. ttyACM2 will be also available with the factory firmware, that is related to e-puck2 STM32F407 port

Note : Virtual serial port numbering on Linux depends on the connections order, thus it can be different if another device using virtual serial ports is already connected to your computer before connecting the robot, but the sequence remains the same.

2.5.3 Mac

1. Open a terminal window and enter the following command: ls /dev/cu.usbmodem*
2. Look for two cu.usbmodemXXXX, where XXXX is the number attributed by your computer. You should find two names, with a numbering near to each other, which are respectively e-puck2 GDB Server (lower number) and e-puck2 Serial Monitor (higher number). A third device cu.usbmodemXXXX will be available with the factory firmware, that is related to e-puck2 STM32F407 port

Note : Virtual serial port numbering on Mac depends on the physical USB port used and the device. If you want to keep the same names, you must connect to the same USB port each time.

2.6 PC interface


A PC application was developed to start playing with the robot attached to the computer via USB cable: you can have information about all the sensors, receive camera images and control the leds and motors.
Beware that it's not mandatory to download this application in order to work with the robot, but it is a nice demo that gives you an overview of all the sensors and actuators available on the robot, this is a first step to gain confidence with the robot.

With the factory firmwares programmed in the robot, place the selector in position 8, attach the USB cable and turn on the robot. Enter the correct port (the one related to e-puck2 STM32F407) in the interface and click connect.

The source code is available from the repository https://github.com/e-puck2/monitor.

2.6.1 Available executables

On Linux remember to apply the configuration explained in the chapter Installing the USB drivers in order to access the serial port.

2.7 Installing the dependencies for firmwares updates

You can update the firmware for all 3 chips: the main microcontroller, the radio module and the programmer. For doing that, you need some tools to be installed on the system.

2.7.1 Windows

To upload a new firmware in the microcontroller or in the radio module, you don't need to install anything, the packages provided include all the dependencies.

To upload a new firmware in the programmer you need to install an application called DfuSe released by STMicroelectronics. You can download it from DfuSe_V3.0.5.zip.

2.7.2 Linux

To upload a new firmware in the microcontroller or in the radio module, you need:

  • Python (>= 3.4): sudo apt-get install python3
  • Python pip: sudo apt-get install -y python3-pip
  • pySerial (>= 2.5): sudo pip3 install pyserial

To upload a new firmware in the programmer you need:

  • dfu-util: sudo apt-get install dfu-util

2.7.3 Mac

Install the Homewbrew package manager by opening a terminal and issueing:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
and then:
brew upgrade

To upload a new firmware in the microcontroller or in the radio module, you need:

  • Python (>= 3.4): brew install python (it will install also pip)
  • pySerial (>= 2.5): pip3 install pyserial

To upload a new firmware in the programmer you need:

  • dfu-util: brew install dfu-util

2.8 PC side development

This section is dedicated to the users that develop algorithms on the PC side and interact with the robot remotely through a predefined communication protocol. These users don't modify the firmware of the robot, but instead they use the factory firmware released with the robot. They update the robot firmware only when there is an official update.
The remote control of the robot, by receiving sensors values and setting the actuators, is done through the following channels: Bluetooth, Bluetooth Low Energy, WiFi, USB cable.
Examples of tools/environment used by these users:

  1. Aseba
  2. Simulator (e.g. Webots)
  3. ROS
  4. iOS, Android apps
  5. Custom PC application
  6. IoT (e.g. IFTTT)

If you fall into this category, then follow this section for more information: PC side development.

3 Main microcontroller

The e-puck2 robot main microcontroller is a 32-bit STM32F407 that runs at 168 MHz (210 DMIPS) and include DSP, FPU and DMA capabilities. The version chosen for the e-puck2 has 192 KB of total RAM and 1024 KB of flash, so there is a lot of memory to work with.
This chip is responsible for handling the sensors and actuators and runs also the demos and algorithms.

3.1 Factory firmware

The main microcontroller of the robot is initially programmed with a firmware that includes many demos that could be started based on the selector position, here is a list of the demos with related position and a small description:

  • Selector position 0: Aseba
  • Selector position 1: Shell
  • Selector position 2: Read proximity sensors and when an object is near a proximity, turn on the corresponding LED
  • Selector position 3: Asercom protocol v2 (BT)
  • Selector positoin 4: Range and bearing extension (receiver)
  • Selector position 5: Range and bearing extension (transmitter)
  • Selector position 6: Move the robot back and forth exploiting the gyro, with LEDs animation
  • Selector position 7: Play a wav (mono, 16 KHz) named "example.wav" from the micro sd when pressing the button
  • Selector position 8: Asercom protocol v2 (USB)
  • Selector position 9: Local communication: transceiver
  • Selector position 10: this position is used to work with the Linux extensions. To work with gumstix refer to Overo Extension: e-puck2 , to work with Pi-puck refer to Pi-puck: Requirements .
  • Selector position 11: Simple obstacle avoidance + some animation
  • Selector position 12: Hardware test
  • Selector position 13: LEDs reflect orientation of the robot
  • Selector position 14: Compass
  • Selector position 15: WiFi mode

The pre-built firmware is available here main microcontroller factory firmware (16.04.20).

3.2 Firmware update

Now and then there could be an official firmware update for the robot and it's important to keep the robot updated with the last firmware to get possibile new features, improvements and for bug fixes.
The onboard programmer run a GDB server, so we use GDB commands to upload a new firmware, for this reason a toolchain is needed to upload a new firmware to the robot.
The following steps explain how to update the main microcontroller firmware:
1. Download the package containing the required toolchain and script to program the robot: Windows, Linux 32 bits/64 bits, Mac OS
2. Download the last version of the main microcontroller factory firmware (16.04.20), or use your custom firmware
3. Extract the package and put the firmware file (with elf extension) inside the package directory; beware that only one elf file must be present inside this directory
4. Attach the USB cable and turn on the robot
5. Run the script from the package directory:

Windows: double click program.bat
Linux/Mac: issue the following command in a terminal ./program.sh. If you get permission errors, then issue sudo chmod +x program.sh to let the script be executable.

When the upload is complete you'll see an output like in the following figure:

The final lines should contain the entry ".data",, this means that the upload was successfull. You can then close the terminal window if it is still open.

If you encounter some problem, try to unplug and plug again the USB cable and power cycle the robot, then retry.

3.3 Robot side development

If you are an embedded developer and are brave enough, then you have complete access to the source code running on the robot, so you can discover what happen inside the main microcontroller and modify it to accomodate your needs. Normally the users that fall into this category develop algorithms optimized to run directly on the microcontroller, such as:

  1. onboard image processing
  2. swarm algorithms
  3. fully autonomous behaviors
  4. ...

For more information about programming the robot itself, refer to section Robot side development

4 Radio module

The radio module chosen for the e-puck is the new ESP32 chip from Espressif, integrating a dual core that run up to 240 MHz, 4 MB of flash and 520 KB of RAM. It supports WiFi standards 802.11 b/g/n (access point mode supported), Bluetooth and Bluetooth LE 4.2. It is the successor of the ESP8266 chip. The following figure shows the various peripherals available on the ESP32:

This chip first of all is responsible for handling the wireless communication, moreover it handles also the RGB LEDs (with PWM) and the user button. The RGB LEDs and button are connected to the radio module due to the pin number limitation on the main microcontroller.

4.1 Factory firmware

The radio module of the robot is initially programmed with a firmware that supports Bluetooth communication.
The pre-built firmware is available here radio module factory firmware (11.12.18).

4.2 WiFi firmware

At the moment the factory firmware supports only Bluetooth, if you want to work with WiFi you need to program the radio with a dedicated firmware, refer to section PC side development: WiFi.

4.3 BLE firmware

At the moment the factory firmware supports only calssic Bluetooth, if you want to work with Bluetooth Low Energy you need to program the radio with a dedicated firmware, refer to section Mobile phone development.

4.4 Firmware update

In order to update the firmware of the ESP32 WiFi module you need to use a python script called esptool provided by Espressif (manufacturer of the chip). This script was modified to work with the e-puck2 robot and is included in the provided package. The following steps explain how to update the radio module firmware:
1. Download the package containing the required tools and script to program the robot: Windows, Linux / Mac
2. Download the last version of the radio module factory firmware (11.12.18), or use another firmware (e.g. WiFi, BLE, your own). The firmware is composed by 3 files named bootloader.bin, ESP32_E-Puck_2.bin and partitions_singleapp.bin
3. Extract the package and put the firmware files inside the package directory; beware that the name of the .bin files must be the same as indicated in step 2
4. Attach the USB cable and turn on the robot
5. Run the script from the package directory:

Windows: double click program.bat
Linux/Mac: issue the following command in a terminal ./program.sh. If you get permission errors, then issue sudo chmod +x program.sh to let the script be executable.

The upload should last about 10-15 seconds and you'll see the progress as shown in the following figure:

When the upload is complete you'll see that all 3 bin files are uploaded correctly as shown in the following figure:

Sometime you could encounter a timeout error as shown in the following figures; in these cases you need to unplug and plug again the USB cable and power cycle the robot, then you can retry.

4.5 Development

Probably, you'll never need to touch the firmware running in the radio module, but in case you need to modify the code or you're simply curious about what is happening at the low level, then refer to the section Radio module development.

5 Programmer

The e-puck2 robot is equipped with an onboard programmer and debugger that let you update the firmware of the robot and debug your code easily using a standard USB interface. There is a dedicated STM32F413 microcontroller that acts as the programmer with built in GDB server, so you can control exactly what happens using the GNU Project Debugger in your host machine.
The programmer microcontroller is also in charge of handling various low level features such as the configuration of the USB hub and the power button.

5.1 Factory firmware

The programmer is initially programmed with a firmware based on a modified version of Black Magic Probe programmer/debugger.
The pre-built firmware is available here programmer-firmware.bin (28.05.20); it is also available in dfu format here programmer-firmware.dfu (28.05.20).

5.2 Firmware update

The programmer's microcontroller features a factory bootloader that can be entered by acting on some special pins, the bootloader mode is called DFU (device firmware upgrade). You can enter DFU mode by contacting two pinholes together while inserting the USB cable (no need to turn on the robot). The two pin holes are located near the USB connector of the e-puck2, see the photo below.


Location of the pin holes to put the programmer into DFU

The programmer will be recognized as STM Device in DFU Mode device.

Note for Windows users: the device should be recognized automatically (in all Windows versions), but in case it won't be detected then you need to install a libusbK driver for the DFU device.
Follow the same procedure as explained in section Installing the USB drivers using libusbK driver instead of USB Serial (CDC).

5.2.1 Linux/Mac

In order to update the programmer firmware you need an utility called dfu-util, it should be already installed from section Installing the dependencies for firmwares updates.
To uplaod the firmware, issue the following command: sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D programmer-firmware.bin

5.2.2 Windows

Start the DfuSe application (previously installed from section Installing the dependencies for firmwares updates). The programmer in DFU mode will be automatically detected as shown in figure 1. Then you need to open the compiled firmware by clicking on choose and then locating the file with dfu extension, as shown in figure 2. Now click on the upgrade button, a warning message will be shown, confirm the action by clicking on yes as shown in figure 3. If all is ok you'll be prompted with a message saying that the upgrade was successfull as shown in figure 4.

[1] [2] [3] [4]


5.3 Development

The programmer code shouldn't be modified, but if you know what you're doing then refer to section Programmer development.