Koa-PicoITX User Manual rev 1.0
16
4.1.2 Using examples
You can find many examples using the libkorebot in the directory of the library:
~/software/libkorebot_VERSION/src/tests
All the examples below are already compiled. You can modify them or take some part to
add to your main program. For recompiling them, in the directory
~/software/libkorebot_VERSION, execute:
make clean
make all
You can execute them with the command:
./PROGRAM_NAME
Here after is the list of examples of source code recommended for starting programming with
the Koa-PicoITX and its extensions:
••••
Make the Koala move: koala_test.c
Here after are desribed the steps to program the robot. The source code is listed in
figure 4.1 below.
-
Firstly, a device pointer of type
knet_dev_t
must be declared.
-
The library debug level is set
kb_set_debug_level
and the library
initialised
kb_init
.
-
Then the device is open with
knet_open
.
-
From now, any command can be sent to the Koala. By example
koa_setSpeed
for setting the speed of the robot, which will make it move
directly. Some main functions are listed below:
§
setting speed:
int koa_setSpeed (
knet_dev_t
* dev, short int left, short int
right )
§
setting motors position:
int koa_setPosition(
knet_dev_t
* dev, long left_pos, long
right_pos)
§
reading motors position:
int koa_readPosition(
knet_dev_t
* dev, int * position)
§
reading proximity sensors:
int koa_readProximity (
knet_dev_t
* dev, int * sens_table )
§
reading battery level:
int koa_readBattery(
knet_dev_t
* dev)
§
and many others. For a detailed description check in the file
~/software/libkorebot_VERSION/src/koala.c.
-
at the end the
kb_config_exit
function is called.