6
KoreBotLE programming
This section explain how to write a simple program for the KoreBotLE to
control the Khepera III base. The Khepera III will act as peripheral of the
KoreBotLE.
Please refer to the KoreBotLE user manual (found on www.k-team.com)
for further details on KoreBotLE programming. This document only pro-
vides a basic example of program compilation and execution.
The first simple executable for KoreBotLE/Khepera III will be built
assuming:
- A working arm-linux toolchain is installed on your host computer.
- The NFS link is active and a shared directory (
mySharedDirectory
) is
mounted on
/mnt/nfs
.
A source file should be first created and edited with a very simple C
program such as the following. People familiar with the KoreMotor will
notice that the code is quite similar. The controlers have been embedded in
the robot but act as two I2C slaves.
/* kh3test.c */
#include <korebot/korebot.h>
static knet_dev_t * mot1;
static knet_dev_t * mot2;
int main()
{
kh3_init();
/* open various socket and store the handle in their respective pointers */
dsPic
= knet_open( "Khepera3:dsPic" , KNET_BUS_I2C , 0 , NULL );
mot1
= knet_open( "Khepera3:mot1" , KNET_BUS_I2C , 0 , NULL );
mot2
= knet_open( "Khepera3:mot2" , KNET_BUS_I2C , 0 , NULL );
/* initialize the motor controler 1 */
kmot_SetMode( mot1 , kMotModeIdle );
kmot_SetSampleTime( mot1 , 1550 );
kmot_SetMargin( mot1 , 6 );
kmot_SetOptions( mot1 , 0x0 , kMotSWOptWindup | kMotSWOptStopMotorBlk
| kMotSWOptDirectionInv );
K-Team S.A.
30