Difference between revisions of "How to connect to the robots via bluetooth and upload a file"

From IridiaWiki
Jump to navigationJump to search
(New page: Download the files from the SVN repository then follow this instructions ==== Bluetooth Configuration ==== * bluetooth/rfcomm.conf has to be copied in /etc/bluetooth * bluetooth/password...)
 
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Download the files from the SVN repository then follow this instructions
+
Download the files from the SVN repository ([[Get all the files you need]]) then follow this instructions
   
 
==== Bluetooth Configuration ====
 
==== Bluetooth Configuration ====
   
* bluetooth/rfcomm.conf has to be copied in /etc/bluetooth
+
* bluetooth/rfcomm.conf must be copied in /etc/bluetooth
* bluetooth/passwords/ has to be copied in /etc/bluetooth
+
* bluetooth/passwords/ must be copied in /etc/bluetooth
* bluetooth/90-local.rules has to be copied in /etc/udev/rules.d/
+
* bluetooth/90-local.rules must be copied in /etc/udev/rules.d/
   
now you have to restart the services
+
now you have to restart the relevant services. On Ubuntu, type:
 
sudo /etc/init.d/bluetooth stop
 
sudo /etc/init.d/bluetooth stop
sudo /etc/init.d/udev restart (or sudo restart udev)
+
sudo /etc/init.d/udev restart
 
sudo /etc/init.d/bluetooth start
 
sudo /etc/init.d/bluetooth start
   
check if in /dev/ there are some files called rfcomm**, if not do:
+
check if in /dev/ there are some files called rfcomm??, typing:
  +
ls /dev/rfcomm*
  +
  +
If you don't see them, type:
 
sudo rfcomm bind all
 
sudo rfcomm bind all
   
you should now have all the necessary files to connect to the robots.
+
you now have all the necessary files to connect to the robots.
   
   
NOTE:
+
NOTE:
The above files have been created by us and are not complete. This means that if you want to use an e-puck that is not in the list you should add it.
+
The bluetooth configuration files were created by us on the basis of the robots we used. It is possible that not all the e-pucks have been added.
  +
If the e-puck you want to use is not listed in those files, you must add it first.
   
To do that you have to first get the MAC address of the epuck you want to add: turn on the selected e-puck and do:
+
To do it, you have to first get the MAC address of the e-puck you want to add. Switch the selected e-puck on and type:
 
hcitool scan
 
hcitool scan
modify rfcomm.conf and 90-local.rules using the existing lines as examples.
 
   
  +
This command prints the information of the bluetooth devices in range. In particular, copy-paste the MAC address of the found e-puck into rfcomm.conf and 90-local.rules using the existing lines as examples.
As a last step you need to add the password file in the passkeys directory. Go in /etc/bluetooth/passwords/ and do (with the correct epuck number and MAC):
 
  +
 
Eventually, you need to add the password file in the passkeys directory. Go to /etc/bluetooth/passwords/ and type (with the correct epuck number NNNN and MM:MM:MM:MM:MM:MM):
  +
echo -n NNNN > MM:MM:MM:MM:MM:MM
  +
  +
for example, for e-puck 1442, the above line would be:
  +
 
echo -n 1442 > 08:00:17:2D:1A:15
 
echo -n 1442 > 08:00:17:2D:1A:15
   
  +
Note that on Ubuntu it is necessary to be root (sudo su) to do this. A simple sudo does not work.
Once you have done this please update the corresponding file in the svn. Eventually we will be able to have the complete list for all the e-pucks (or, at least, the most used ones)
 
  +
It is important that the command is exactly 'echo -n ...'. The '-n' option of echo does not print a newline after the passed text.
  +
In password files the newline must not be there, or they will be (erroneously) treated as part of the password itself.
  +
  +
Once you have changed the files, please update the files in the svn too, so your work will be available to everybody else.
   
 
==== Upload the .hex file ====
 
==== Upload the .hex file ====
   
Once you are able to connect to the robot you have to upload the file to the Epuck.
+
Once you are able to connect to the robot, you have to upload a controller to the e-puck.
   
In epuck-uploader/ there is a script to upload a file to the E-puck. To do it just write:
+
In the epuck-uploader/ directory there is a script to upload a file to the e-puck. Type:
./epuckupload -f filename **
+
./epuckupload -f filename NN
where filename is the name of the file to upload (e.g. epuckaseba.hex) and ** is the number of the robot to update (e.g. 42)
+
where filename is the name of the file to upload (e.g. epuckaseba.hex) and NN is the number of the robot to update (i.e., 42)
   
When a series of dots are printed on the screen press the reset button of the e-puck and the upload should begin (a series of * are printed)
+
As soon as the command is issued, a series of dots appear on the screen. When this happens, press the reset button of the e-puck and the upload will begin.
  +
You know when the actual upload is running because a series of * are printed instead of the dots. Very often, especially when you turn on your computer, the first transfer fails. Try again.
   
Example of a successful upload
+
Example of a successful upload:
./epuckupload -f epuckaseba.hex 42
+
epuckupload -f epuckaseba.hex 42
 
[18:32:43] Reading file epuckaseba.hex
 
[18:32:43] Reading file epuckaseba.hex
 
[18:32:43] [/dev/rfcomm42] Connecting to /dev/rfcomm42 (robot ID 42)
 
[18:32:43] [/dev/rfcomm42] Connecting to /dev/rfcomm42 (robot ID 42)
 
