e-puck2 PC side development and Wheelphone: Difference between pages

From GCtronic wiki
(Difference between pages)
Jump to navigation Jump to search
 
No edit summary
 
Line 1: Line 1:
[{{fullurl:e-puck2}} e-puck2 main wiki]<br/>
=Features=
* compatible with <b>Android</b> phones (USB communication) and <b>iPhone</b> (sound cable)
* telepresence (with Skype and robot remote control) <span class="plainlinks">[https://www.gctronic.com/doc/index.php/Wheelphone-videos#Wheelphone_robot_telepresence_with_Skype_.28iPhone_and_Android.29 <img width=16 src="https://www.gctronic.com/doc/images/phones-video-call-icon.png">]</span>
* avoid obstacles <span class="plainlinks">[https://www.gctronic.com/doc/index.php/Wheelphone-videos#Wheelphone_robot_capabilities <img width=16 src="https://www.gctronic.com/doc/images/phones-video-call-icon.png">]</span>
* doesn't fall from table <span class="plainlinks">[https://www.gctronic.com/doc/index.php/Wheelphone-videos#Wheelphone_robot_capabilities <img width=16 src="https://www.gctronic.com/doc/images/phones-video-call-icon.png">]</span>
* runs on carpet <span class="plainlinks">[https://www.gctronic.com/doc/index.php/Wheelphone-videos#Wheelphone_overcomes_obstacles <img width=16 src="https://www.gctronic.com/doc/images/phones-video-call-icon.png">]</span>
* docking station <span class="plainlinks">[https://www.gctronic.com/doc/index.php/Wheelphone-videos#Wheelphone_navigation_and_automatic_docking_with_markers <img width=16 src="https://www.gctronic.com/doc/images/phones-video-call-icon.png">]</span>
* charges phone
* available examples (apps) source code


=Robot configuration=
For more technical specifications refer to the page [{{fullurl:Wheelphone technical specifications}} Wheelphone technical specifications]
This section explains how to configure the robot based on the communication channel you will use for your developments, thus you need to read only one of the following sections, but it would be better if you spend a bit of time reading them all in order to have a full understanding of the available configurations.
==Bluetooth and USB==
The robot is initially programmed with a firmware that supports Bluetooth and USB communication.<br/>
If the robot isn't programmed with the standard firmware or if you want to be sure to have the last firmware on the robot, you need to program it with the last standard firmware, refer to section [http://www.gctronic.com/doc/index.php?title=e-puck2#Firmware_update Firmware update].<br/>
When you want to interact with the robot from the computer you need to place the selector in position 3 if you want to work with Bluetooth, or in position 8 if you want to work with USB. Both communication channels use the same protocol called <code>asercom v2</code>, refer to section [http://www.gctronic.com/doc/index.php?title=e-puck2_PC_side_development#Bluetooth_and_USB Communication protocol: BT and USB] for detailed information about this protocol.<br/>


==WiFi==
=Getting started=
For working with the WiFi there is a special firmware, refer to section [].
Informations on how to start playing with the Wheelphone robot can be found in the following page [{{fullurl:Getting started}} Getting started].


=Connecting to the Bluetooth=
=Software=
You can find the software related to the <b>Android</b> platform on the following page [{{fullurl:Android software}} <b>Android software</b>].<br/>
You can find the software related to the <b>iPhone</b> platform on the follwing page [{{fullurl:IPhone software}} <b>iPhone software</b>].


The default firmware in the ESP32, the module which provides Bluetooth and Wi-Fi connectivity, creates 3 Bluetooth channels using the RFcomm protocol:
=Media=
# Channel 1, GDB: port to connect with GDB if the programmer is in mode 1 or 3 (refer to chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#Configuring_the_Programmer.27s_settings Configuring the Programmer's settings] for more information about these modes)
You can find images of the Wheelphone in the following page: [{{fullurl:Wheelphone-images}} Wheelphone images].<br/>
# Channel 2, UART: port to connect to the UART port of the main processor
You can find various videos of the Wheelphone in the following page: [{{fullurl:Wheelphone-videos}} Wheelphone videos].
# Channel 3, SPI: port to connect to the SPI port of the main processor (not yet implemented. Just do an echo for now)


By default, the e-puck2 is not visible when you search for it in the Bluetooth utility of your computer.<br>
=Hands-on=
'''To make it visible, it is necessary to hold the USER button (also labeled "esp32" on the electronic board) while turning on the robot with the ON/OFF button.'''<br>
If you're interested in doing some mechanical experiments to play with the Wheelphone robot visit the section [{{fullurl:Hands-on}} Hands-on].
Then it will be discoverable and you will be able to pair with it.<br>
Note that a prompt could ask you to confirm that the number written on the screen is the same on the e-puck. just ignore this and accept. Otherwise if you are asked for a pin insert 0000.
 
==Windows 7==
When you pair your computer with the e-puck2, 3 COM ports will be automatically created.
To see which COM port corresponds to which channel you need to open the properties of the paired e-puck2 robot from <code>Bluetooth devices</code>. Then the ports and related channels are listed in the <code>Services</code> tab, as shown in the following figure:<br/>
<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/BT-connection-win7.png <img width=300 src="http://projects.gctronic.com/epuck2/wiki_images/BT-connection-win7.png">]</span>
 
==Windows 10==
When you pair your computer with the e-puck2, 6 COM ports will be automatically created. The three ports you will use have <code>Outgoing</code> direction and are named <code>e_puck2_xxxxx-GDB</code>, <code>e_puck2_xxxxx-UART</code>, <code>e_puck2_xxxxx-SPI</code>. <code>xxxxx</code> is the ID number of your e-puck2.<br/>
To see which COM port corresponds to which channel you need to:
# open the Bluetooth devices manager
# pair with the robot
# click on <code>More Bluetooth options</code>
# the ports and related channels are listed in the <code>COM Ports</code> tab, as shown in the following figure:<br/>
:<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/BT-connection-win10.png <img height=300 src="http://projects.gctronic.com/epuck2/wiki_images/BT-connection-win10.png">]</span>
 
==Linux==
Once paired with the Bluetooth manager, you need to create the port for communicating with the robot by issueing the command: <br/>
<code>sudo rfcomm bind /dev/rfcomm0 MAC_ADDR 2</code><br/>
The MAC address is visible from the Bluetooth manager. The parameter <code>2</code> indicates the channel, in this case a port for the <code>UART</code> channel is created. If you want to connect to another service you need to change this parameter accordingly (e.g. <code>1</code> for <code>GDB</code> and <code>3</code> for <code>SPI</code>). Now you can use <code>/dev/rfcomm0</code> to connect to the robot.
 
==Mac==
When you pair your computer with the e-puck2, 3 COM ports will be automatically created: <code>/dev/cu.e-puck2_xxxxx-GDB</code>, <code>/dev/cu.e-puck2_xxxxx-UART</code> and <code>/dev/cu.e-puck2_xxxxx-SPI</code>. xxxxx is the ID number of your e-puck2.
 
=Connecting to the WiFi=
At the moment the WiFi channel is used to transfer the image to the computer (a QQVGA color image is transferred) together with the sensors values (magnetometer, selector and tv remote not supported at the moment). The robot is also able to receive commands from the computer (only motors and red LEDs are supported at the moment).<br/>
A dedicated configuration is needed to use the WiFi, thus the robot and WiFi module firmwares need to be updated; moreover a PC application is provided to receive the data from the robot and send commands to it:
# [http://projects.gctronic.com/epuck2/e-puck2_main-processor_wifi_afaa618.elf main processor firmware] (see chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#Flashing_the_main_microcontroller Flashing the main microcontroller]to update the firmware); put the selector in position 15. If you are interested to the source code, refer to chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#WiFi_support_2 Main microcontroller - WiFi support].
# [http://projects.gctronic.com/epuck2/esp32-firmware-wifi-7bf44de.zip WiFi module firmware] (see chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#Flashing_the_radio_module Flashing the radio module] to update the firmware). If you are interested to the source code, refer to chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#WiFi_support_3 Radio module - WiFi support].
# PC application: [http://projects.gctronic.com/epuck2/monitor_wifi_27dddd4.zip Monitor WiFi]. If you are interested to the source code, refer to chapter [http://www.gctronic.com/doc/index.php?title=e-puck2#WiFi_support PC interface - WiFi support].
 
The LED2 is used to indicate the state of the WiFi connection:
* red indicates that the robot is in ''access point mode'' (waiting for configuration)
* green indicates that the robot is connected to a network and has received an IP address
* blue (toggling) indicates that the robot is transferring the image to the computer
 
==Network configuration==
If there is no WiFi configuration saved in flash, then the robot will be in ''access point mode'' in order to let the user connect to it and setup a WiFi connection. The LED2 is red.
 
The access point SSID will be <code>e-puck2_0XXXX</code> where <code>XXXX</code> is the id of the robot; the password to connect to the access point is <code>e-puck2robot</code>.<br/>
You can use a phone, a tablet or a computer to connect to the robot's WiFi and then you need to open a browser and insert the address <code>192.168.1.1</code>. The available networks are scanned automatically and listed in the browser page as shown in ''figure 1''. Choose the WiFi signal you want the robot to establish a conection with from the web generated list, and enter the related password; if the password is correct you'll get a message saying that the connection is established as shown in ''figure 2''. After pressing <code>OK</code> you will be redirected to the main page showing the network to which you're connected and the others available nearby as shown in ''figure 3''. If you press on the connected network, then you can see your IP address as shown in ''figure 4''; take note of the address since it will be needed later.<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/esp32-wifi-setup1.png <img width=150 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup1.png">]</td>
<td>[http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup2.png <img width=150 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup2.png">]</td>
<td>[http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup3.png <img width=150 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup3.png">]</td>
<td>[http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup4.png <img width=150 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup4.png">]</td>
</tr>
</table>
</span><br/>
Now the configuration is saved in flash, this means that when the robot is turned on it will read this configuration and try to establish a connection automatically.<br/>
Remember that you need to power cycle the robot at least once for the new configuration to be active.<br/>
 
Once the connection is established, the LED2 will be green.<br/>
 
In order to reset the current configuration you need to press the user button for 2 seconds (the LED2 red will turn on), then you need to power cycle the robot to enter ''access point mode''.
 
==Receiving the image==
Run the pc application and insert the IP address of the robot. Click on <code>Connect</code> to start receiving the image. The LED2 blue will toggle.<br/>
 
Often the IP address assigned to the robot will remain the same when connecting to the same network, so if you took note of the IP address in section [http://www.gctronic.com/doc/index.php?title=e-puck2#Network_configuration Network configuration] probably you're ready to go. <br/>
Otherwise you need to connect the robot to the computer with the USB cable and open the port labeled <code>Serial Monitor</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]). Then power cycle the robot and the IP address will be shown in the terminal (together with others informations), as illustrated in the following figure:<br/>
<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup5.png <img width=500 src="http://projects.gctronic.com/epuck2/wiki_images/esp32-wifi-setup5.png">]</span>
 
=Configuring the PATH variable=
The PATH variable is a environment variable used to store a list of the paths to the folders containing the executables we can run in a terminal with Windows, Mac and Linux.
 
If you want to use the arm-none-eabi toolchain provided inside the Eclipse_e-puck2 package, you have to add it to the PATH variable to be able to call it inside a terminal window.
 
Setting the PATH variable for Windows :
<pre>set PATH=your_installation_path\Eclipse_e-puck2\Tools\gcc-arm-none-eabi-7-2017-q4-major-win32\bin;%PATH%</pre>
Setting the PATH variable for Linux :
<pre>export PATH=your_installation_path/Eclipse_e-puck2/Tools/gcc-arm-none-eabi-7-2017-q4-major/bin:$PATH</pre>
Setting the PATH variable for Mac :
<pre>export PATH=your_installation_path/Eclipse_e-puck2.app/Contents/Eclipse_e-puck2/Tools/gcc-arm-none-eabi-7-2017-q4-major/bin:$PATH</pre>
 
What is important to know is that this procedure is temporary. It applies only to the terminal window used to type it. If you open a new terminal window or close this one, you will have to set again the PATH variable.
 
Note : The arm-none-eabi version can differ from the one given in this example. It could be needed to adapt the path to the correct version.
 
 
=Communication protocol=
This section is the hardest part to understand. It outlines all the details about the communication protocols that you'll need to implement in order to communicate with the robot form the computer. So spend a bit of time reading and re-reading this section in order to grasp completely all the details.
 
==Bluetooth and USB==
 
 
==WiFi==
The communication is based on TCP; the robot create a TCP server and wait for a connection.<br/>
 
Each packet is identified by an ID (1 byte). The following IDs are used to send data from the robot to the computer:
* 0x00 = reserved
* 0x01 = QQVGA color image packet (only the first segment includes this id); packet size (without id) = 38400 bytes; image format = RGB565
* 0x02 = sensors packet; packet size (without id) = 104 bytes; the format of the returned values are based on the [http://www.gctronic.com/doc/index.php/Advanced_sercom_protocol asercom protocol] and are compatible with e-puck1.x:
 
:<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/packet-format-robot-to-pc.jpg <img width=1150 src="http://projects.gctronic.com/epuck2/wiki_images/packet-format-robot-to-pc.jpg">]</span><br/>
:*Acc: raw axes values, between -1500 and 1500, resolution is +-2g
:*Acceleration: acceleration magnitude <img width=70 src="http://projects.gctronic.com/epuck2/wiki_images/3dvector-magnitude.png">, between 0.0 and about 2600.0 (~3.46 g)
:*Orientation: between 0.0 and 360.0 degrees <table><tr><td align="center">0.0 deg</td><td align="center">90.0 deg</td><td align="center">180 deg</td><td align="center">270 deg</td></tr><tr><td><img width=80 src="http://projects.gctronic.com/epuck2/wiki_images/orientation0.png"></td><td><img width=80 src="http://projects.gctronic.com/epuck2/wiki_images/orientation90.png"></td><td><img width=80 src="http://projects.gctronic.com/epuck2/wiki_images/orientation180.png"></td><td><img width=80 src="http://projects.gctronic.com/epuck2/wiki_images/orientation270.png"></td></tr></table>
 
:*Inclination: between 0.0 and 90.0 degrees (when tilted in any direction)<table><tr><td align="center">0.0 deg</td><td align="center">90.0 deg</td></tr><tr><td><img width=80 src="http://projects.gctronic.com/epuck2/wiki_images/inclination0.png"></td><td><img width=80 src="http://projects.gctronic.com/epuck2/wiki_images/inclination90.png"></td></tr></table>
:*Gyro: raw axes values, between -32768 and 32767, range is +-250dps
:*Magnetometer: raw axes values, between -32760 and 32760, range is +-4912 uT (magnetic flux density expressed in micro Tesla)
:*Temp: temperature given in Celsius degrees
:*IR proximity: between 0 (no objects detected) and 4095 (object near the sensor)
:*IR ambient: between 0 (strong light) and 4095 (dark)
:*ToF distance: distance given in millimeters
:*Mic volume: between 0 and 4095
:*Motors steps: 1000 steps per wheel revolution
:*Battery:
:*uSD state: 1 if the micro sd is present and can be read/write, 0 otherwise
:*TV remote data: RC5 protocol
:*Selector position: between 0 and 15
:*Ground proximity: between 0 (no surface at all or not reflective surface e.g. black) and 1023 (very reflective surface e.g. white)
:*Ground ambient: between 0 (strong light) and 1023 (dark)
:*Button state: 1 button pressed, 0 button released
* 0x03 = empty packet (only id is sent); this is used as an acknowledgment for the commands packet when no sensors and no image is requested
The following IDs are used to send data from the computer to the robot:
* 0x80 = commands packet; packet size (without id) = 20 bytes:
 
:<span class="plain links">[http://projects.gctronic.com/epuck2/wiki_images/packet-format-pc-to-robot.jpg <img width=600 src="http://projects.gctronic.com/epuck2/wiki_images/packet-format-pc-to-robot.jpg">]</span><br/>
 
:*request:
:** bit0: 0=stop image stream; 1=start image stream
:** bit1: 0=stop sensors stream; 1=start sensors stream
:*settings:
:** bit0: 1=calibrate IR proximity sensors
:** bit1: 0=disable onboard obstacle avoidance; 1=enable onboard obstacle avoidance (not implemented yet)
:** bit2: 0=set motors speed; 1=set motors steps (position)
:*left and right: when bit2 of <code>settings</code> field is <code>0</code>, then this is the desired motors speed (-1000..1000); when <code>1</code> then this is the value that will be set as motors position (steps)
:*LEDs: 0=off; 1=on; 2=toggle
:** bit0: 0=LED1 off; 1=LED1 on
:** bit1: 0=LED3 off; 1=LED3 on
:** bit2: 0=LED5 off; 1=LED5 on
:** bit3: 0=LED7 off; 1=LED7 on
:** bit4: 0=body LED off; 1=body LED on
:** bit5: 0=front LED off; 1=front LED on
:*RGB LEDs: for each LED, it is specified in sequence the value of red, green and blue (0...100)
:* sound id: 0x01=MARIO, 0x02=UNDERWOLRD, 0x04=STARWARS, 0x08=4KHz, 0x10=10KHz, 0x20=stop sound
 
For example to receive the camera image (stream) the following steps need to be followed:<br/>
1) connect to the robot through TCP<br/>
2) send the command packet:
:{| border="1"
|0x80
|0x01
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|0x00
|}
3) read the ID (1 byte) and the QQVGA color image pakcet (38400 bytes)<br/>
4) go to step 3
 
=Webots=
TBD
 
=ROS=
TBD

Latest revision as of 12:36, 27 January 2023

Features

  • compatible with Android phones (USB communication) and iPhone (sound cable)
  • telepresence (with Skype and robot remote control)
  • avoid obstacles
  • doesn't fall from table
  • runs on carpet
  • docking station
  • charges phone
  • available examples (apps) source code

For more technical specifications refer to the page Wheelphone technical specifications

Getting started

Informations on how to start playing with the Wheelphone robot can be found in the following page Getting started.

Software

You can find the software related to the Android platform on the following page Android software.
You can find the software related to the iPhone platform on the follwing page iPhone software.

Media

You can find images of the Wheelphone in the following page: Wheelphone images.
You can find various videos of the Wheelphone in the following page: Wheelphone videos.

Hands-on

If you're interested in doing some mechanical experiments to play with the Wheelphone robot visit the section Hands-on.