e-puck2 and e-puck2 robot side development: Difference between pages

From GCtronic wiki
(Difference between pages)
Jump to navigation Jump to search
 
No edit summary
 
Line 1: Line 1:
=Hardware=
[{{fullurl:e-puck2}} e-puck2 main wiki]<br/>
==Overview==
=Installation of the e-puck2 environment=
<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>
Eclipse_e-puck2 is a distribution of Eclipse IDE for C/C++ Developers specially modified to edit and compile e-puck2's projects out of the box. It doesn't require to be installed and everything needed is located in the package given. The only dependency needed to be able to run Eclipse is '''Java'''.
<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/>


The following figures show the main components offered by the e-puck2 robot and where they are physically placed:<br/>
==Installation for Windows==
<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/>
===Java 8 32bits===
This section can be ignored if Java version 8 32bits is already installed on your computer.<br>
To verify, you can open the '''Programs and Features''' panel and search for a '''Java 8 Update xxx''' install.


==Specifications==
#Go to the [https://www.java.com/en/download/manual.jsp Java download page] and download "Windows offline" This is the 32bits version of Java.
The e-puck2 robot maintains full compatibility with its predecessor e-puck (e-puck HWRev 1.3 is considered in the following table):
#Run the downloaded installer and follow its instructions to proceed with the installation of Java 32bits.
{| border="1"
#Close the internet browser if it opened at the end of the installation.
|'''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="plain links">[http://projects.gctronic.com/epuck2/wiki_images/Java_windows.png <img width=500 src="http://projects.gctronic.com/epuck2/wiki_images/Java_windows.png">]</span><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/>
:''Java download page''


==Documentation==
===Eclipse_e-puck2===
* '''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]
#Download the [http://projects.gctronic.com/epuck2/Eclipse_e-puck2/Eclipse_e-puck2_Win32_11_apr_2018.zip Eclipse_e-puck2 package for windows].
* '''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]
#Unzip the downloaded file to the location you want (can take time). It is strongly recommended for better performance and less extraction time to use 7Zip. You can download it on http://www.7-zip.org.
* '''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]
#You can now run the <code>Eclipse_e-puck2.exe</code> to launch Eclipse.
* '''Camera''': PixelPlus PO8030D CMOS image sensor, [http://projects.gctronic.com/E-Puck/docs/Camera/PO8030D.pdf datasheet], no IR cut filter
#You can create a shortcut to Eclipse_e-puck2.exe and place it anywhere if you want.
* '''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==
:<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/Eclipse_e-puck2_Folder_Windows.png <img width=800 src="http://projects.gctronic.com/epuck2/wiki_images/Eclipse_e-puck2_Folder_Windows.png">]</span><br/>
The e-puck2 robot maintains full compatibility with its predecessor e-puck, but there are some improvements that you should be aware of.<br/>
:''Eclipse_e-puck2 folder obtained after extraction''


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/>
'''Important things to avoid :'''
:1. The path to the Eclipse_e-puck2 folder must contain zero space.  
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/>
::Example :
::<code>C:\epfl_stuff\Eclipse_e-puck2</code> OK
::<code>C:\epfl stuff\Eclipse_e-puck2</code> NOT OK
:2. You must not put Ellipse_e-puck2 folder into '''Program Files (x86)'''. Otherwise the compilation when using Eclipse will not work.
:3. The file’s structure in the Eclipse_e-puck2 folder must remain the same. It means no file inside this folder must be moved to another place.


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.
==Installation for Linux==
===Java 8===
This section can be ignored if Java is already installed on your computer.<br>
To verify whether it is installed or not you can type the following command into a terminal window:
<pre>update-java-alternatives -l</pre>
If Java is installed, you will get some information about it, otherwise the command will be unknown.<br>
You need to have Java 1.8.xxxx listed to be able to run Eclipse_e-puck2.


==Extensions==
Type the following commands in a terminal session to install Java SDK:
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/>
<pre>sudo add-apt-repository ppa:openjdk-r/ppa
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].
sudo apt-get update
sudo apt-get install openjdk-8-jre </pre>


=Getting Started=
===Eclipse_e-puck2===
The e-puck2 robot features 3 chips onboard:
#Install <code>make</code> (probably you already have it installed) by issueing the command: <code>sudo apt-get install make</code>
* the main microcontroller, that is responsible for handling the sensors and actuators and which runs also the demos/algorithms
#Download the Eclipse_e-puck2 package for Linux [http://projects.gctronic.com/epuck2/Eclipse_e-puck2/Eclipse_e-puck2_Linux_11_apr_2018_32bits.tar.gz 32bits] / [http://projects.gctronic.com/epuck2//Eclipse_e-puck2/Eclipse_e-puck2_Linux_11_apr_2018_64bits.tar.gz 64bits]. Pay attention to the 32bits or 64bits version. If unsure which Linux version you have, enter the following comand <code>uname -a</code> in the terminal window and look for i686 (32bit) or x86_64 (64 bit)
* 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)
#Extract the downloaded file to the location you want (can take time).
* 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)
#You can now run the <code>Eclipse_e-puck2</code> executable to launch Eclipse.


The following sections explain the basic usage of the robot, more detailed information can be found following the links provided.
:<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/Eclipse_e-puck2_Folder_Linux.png <img width=800 src="http://projects.gctronic.com/epuck2/wiki_images/Eclipse_e-puck2_Folder_Linux.png">]</span><br/>
:''Eclipse_e-puck2 folder obtained after extraction''


==Turn on/off the robot==
Note : The icon of the Eclipse_e-puck2 executable will appear after the first launch of the program.
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.


==Meaning of the LEDs==
'''Important things to avoid :'''
The e-puck2 has three groups of LEDs that are not controllable by the user.
:1. You cannot create a Link to the Eclipse_e-puck2 executable because otherwise the program will think its location is where the Link is and it will not find the resource located in the Eclipse_e-puck2 folder.
:2. The path to the Eclipse_e-puck2 folder must contain zero space.
::Example :
::<code>/home/student/epfl_stuff/Eclipse_e-puck2</code> OK
::<code>/home/student/epfl stuff/Eclipse_e-puck2</code> NOT OK
:3. The file’s structure in the Eclipse_e-puck2 folder must remain the same. It means no file inside this folder must be moved to another place.


::<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/>
==Installation for Mac==
::''Top view of the e-puck2''
===Command Line Tools ===
To compile on Mac with Eclipse_e-puck2, it is necessary to have the Command Line Tools installed. It is a bundle of many commonly used tools.<br>
You can install it by typing the following command in a terminal window. It will then open a popup asking you if you want to install this bundle. Otherwise it will tell you it is already installed.
<pre>xcode-select --install</pre>


*Charger: RED if charging, GREEN if charge complete and RED and GREEN if an error occurs
===Java 8===
*USB: Turned ON if the e-puck2 detects a USB connection with a computer
This section can be ignored if Java is already installed on your computer.<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 verify whether it is installed or not you can type the following command into a terminal window. It will list all the Java runtimes installed on your Mac.
<pre>/usr/libexec/java_home -V</pre>
You need to have <code>Java SE 8</code> listed to be able to run Eclipse_e-puck2.


Battery level indications (STATUS RGB LED):
:1. Go to the [http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html Java download page] and download the <code>Mac OS X Java 8 SE Development Kit</code>. It is the .dmg file without the Demos and Samples.
*GREEN if the system's tension is greater than 3.5V
::For example: <code>jdk-8uXXX-macosx-x64.dmg</code>
*ORANGE if the system's tension is between 3.5V and 3.4V
:2. Open the .dmg file downloaded, run the installer and follow the instructions to proceed with the installation of Java SDK.
*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.
:<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/Java_mac.png <img width=500 src="http://projects.gctronic.com/epuck2/wiki_images/Java_mac.png">]</span><br/>
:''Java download page''


==Connecting the USB cable==
===Eclipse_e-puck2===
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.
:1. Download the [http://projects.gctronic.com/epuck2/Eclipse_e-puck2/Eclipse_e-puck2_Mac_11_apr_2018.dmg Eclipse_e-puck2 package for Mac].
::<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/>
:2. Open the .dmg file downloaded and DragAndDrop the Eclipse_e-puck2.app into the Applications folder
::Note : You can place the Eclipse_e-puck2.app anywhere, as long as the full path to it doesn’t contain any space, if you don’t want it to be in Applications.
:3. You can create an Alias to Eclipse_e-puck2.app and place it anywhere if you want.


==Installing the USB drivers==
===First launch and Gatekeeper===
The USB drivers must be installed only for the users of a Windows version older than Windows 10:
It’s very likely that Gatekeeper (one of the protections of Mac OS) will prevent you to launch Eclipse_e-puck2.app because it isn’t signed from a known developer.<br>
If you can’t run the program because of a warning of the system, press <code>OK</code> and try to launch it by right clicking on it and choosing <code>open</code> in the contextual menu (may be slow to open the first time).<br>
If <code>Unable to open "Eclipse_e-puck2.app" because this app comes from an unidentified developer.</code> or if <code>"Eclipse.app" is corrupted and cannot be opened. You should place this item in the Trash.</code> appears after executing the app the first time, it is needed to disable temporarily Gatekeeper.


#Download and open [http://projects.gctronic.com/epuck2/zadig-2.3.exe zadig-2.3.exe]
To do so :
#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)'''.
#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>


:<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/>
:1. Go to <code>System Preferences->security and privacy->General</code> and authorize downloaded application from <code>Anywhere</code>.
::''Example of driver installation for e-puck2 STM32F407''


The drivers are automatically installed with Windows 10, Linux and Mac OS.
::<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/security_tab_mac.png <img width=500 src="http://projects.gctronic.com/epuck2/wiki_images/security_tab_mac.png">]</span><br/>
::''Security settings of 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: <code>sudo adduser $USER dialout</code>. Once done, you need to log off to let the change take effect.
::If you are on Mac OS Sierra or greater (greater or equal to Mac OS 10.12), you must type the following command on the terminal to make the option above appear.
::<pre>sudo spctl --master-disable</pre>
:2. Now you can try to run the application and it should work.
:3. If Eclipse opened successfully, it is time to reactivate Gatekeeper. Simply set back the setting of Gatekeeper.
::For the ones who needed to type a command to disable Gatekeeper, here is the command to reactivate it.
::<pre>sudo spctl --master-enable</pre>