[18:32:45] [/dev/rfcomm42] Uploading epuckaseba.hex
 
[18:32:45] [/dev/rfcomm42] Uploading epuckaseba.hex
R.......*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
+
R.......******************************************************************************
  +
**************************************************************************************
  +
**************************************************************************************
  +
******************************************************************************
  +
 
NOTE: sometimes, if you connect to a robot that your pc has never met, a dialog will pop up and ask for the password. In that case, just write the four digits of the e-puck and it should work. If you don't have a bluetooth manager on your system (or it's not running), you won't be able to connect to new robots. Under KDE systems you have to start the kbluetooth program.
  +
  +
===== Uploading and btcomm =====
  +
  +
Be careful if you are using btcomm to send data from the e-puck to the pc. In fact, if the e-puck is sending data it won't be ready to receive the new software and uploading is prevented. To fix this the best strategy is to wait and hope. If the e-puck is sending data, epuckupload will fail to do its job. However, if you don't stop the communication, after a while epuckupload will stop and restart. Usually this second trial works.
   
  +
To prevent this, always put a "wait for char" instruction before sending data via bluetooth. This stops the e-puck to start automatically and allows you to upload a file. If you want the e-puck to start automatically when turned on just do not communicate with the bluetooth.
NOTE:it seems that the passkeys file are not so useful after all because if you connect to a new robot (one that your pc has never met) a dialog will pop up and ask for the password. In that case just write the four digits of the e-puck and it should work. If you don't have a bluetooth manager on your system (or it's not running) you won't be able to connect to new robots. Under KDE systems you have to start kbluetooth otherwise it does not work.
 

Latest revision as of 11:42, 19 October 2011

Download the files from the SVN repository (Get all the files you need) then follow this instructions

Bluetooth Configuration

  • bluetooth/rfcomm.conf must be copied in /etc/bluetooth
  • bluetooth/passwords/ must be copied in /etc/bluetooth
  • bluetooth/90-local.rules must be copied in /etc/udev/rules.d/

now you have to restart the relevant services. On Ubuntu, type:

sudo /etc/init.d/bluetooth stop
sudo /etc/init.d/udev restart
sudo /etc/init.d/bluetooth start

check if in /dev/ there are some files called rfcomm??, typing:

ls /dev/rfcomm*

If you don't see them, type:

sudo rfcomm bind all

you now have all the necessary files to connect to the robots.


NOTE: The bluetooth configuration files were created by us on the basis of the robots we used. It is possible that not all the e-pucks have been added. If the e-puck you want to use is not listed in those files, you must add it first.

To do it, you have to first get the MAC address of the e-puck you want to add. Switch the selected e-puck on and type:

hcitool scan 

This command prints the information of the bluetooth devices in range. In particular, copy-paste the MAC address of the found e-puck into rfcomm.conf and 90-local.rules using the existing lines as examples.

Eventually, you need to add the password file in the passkeys directory. Go to /etc/bluetooth/passwords/ and type (with the correct epuck number NNNN and MM:MM:MM:MM:MM:MM):

echo -n NNNN > MM:MM:MM:MM:MM:MM

for example, for e-puck 1442, the above line would be:

echo -n 1442 > 08:00:17:2D:1A:15

Note that on Ubuntu it is necessary to be root (sudo su) to do this. A simple sudo does not work. It is important that the command is exactly 'echo -n ...'. The '-n' option of echo does not print a newline after the passed text. In password files the newline must not be there, or they will be (erroneously) treated as part of the password itself.

Once you have changed the files, please update the files in the svn too, so your work will be available to everybody else.

Upload the .hex file

Once you are able to connect to the robot, you have to upload a controller to the e-puck.

In the epuck-uploader/ directory there is a script to upload a file to the e-puck. Type:

./epuckupload -f filename NN

where filename is the name of the file to upload (e.g. epuckaseba.hex) and NN is the number of the robot to update (i.e., 42)

As soon as the command is issued, a series of dots appear on the screen. When this happens, press the reset button of the e-puck and the upload will begin. You know when the actual upload is running because a series of * are printed instead of the dots. Very often, especially when you turn on your computer, the first transfer fails. Try again.

Example of a successful upload:

epuckupload -f epuckaseba.hex 42
[18:32:43] Reading file epuckaseba.hex                                                                      
[18:32:43] [/dev/rfcomm42] Connecting to /dev/rfcomm42 (robot ID 42)                                        
[18:32:45] [/dev/rfcomm42] Uploading epuckaseba.hex                                                         
R.......******************************************************************************
**************************************************************************************
**************************************************************************************
******************************************************************************

NOTE: sometimes, if you connect to a robot that your pc has never met, a dialog will pop up and ask for the password. In that case, just write the four digits of the e-puck and it should work. If you don't have a bluetooth manager on your system (or it's not running), you won't be able to connect to new robots. Under KDE systems you have to start the kbluetooth program.

Uploading and btcomm

Be careful if you are using btcomm to send data from the e-puck to the pc. In fact, if the e-puck is sending data it won't be ready to receive the new software and uploading is prevented. To fix this the best strategy is to wait and hope. If the e-puck is sending data, epuckupload will fail to do its job. However, if you don't stop the communication, after a while epuckupload will stop and restart. Usually this second trial works.

To prevent this, always put a "wait for char" instruction before sending data via bluetooth. This stops the e-puck to start automatically and allows you to upload a file. If you want the e-puck to start automatically when turned on just do not communicate with the bluetooth.