Khepera II

Software

GNU C Environment and KTProject


GNU C Cross Compiler

The GNU C cross-compiler lets you generate code that can be executed directly on-board the Khepera and Koala, freeing you from the constraints of the ASCII protocol and serial cables.

The cross-compiler package provides a library of all the low-level functions available in the K-Team BIOS including motor control, sensor reading, communication, and multi-tasking management.

In addition libraries are provided for all the K-Team extension turrets, letting you control all your favorite turrets like the gripper, radio, etc.

The cross-compiler provides a full C programming environment, and lets you create programs as simple or as powerful as you wish.

Here is a simple example to create a Braitenberg vehicle, by reading the sensors, calculating appropriate speeds, and then issuing the commands to the motors to control the robot:

/* K-Team Braitenberg demo for Khepera   copyright Skye Legon, K-Team SA, 2001 */
#include 
#include 



int main(){
	int i, sensor[6], delta, speed[2];
	printf("  S0   S1   S2   S3   S4   S5 Delta   L   R  ");
	while (TRUE)  {
	/* read front 6 sensors */
	for (i=0; i<6; i++)    {
	sensor[i] = sens_get_reflected_value(i);
	printf("%4d ", sensor[i]);
	}
	/* calculate speed adjustments based on sensors */
	delta = 0;
	for (i=0; i<3; i++)
	  delta += sensor[i];
	for (i=3; i<6; i++)
	  delta -= sensor[i];
	delta = delta/50;
	printf("%5d ", delta);
	/* set motor speeds (right, left) */
	speed[0] = 20 + delta;
	speed[1] = 20 - delta;
	printf("%3d %3d  ", speed[0], speed[1]);
	mot_new_speed_2m(speed[1], speed[0]);
	}
return 0;
}

This program can now be compiled for the Khepera or Koala processors, transformed into Motorola S format, downloaded to the robot using a terminal program, and then executed. This approach allows for fast, self-contained code running on-board the robot, but has a slight disadvantage for development in that there is no debugger, and every modification requires repeating this compile and download process. We therefore recommend the cross-compiler for advanced users, while beginners may find the SerCom protocol easier to use and to debug.

KTProject

To ease use of the GNU C compiler under Windows, we propose KTProject, a graphical C development environment for Windows. With KTProject you can develop C code for Khepera, Koala and Kameleon from a graphical interface instead of a big, scary command prompt.

KTProject includes the GNU C compiler, the Cygwin Environment (copyright RedHat Inc.), Source Navigator (copyright RedHat Inc.) and KTDebug, a serial port terminal written in Java (copyright J-M Koller).

KTProject is still in beta, but can be downloaded for free here (24Mb, Windows 95/98/M/NT/XP, Self Executable). This is the complete package and does not require anything else to run. Any comments you may have to help us improve KTProject are welcome!

Source code for the KTProject launcher is written in Borland C++ Builder 3.0 (click here to download it).