==Finding the USB serial ports used==
This procedure is only needed the first time. After that Gatekeeper will remember your choice to let run this application and will not bother you anymore, as long as you use this application. If you re-download it, you will have to redo the procedure for Gatekeeper.
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 standard firmware a port named '''e-puck2 STM32F407''' is created.
'''Important things to avoid :'''
===Windows===
:1. The path to the Eclipse_e-puck2.app must contain zero space.
#Open the Device Manager
::Example :
#Under '''Ports (COM & LPT)''' you can see the virtual ports connected to your computer.
::<code>/home/student/epfl_stuff/Eclipse_e-puck2</code> OK
#Do a '''Right-click -> properties''' on the COM port you want to identify.
::<code>/home/student/epfl stuff/Eclipse_e-puck2</code> NOT OK
#Go under the '''details''' tab and select '''Bus reported device description''' in the properties list.
:2. The file’s structure in the Eclipse_e-puck2.app must remain the same. It means no file inside this app must be moved to another place.
#The name of the port should be written in the text box below.
#Once you found the desired device, you can simply look at its port number '''(COMX)'''.


===Linux===
=Get the source code=
:1. Open a terminal window (<code>ctrl+alt+t</code>) and enter the following command: <code>ls /dev/ttyACM*</code>
The source code is available in the git repo [https://github.com/e-puck2/e-puck2_main-processor https://github.com/e-puck2/e-puck2_main-processor].<br/>
: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 standard 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.


===Mac===
==Configuring the Debugger's settings==
:1. Open a terminal window and enter the following command: <code>ls /dev/cu.usbmodem*</code>
Eclipse_e-puck2 contains everything needed to compile, program and debug the e-puck2.<br>
: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''' and '''e-puck2 Serial Monitor'''. A third device '''cu.usbmodemXXXX''' will be available with the standard firmware, that is related to '''e-puck2 STM32F407''' port
The only settings to configure with a new project are located under the '''Debug Configurations''' tab of Eclipse (you can also find it on '''Run->Debug Configurations''').  
:<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/Debug_configuration.png <img width=231 src="http://projects.gctronic.com/epuck2/wiki_images/Debug_configuration.png">]</span><br/>
Once in the settings, select '''Generic Blackmagic Probe''' preset on the left panel. Then you need to configure two things :


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.
#If you already have a project, under the '''main''' tab, you need to select which project to debug and the path to the compiled file. If the project has already been compiled, Eclipse must have indexed the binaries and you can list the project and the compiled files using respectively the '''Browse...''' and '''Search Project...''' buttons. If you do not already have a project, add a random name as the title which will act as a place holder, allowing you to apply the next configuration.
#Under the '''Startup''' tab, you need to replace the path to the serial port written on the first line of the text box by the one used by the GDB Server of your e-puck. [[#Finding the USB serial ports used | See how to find it]].
:* For Windows, it will be '''\\.\COMX''', X being the port number.
:* For Linux, it will be '''/dev/ttyACMX''', X being the port number
:* For Mac, it will be '''/dev/cu.usbmodemXXXXX''', XXXXX being the port number.
:* You can also type '''${COM_PORT}''' instead of the com port in order to use the variable COM_PORT for the debug configuration.<br>To change the value of this variable, go to the '''main''' tab again, click on the '''Variables...''' button and click on the '''Edit Variables...''' button. The opened window will let you edit the value of the variable.<br>Using the variable COM_PORT instead of the real com port in a debug configuration is useful if you have multiple debug configurations for example. If for one reason you need to change the com port to use, then you can simply edit the variable COM_PORT instead of editing the com port for each debug configuration


==PC interface==
If you want to debug another project, you can change the settings of the '''Generic Blackmagic Probe''' preset or copy it into another preset and configure this one in order to have one preset by project.
<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/>
Now you should be able to use the debugger with Eclipse.
A PC application was developed to start playing with the robot: you can have information about all the sensors, receive camera images and control the leds and motors.<br/>
With the standard firmware 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/>
==Creating a project==
===Basic standard project===
[https://github.com/e-puck2/e-puck2_main-processor.git e-puck2_main-processor] is the basic standard project containing all the libraries written for the e-puck2. Refer to the [http://www.gctronic.com/doc/index.php?title=e-puck2#Library Library] section to download the complete version.<br>
The basic standard project shows how to use the libraries and can be interfaced with [[#PC interface | e-puck2 monitor]].<br/>
This project can be added to Eclipse_e-puck2 by following the next steps:<br>
# Run Eclipse and then select '''File->New->Makefile Project with Existing Code'''.
# Next choose the project folder and set a project name (otherwise you can keep the one created by Eclipse). Choose '''None''' for the the toolchain.
# Click on the '''Finish''' button and the project is added to Eclipse.


Available executables:
===Project template===
* [http://projects.gctronic.com/epuck2/monitor_win.zip Windows executable]: tested on Windows 7 and Windows 10
The basic standard project can also be used as a library to build your own project on top of it.<br>
* [http://projects.gctronic.com/epuck2/monitor_mac.zip Max OS X executable]


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.
To accomplish that, you have to copy the folder '''Project_template''', contained in the e-puck2_main-processor project, where you want to place your project.<br>
You can of course rename the folder to the name you want.<br>


==PC side development==
The next step is to edit the makefile of your project. Set the name of your project, write the updated path to the e-puck2_main-processor folder, and also rewrite the path to the .c files. Lastly, include the path for any desired .h files from other folders.<br>
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 standard firmware released with the robot. They update the robot firmware only when there is an official update. <br/>
All the .h files located next to the makefile are automatically included in the compilation. But if you need to place them into folders, you have to specify these folders in the makefile.
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/>
This makefile uses the main makefile of the e-puck2_main-processor project. This means you can add custom commands to the makefile but it should not interfere with the main makefile.
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].


=Main microcontroller=
The result of the compilation will appear in a build folder in your project folder.
[http://www.gctronic.com/doc/index.php?title=e-puck2_main_microcontroller_programming main microcontroller programming]
 
==Standard firmware==
===Adding to Eclipse_epuck2===
The robot is initially programmed with a firmware that includes many demos that could be started based on the selector position:
#To add the project into Eclipse, you need to select '''File->New->Makefile Project with Existing Code'''.
* Selector position 0: Aseba
#Next choose your project folder and set a project name. Choose '''None''' for the the toolchain.
* Selector position 1: Shell
#Click on the '''Finish''' button and the project is added to Eclipse.
* Selector position 2: Read proximity sensors
#Rename the file '''Debug_project_template.launch''' contained in the project folder by the name you want for the debug configuration of your project.
* Selector position 3: Asercom protocol v2 (BT)
#Go to '''Run->Debug Configurations...''' and select on the left your new debug configuration and set the project to debug and the path to the compiled file of the project ([[#Configuring the Debugger's settings |as explained in the chapter before]]). If there is nothing apering when you press '''Search Project...''' then you must enter the '''.elf''' file name by hand, which can be found in your project folder under a folder named '''build'''.
* Selector positoin 4: Range and bearing extension (receiver)
#Go to  '''Project->Properties->C/C++ General->Preprocessor Include Paths, Macros etc->Providers''' and Check '''CDT Cross GCC Built-in Compiler Settings'''.<br> Then in the textbox below, write '''arm-none-eabi-gcc ${FLAGS} -E -P -v -dD "${INPUTS}"'''.
* Selector position 5: Range and bearing extension (transmitter)
#Create a linked folder inside your project that links to the e-puck2_main-processor library. This allows Eclipse to index the declarations and implementations of the functions and variables in the code of the library.
* Selector position 6: ESP32 UART communication test
##Go to '''File->New->Folder'''.
* Selector position 7: ...
##Check '''Advanced >>''' on the bottom.
* Selector position 8: Asercom protocol v2 (USB)
##Choose '''Link to alternate location (Linked Folder)'''.
* Selector position 9: Asercom protocol (BT)
##Type '''PROJECT_LOC''' and then add to this path the path to the e-puck2_main-processor folder. For example '''PROJECT_LOC/../e-puck2_main-processor''' if the library is located as the same level as your project folder.
* Selector position 10: This position is used to work with the gumstix extension.  
#Before you compile, make sure the robot is turned on, and in addition make sure that the Makefile, has a capital M in the front.  
* Selector position 11: Simple obstacle avoidance + some animation
#After you compile the project and if it succeeded, select the project root folder and go to '''Project->C/C++ Index->Rebuild''' to rebuild the index. (We need to have compiled at least one time in order to let Eclipse find all the paths to the files used.)
* Selector position 12: Hardware test
 
* Selector position 13: LEDs reflect orientation of the robot
You should now be able to use the project with Eclipse.
* Selector position 14: Read magnetometer sensor
 
* Selector position 15: ...
==Flashing the main microcontroller==
The source code is available in the git repo [https://github.com/e-puck2/e-puck2_main-processor https://github.com/e-puck2/e-puck2_main-processor].<br/>
In order to update the firmware of the main microcontroller (STM32F407) you can either use Eclipse (as explained in section [http://www.gctronic.com/doc/index.php?title=e-puck2#Configuring_the_Debugger.27s_settings Configuring the Debugger settings]) or you can do it manually as explained in this section. The onboard programmer run a gdb server, so we can use gdb commands to upload a new firmware.<br/>
The pre-built firmware is available here <a name="e-puck2_main-processor" href="http://projects.gctronic.com/epuck2/e-puck2_main-processor_23.04.18_3988f7c.elf">e-puck2-firmware</a>.
1. download the gdb init file [http://projects.gctronic.com/epuck2/mygdbinit mygdbinit] and place it in the same folder of the compiled firmware. This file has the following content:
<pre>target extended-remote \\.\COM72
monitor swdp_scan
attach 1
set mem inaccessible-by-default off
load</pre>
In this file you need to change the port to reflect the one of the <code>GDB server</code> (see chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#Finding_the_USB_serial_ports_used Finding the USB serial ports used]).


=Radio module=
2. issue the following command to start the upload
<pre>Windows: arm-none-eabi-gdb.exe --interpreter=mi -x mygdbinit firmware.elf
Linux/Mac: arm-none-eabi-gdb --interpreter=mi -x mygdbinit firmware.elf</pre>
In this command you need to change the name of the firmware with the one you have.<br/>
Moreover if the <code>PATH</code> variable is not set (see chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#Configuring_the_PATH_variable Configuring the PATH variable]) you need to insert the absolute path to the debugger that you can find in the Eclipse package (see chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#Installation_of_the_e-puck2_environment Installation of the e-puck2 environment]) inside the directory <code>Tools\gcc-arm-none-eabi-XXX\bin</code>.


When the upload is complete you'll see an output like in the following figure:<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/>
The final line should contain <code>".data",</code> , and it should all be enclosed at the end with <code>(gdb)</code>. You can then close the terminal window.


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

Revision as of 13:43, 26 July 2018

e-puck2 main wiki

Installation of the e-puck2 environment

Eclipse_e-puck2 is a distribution of Eclipse IDE for C/C++ Developers specially modified to edit and compile e-puck2's projects out of the box. It doesn't require to be installed and everything needed is located in the package given. The only dependency needed to be able to run Eclipse is Java.

Installation for Windows

Java 8 32bits

This section can be ignored if Java version 8 32bits is already installed on your computer.
To verify, you can open the Programs and Features panel and search for a Java 8 Update xxx install.

  1. Go to the Java download page and download "Windows offline" This is the 32bits version of Java.
  2. Run the downloaded installer and follow its instructions to proceed with the installation of Java 32bits.
  3. Close the internet browser if it opened at the end of the installation.

Java download page

Eclipse_e-puck2

  1. Download the Eclipse_e-puck2 package for windows.
  2. Unzip the downloaded file to the location you want (can take time). It is strongly recommended for better performance and less extraction time to use 7Zip. You can download it on http://www.7-zip.org.
  3. You can now run the Eclipse_e-puck2.exe to launch Eclipse.
  4. You can create a shortcut to Eclipse_e-puck2.exe and place it anywhere if you want.

Eclipse_e-puck2 folder obtained after extraction

Important things to avoid :

1. The path to the Eclipse_e-puck2 folder must contain zero space.
Example :
C:\epfl_stuff\Eclipse_e-puck2 OK
C:\epfl stuff\Eclipse_e-puck2 NOT OK
2. You must not put Ellipse_e-puck2 folder into Program Files (x86). Otherwise the compilation when using Eclipse will not work.
3. The file’s structure in the Eclipse_e-puck2 folder must remain the same. It means no file inside this folder must be moved to another place.

Installation for Linux

Java 8

This section can be ignored if Java is already installed on your computer.
To verify whether it is installed or not you can type the following command into a terminal window:

update-java-alternatives -l

If Java is installed, you will get some information about it, otherwise the command will be unknown.
You need to have Java 1.8.xxxx listed to be able to run Eclipse_e-puck2.

Type the following commands in a terminal session to install Java SDK:

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jre 

Eclipse_e-puck2

  1. Install make (probably you already have it installed) by issueing the command: sudo apt-get install make
  2. Download the Eclipse_e-puck2 package for Linux 32bits / 64bits. Pay attention to the 32bits or 64bits version. If unsure which Linux version you have, enter the following comand uname -a in the terminal window and look for i686 (32bit) or x86_64 (64 bit).
  3. Extract the downloaded file to the location you want (can take time).
  4. You can now run the Eclipse_e-puck2 executable to launch Eclipse.

Eclipse_e-puck2 folder obtained after extraction

Note : The icon of the Eclipse_e-puck2 executable will appear after the first launch of the program.

Important things to avoid :

1. You cannot create a Link to the Eclipse_e-puck2 executable because otherwise the program will think its location is where the Link is and it will not find the resource located in the Eclipse_e-puck2 folder.
2. The path to the Eclipse_e-puck2 folder must contain zero space.
Example :
/home/student/epfl_stuff/Eclipse_e-puck2 OK
/home/student/epfl stuff/Eclipse_e-puck2 NOT OK
3. The file’s structure in the Eclipse_e-puck2 folder must remain the same. It means no file inside this folder must be moved to another place.

Installation for Mac

Command Line Tools

To compile on Mac with Eclipse_e-puck2, it is necessary to have the Command Line Tools installed. It is a bundle of many commonly used tools.
You can install it by typing the following command in a terminal window. It will then open a popup asking you if you want to install this bundle. Otherwise it will tell you it is already installed.

xcode-select --install

Java 8

This section can be ignored if Java is already installed on your computer.
To verify whether it is installed or not you can type the following command into a terminal window. It will list all the Java runtimes installed on your Mac.

/usr/libexec/java_home -V

You need to have Java SE 8 listed to be able to run Eclipse_e-puck2.

1. Go to the Java download page and download the Mac OS X Java 8 SE Development Kit. It is the .dmg file without the Demos and Samples.
For example: jdk-8uXXX-macosx-x64.dmg
2. Open the .dmg file downloaded, run the installer and follow the instructions to proceed with the installation of Java SDK.

Java download page

Eclipse_e-puck2

1. Download the Eclipse_e-puck2 package for Mac.
2. Open the .dmg file downloaded and DragAndDrop the Eclipse_e-puck2.app into the Applications folder
Note : You can place the Eclipse_e-puck2.app anywhere, as long as the full path to it doesn’t contain any space, if you don’t want it to be in Applications.
3. You can create an Alias to Eclipse_e-puck2.app and place it anywhere if you want.

First launch and Gatekeeper

It’s very likely that Gatekeeper (one of the protections of Mac OS) will prevent you to launch Eclipse_e-puck2.app because it isn’t signed from a known developer.
If you can’t run the program because of a warning of the system, press OK and try to launch it by right clicking on it and choosing open in the contextual menu (may be slow to open the first time).
If Unable to open "Eclipse_e-puck2.app" because this app comes from an unidentified developer. or if "Eclipse.app" is corrupted and cannot be opened. You should place this item in the Trash. appears after executing the app the first time, it is needed to disable temporarily Gatekeeper.

To do so :

1. Go to System Preferences->security and privacy->General and authorize downloaded application from Anywhere.

Security settings of Mac OS
If you are on Mac OS Sierra or greater (greater or equal to Mac OS 10.12), you must type the following command on the terminal to make the option above appear.
sudo spctl --master-disable
2. Now you can try to run the application and it should work.
3. If Eclipse opened successfully, it is time to reactivate Gatekeeper. Simply set back the setting of Gatekeeper.
For the ones who needed to type a command to disable Gatekeeper, here is the command to reactivate it.
sudo spctl --master-enable

This procedure is only needed the first time. After that Gatekeeper will remember your choice to let run this application and will not bother you anymore, as long as you use this application. If you re-download it, you will have to redo the procedure for Gatekeeper.

Important things to avoid :

1. The path to the Eclipse_e-puck2.app must contain zero space.
Example :
/home/student/epfl_stuff/Eclipse_e-puck2 OK
/home/student/epfl stuff/Eclipse_e-puck2 NOT OK
2. The file’s structure in the Eclipse_e-puck2.app must remain the same. It means no file inside this app must be moved to another place.

Get the source code

The source code is available in the git repo https://github.com/e-puck2/e-puck2_main-processor.

Configuring the Debugger's settings

Eclipse_e-puck2 contains everything needed to compile, program and debug the e-puck2.
The only settings to configure with a new project are located under the Debug Configurations tab of Eclipse (you can also find it on Run->Debug Configurations).


Once in the settings, select Generic Blackmagic Probe preset on the left panel. Then you need to configure two things :

  1. If you already have a project, under the main tab, you need to select which project to debug and the path to the compiled file. If the project has already been compiled, Eclipse must have indexed the binaries and you can list the project and the compiled files using respectively the Browse... and Search Project... buttons. If you do not already have a project, add a random name as the title which will act as a place holder, allowing you to apply the next configuration.
  2. Under the Startup tab, you need to replace the path to the serial port written on the first line of the text box by the one used by the GDB Server of your e-puck. See how to find it.
  • For Windows, it will be \\.\COMX, X being the port number.
  • For Linux, it will be /dev/ttyACMX, X being the port number
  • For Mac, it will be /dev/cu.usbmodemXXXXX, XXXXX being the port number.
  • You can also type ${COM_PORT} instead of the com port in order to use the variable COM_PORT for the debug configuration.
    To change the value of this variable, go to the main tab again, click on the Variables... button and click on the Edit Variables... button. The opened window will let you edit the value of the variable.
    Using the variable COM_PORT instead of the real com port in a debug configuration is useful if you have multiple debug configurations for example. If for one reason you need to change the com port to use, then you can simply edit the variable COM_PORT instead of editing the com port for each debug configuration

If you want to debug another project, you can change the settings of the Generic Blackmagic Probe preset or copy it into another preset and configure this one in order to have one preset by project. Now you should be able to use the debugger with Eclipse.

Creating a project

Basic standard project

e-puck2_main-processor is the basic standard project containing all the libraries written for the e-puck2. Refer to the Library section to download the complete version.
The basic standard project shows how to use the libraries and can be interfaced with e-puck2 monitor.
This project can be added to Eclipse_e-puck2 by following the next steps:

  1. Run Eclipse and then select File->New->Makefile Project with Existing Code.
  2. Next choose the project folder and set a project name (otherwise you can keep the one created by Eclipse). Choose None for the the toolchain.
  3. Click on the Finish button and the project is added to Eclipse.

Project template

The basic standard project can also be used as a library to build your own project on top of it.

To accomplish that, you have to copy the folder Project_template, contained in the e-puck2_main-processor project, where you want to place your project.
You can of course rename the folder to the name you want.

The next step is to edit the makefile of your project. Set the name of your project, write the updated path to the e-puck2_main-processor folder, and also rewrite the path to the .c files. Lastly, include the path for any desired .h files from other folders.
All the .h files located next to the makefile are automatically included in the compilation. But if you need to place them into folders, you have to specify these folders in the makefile. This makefile uses the main makefile of the e-puck2_main-processor project. This means you can add custom commands to the makefile but it should not interfere with the main makefile.

The result of the compilation will appear in a build folder in your project folder.

Adding to Eclipse_epuck2

  1. To add the project into Eclipse, you need to select File->New->Makefile Project with Existing Code.
  2. Next choose your project folder and set a project name. Choose None for the the toolchain.
  3. Click on the Finish button and the project is added to Eclipse.
  4. Rename the file Debug_project_template.launch contained in the project folder by the name you want for the debug configuration of your project.
  5. Go to Run->Debug Configurations... and select on the left your new debug configuration and set the project to debug and the path to the compiled file of the project (as explained in the chapter before). If there is nothing apering when you press Search Project... then you must enter the .elf file name by hand, which can be found in your project folder under a folder named build.
  6. Go to Project->Properties->C/C++ General->Preprocessor Include Paths, Macros etc->Providers and Check CDT Cross GCC Built-in Compiler Settings.
    Then in the textbox below, write arm-none-eabi-gcc ${FLAGS} -E -P -v -dD "${INPUTS}".
  7. Create a linked folder inside your project that links to the e-puck2_main-processor library. This allows Eclipse to index the declarations and implementations of the functions and variables in the code of the library.
    1. Go to File->New->Folder.
    2. Check Advanced >> on the bottom.
    3. Choose Link to alternate location (Linked Folder).
    4. Type PROJECT_LOC and then add to this path the path to the e-puck2_main-processor folder. For example PROJECT_LOC/../e-puck2_main-processor if the library is located as the same level as your project folder.
  8. Before you compile, make sure the robot is turned on, and in addition make sure that the Makefile, has a capital M in the front.
  9. After you compile the project and if it succeeded, select the project root folder and go to Project->C/C++ Index->Rebuild to rebuild the index. (We need to have compiled at least one time in order to let Eclipse find all the paths to the files used.)

You should now be able to use the project with Eclipse.

Flashing the main microcontroller

In order to update the firmware of the main microcontroller (STM32F407) you can either use Eclipse (as explained in section Configuring the Debugger settings) or you can do it manually as explained in this section. The onboard programmer run a gdb server, so we can use gdb commands to upload a new firmware.
1. download the gdb init file mygdbinit and place it in the same folder of the compiled firmware. This file has the following content:

target extended-remote \\.\COM72
monitor swdp_scan
attach 1
set mem inaccessible-by-default off
load

In this file you need to change the port to reflect the one of the GDB server (see chapter Finding the USB serial ports used).

2. issue the following command to start the upload

Windows: arm-none-eabi-gdb.exe --interpreter=mi -x mygdbinit firmware.elf
Linux/Mac: arm-none-eabi-gdb --interpreter=mi -x mygdbinit firmware.elf

In this command you need to change the name of the firmware with the one you have.
Moreover if the PATH variable is not set (see chapter Configuring the PATH variable) you need to insert the absolute path to the debugger that you can find in the Eclipse package (see chapter Installation of the e-puck2 environment) inside the directory Tools\gcc-arm-none-eabi-XXX\bin.

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

The final line should contain ".data", , and it should all be enclosed at the end with (gdb). You can then close the terminal window.

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