toddler.pyand start the Sandbox.
toddlercode is executed.
Each Raspberry Pi has been assigned a unique hostname. We decided to name them after Digimons and Pokemons. Therefore, as part of your kit, you should have a Raspberry Pi labeled with one of the following identifiers:
Agumon, Armadillomon, Biyomon, Gabumon, Gatomon, Gomamon, Hawkmon, Meicoomon, Palmon, Patamon, Tentomon, Veemon, Wormmon.
Bulbasaur, Caterpie, Charmander, Clefairy, Diglett, Jigglypuff, Meowth, Pikachu, Psyduck, Rattata, Squirtle.
When the Raspberry Pi is powered it will boot-up automatically. The full boot-up sequence takes few seconds, so remember to wait for a short interval before attempting to login to the module. The system will automatically connect to the room's WiFi and be accessible by the DICE machines on the network.
Now you're ready to login to your module.
Bring up a terminal window on a DICE machine and use the SSH command to connect to the module.
The name of your module will be printed on its top side, for example if the module on your desk is named Panda.
So to login to Panda as student you would type
ssh -XC student@Panda.
Remember to add the
-XC option so that you can later start graphical text editor and debug your image processing remotely.
After typing this command you will be asked for a password. The password is
If all that went well you are now able to login to the module.
You should store all your programs in /home/student/ directory.
To log out type exit.
If you want to reboot or turn off the Raspberry use
sudo reboot and
Always turn off the Raspberry using
sudo poweroff, otherwise you may cause damage to the SD card and loose your work.
Step by Step:
password(example for brain brick named Panda):
ssh -XC student@Panda.
sandboxcommand on the Raspberry (good for debugging) or by shortly pressing the connected button.
The sandbox environment is a python program that allows you to develop and run python programs for the Raspberry Pi. The Sandbox handles reading sensors, controlling DC motors and the servo, capturing images from the camera, handling, reporting and logging errors, and launching from the Raspberry.
The sandbox consist of three python source files located in
The sandbox can be launched by shortly pressing the button connected to the Raspberry. Pressing the button will either start the sandbox or kill all sandbox processes if there are any running. Use the button to start/stop your program during experiments.
The sandbox can also be launched from SSH with the alias commamd:
This command will start the Sandbox and print the output of the program into the SSH terminal
and also display any graphical windows you may have created (e.g. imshow()).
The program will initialize the IO tools (implemented in iotools.py), start logging, and attempt to import a user program from toddler.py.
When running the Sandbox on DICE or on your own machine, the standard and error output will be displayed in the terminal window.
However, when you run the Sandbox on the Raspberry, the output streams will be piped into /dev/null to prevent the output from blocking your SSH connection.
A copy of these streams will also be saved into a text file:
Note that the directory
/tmp/sandbox/ needs to be created for the log to be generated.
Any print command or error text will be appended to the end of this file. You can SSH into the Raspberry and retrieve this file. The log file is only temporary and will only exist as long as your robot stays powered. Do not disconnect/turn off your Raspberry if you want to retrieve the log file later.
You can up/down-loading files to/from the Raspberry via a FTP tool. To do this, you will need:
To upload files via FTP, use the FTP tool of your choosing, specify <host_name>.inf.ed.ac.uk as the server, and student and password as user name and password. This will allow you to modify file in the home directory. You can put the toddler.py in here.
ssh -XC student@<host_name>
Replacing <host_name> with the host name of your Raspberry. The -XC argument is to allow forwarding of graphical windows (e.g. imshow()). You can now run all the command available on the Raspberry, e.g. sandbox, cp, mv, ...
To use the supervisor script, you should have a button connected directly to the GPIO (General Purpose Input Output) pin 21 of the Raspberry Pi inside the lego case. Normally, this should already be the done for you.
The supervisor is a script automatically launch by the system when the Raspberry is powered up.
It is meant to be use with an external button to start and stop your behaviour (
in a more "autonomous" way, without the need for any SSH connection.
With the button:
toddler.pyscript or stop all curently running behaviours. Without SSH, the printing outputs are written in a log file located at