Difference between revisions of "Getting Started: How to work with kilobots"

From Kilobots
Jump to: navigation, search
Line 45: Line 45:
  
 
: on Mac OSX:
 
: on Mac OSX:
<pre>
+
: <pre>
 
   brew tap larsimmisch/avr  
 
   brew tap larsimmisch/avr  
 
   brew install avr-libc
 
   brew install avr-libc
 
   brew install avrdude --with-usb
 
   brew install avrdude --with-usb
</pre>
+
</pre>
  
in case the tap larsimmisch/avr does not work, you can try with this:
+
: in case the tap larsimmisch/avr does not work, you can try with this:
  
<pre>
+
: <pre>
 
brew tap osx-cross/avr
 
brew tap osx-cross/avr
 
brew install avr-libc
 
brew install avr-libc
Line 63: Line 63:
 
make blank
 
make blank
 
</pre>
 
</pre>
 
 
You will find the compiled control software as a <tt>hex</tt> file in the directory <tt>build/</tt>
 
You will find the compiled control software as a <tt>hex</tt> file in the directory <tt>build/</tt>
 
<br/>
 
<br/>
 
Then, edit the <tt>Makefile</tt> to compile your own code.
 
Then, edit the <tt>Makefile</tt> to compile your own code.
 +
 +
Alternatively, you can download and compile another example using the template code available here ([[Media:TemplateForCompilingKilobotCode.zip|Template code]])
 +
<br/>
 +
Download the code and execute:
 +
<pre>
 +
cd <path-to-the-template-code-dir>
 +
./compileCode.sh test
 +
</pre>
 +
You will find the compiled control software as a <tt>hex</tt> file in the directory <tt>build/</tt>
 +
<br/>
 +
Then, run the script the <tt>./compileCode.sh</tt> with your filename to compile your own code.

Revision as of 16:44, 15 December 2017

The following instructions to operate with the kilobots require the firmware 2.0 installed on both the Overhead Controller (see OHC Firmware) and on the kilobots (see Kilobot Firmware).

KiloGUI

To operate with the kilobots, we recommend the use of the KiloGUI software.
The KiloGUI can be downloaded from GitHub here: https://github.com/acornejo/kilogui
A complete documentation about its functioning can be found on the kilobotics website: https://www.kilobotics.com/documentation
On Linux, run kilogui with sudo privileges.

Upload your first control software on a kilobot

Try to upload a test control software on kilobots following these steps:

  • download the file: blank.hex
  • run kiloGui
  • select as Program file the file you just downloaded
  • turn on the kilobot by adding the power jumper (see Figure), and place it under the IR communication cone of the OHC (see Figure).
  • click on Bootload button (and the kilobot must switch on the blue LED immediately)
  • when the blue LED is on, click on Upload and wait some seconds (the kilobot's LED should blink at high frequency)
  • when the kilobot stops blinking, try to run the program on kilobot, by clicking the button Run
  • the expected behaviour is the robot keeping blinking in alternate colours red and green. Have fun! :-)
WARNING:
Do not upload on kilobots files downloaded from this page:
https://github.com/SSR-Harvard/kilobotics-labs/tree/master/hex_files
They are not compatible with the current firmware 2.0 and will corrupt the kilobot firmware. In case you have done it, the only solution to resurrect the corrupted kilobot is by wire uploading the firmware. If you need to do this, follow the instructions on the page Kilobot Firmware.

Write your own control software

The API documentation of the firmware 2.0 functions is available here: https://www.kilobotics.com/docs/index.html
A good tutorial to learn how to program kilobots can be found here: https://www.kilobotics.com/labs

Compile your own control software

To compile the control software for the kilobot, use the kilolib that you can download from GitHub here: https://github.com/acornejo/kilolib
Needed dependencies are avr-libc, gcc-avr, avrdude:

on Ubuntu:
sudo apt-get install avr-libc gcc-avr avrdude
on Mac OSX:
brew tap larsimmisch/avr brew install avr-libc brew install avrdude --with-usb
in case the tap larsimmisch/avr does not work, you can try with this:

brew tap osx-cross/avr brew install avr-libc

Begin with a test by compiling the blank.c file, executing the command:

cd <path-to-the-kilolib-dir>
make blank

You will find the compiled control software as a hex file in the directory build/
Then, edit the Makefile to compile your own code.

Alternatively, you can download and compile another example using the template code available here (Template code)
Download the code and execute:

cd <path-to-the-template-code-dir>
./compileCode.sh test

You will find the compiled control software as a hex file in the directory build/
Then, run the script the ./compileCode.sh with your filename to compile your own code.