How to connect to the robots via bluetooth and upload a file
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.