kh3.c File Reference

This file implements an interactive shell to issue movement commands to the robot. More...

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include "kh3moves.h"

Include dependency graph for kh3.c:

Go to the source code of this file.

Functions

int cmdQuit (int argc, char *argv[], void *data)
 Called if user wants to exit this programm at all.
int cmdHelp (int argc, char *argv[], void *data)
 Prints some help for the user.
int cmdDummy (int argc, char *argv[], void *data)
 Placeholder for functions which have not yet been implemented.
int cmdTest (int argc, char *argv[], void *data)
int cmdMotInfo (int argc, char *argv[], void *data)
 Print information about left or right motor.
int cmdForw (int argc, char *argv[], void *data)
 Move the robot forward.
int cmdBack (int argc, char *argv[], void *data)
 Move the robot backward.
int cmdStop (int argc, char *argv[], void *data)
 Stop the motors.
void forceStop (int signal)
 Stop the motors and exit.
int cmdReset (int argc, char *argv[], void *data)
 Resets both motors (initializes them).
int cmdSpeed (int argc, char *argv[], void *data)
 Set constant speed for motors.
int cmdLeft (int argc, char *argv[], void *data)
 Turn robot to the left, around its centre.
int cmdRight (int argc, char *argv[], void *data)
 Turn robot to the right, around its centre.
int cmdArcLeft (int argc, char *argv[], void *data)
 Let the robot walk on a left arc.
int cmdArcRight (int argc, char *argv[], void *data)
 Let the robot walk on a right arc.
int main (int argc, char *argv[])

Variables

knet_dev_t * dsPic
 Khepera's status information device.
knet_dev_t * lMot
 Khepera's left motor.
knet_dev_t * rMot
 Khepera's right motor.
char quitReq = 0
 program ends, if this is set to 1
static kb_command_t commands []
 This defines valid commands, minimal and maximal number of parameters, and a function pointer.


Detailed Description

This file implements an interactive shell to issue movement commands to the robot.

It exists merely for debuging and testing

Version:
Id
kh3.c,v 1.6 2008/09/18 12:59:02 prokop Exp

Definition in file kh3.c.


Function Documentation

int cmdArcLeft ( int  argc,
char *  argv[],
void *  data 
)

Let the robot walk on a left arc.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure This function needs two parameters: 1. the angle to walk (in degree); 2. distance from robot's centre to the arc's centre (in mm, special value "O" [oh] to walk an arc around the inner wheel);

Definition at line 298 of file kh3.c.

int cmdArcRight ( int  argc,
char *  argv[],
void *  data 
)

Let the robot walk on a right arc.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure This function needs two parameters: 1. the angle to walk (in degree); 2. distance from robot's centre to the arc's centre (in mm, special value "O" [oh] to walk an arc around the inner wheel);

Definition at line 311 of file kh3.c.

int cmdBack ( int  argc,
char *  argv[],
void *  data 
)

Move the robot backward.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure This function accepts one or two parameters, which are the relative position in millimeters
back { left_and_right_pos | left_pos right_pos }

positions can be negative, in which case this function would be identical to "forw".

Definition at line 192 of file kh3.c.

int cmdDummy ( int  argc,
char *  argv[],
void *  data 
)

Placeholder for functions which have not yet been implemented.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success (that would be always)

Definition at line 115 of file kh3.c.

int cmdForw ( int  argc,
char *  argv[],
void *  data 
)

Move the robot forward.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure This function accepts one or two parameters, which are the relative position in millimeters
forw { left_and_right_pos | left_pos right_pos }

positions can be negative, in which case this function would be identical to "back".

Definition at line 166 of file kh3.c.

int cmdHelp ( int  argc,
char *  argv[],
void *  data 
)

Prints some help for the user.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success (that would be always)

Definition at line 61 of file kh3.c.

int cmdLeft ( int  argc,
char *  argv[],
void *  data 
)

Turn robot to the left, around its centre.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure This function accepts one paramter - the angle of the rotation

Definition at line 264 of file kh3.c.

int cmdMotInfo ( int  argc,
char *  argv[],
void *  data 
)

Print information about left or right motor.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
1 on success, 0 on failure (e.g. uninitialized motor) Possible parameters are "l" for left motor and "r" for right motor. motInfo [l] [r]

Definition at line 131 of file kh3.c.

int cmdQuit ( int  argc,
char *  argv[],
void *  data 
)

Called if user wants to exit this programm at all.

It stops both motors and sets the exit variable

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
-1 if motors were uninitialized (and could not be stopped), 0 on success

Definition at line 49 of file kh3.c.

int cmdReset ( int  argc,
char *  argv[],
void *  data 
)

Resets both motors (initializes them).

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure

Definition at line 234 of file kh3.c.

int cmdRight ( int  argc,
char *  argv[],
void *  data 
)

Turn robot to the right, around its centre.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure This function accepts one paramter - the angle of the rotation

Definition at line 280 of file kh3.c.

int cmdSpeed ( int  argc,
char *  argv[],
void *  data 
)

Set constant speed for motors.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure Speed is specified in millimeters pers second.

Definition at line 245 of file kh3.c.

int cmdStop ( int  argc,
char *  argv[],
void *  data 
)

Stop the motors.

Parameters:
argc length of argument vector
argv argument vector
data additional data (you specify it)
Returns:
0 on success, -1 on failure This function ignores all parameters.

Definition at line 212 of file kh3.c.

int cmdTest ( int  argc,
char *  argv[],
void *  data 
)

Definition at line 120 of file kh3.c.

void forceStop ( int  signal  ) 

Stop the motors and exit.

This is the callback function for signals received by the program (for example Ctrl-C = SIGINT). Right now we exit on every signal.

Parameters:
signal Signal which we receive, SIGsomething This function ignores all parameters.

Definition at line 222 of file kh3.c.

int main ( int  argc,
char *  argv[] 
)

Definition at line 344 of file kh3.c.


Variable Documentation

kb_command_t commands[] [static]

Initial value:

 {
        { "quit",     0, 0,  cmdQuit },
        { "exit",     0, 0,  cmdQuit },
        { "bye",      0, 0,  cmdQuit },
        { "q",        0, 0,  cmdQuit },
        { "help",     0, 0,  cmdHelp },
        { "forw",     1, 2,  cmdForw },
        { "back",     1, 2,  cmdBack },
        { "left",     1, 1,  cmdLeft },
        { "right",    1, 1,  cmdRight },
        { "stop",     0, 0,  cmdStop },
        { "s",        0, 0,  cmdStop },
        { "rst",      0, 0,  cmdReset },
        { "speed",    1, 2,  cmdSpeed },
        { "sp",       1, 2,  cmdSpeed },
        { "arcleft",  1, 2,  cmdArcLeft },
        { "arcright", 1, 2,  cmdArcRight },
        { "motinfo",  0, 2,  cmdMotInfo },
        { "info",     0, 2,  cmdMotInfo },
        { "i",        0, 2,  cmdMotInfo },
        { "test",     0, 10, cmdTest },
        { NULL,       0, 0,  NULL }
}
This defines valid commands, minimal and maximal number of parameters, and a function pointer.

Definition at line 320 of file kh3.c.

knet_dev_t* dsPic

Khepera's status information device.

Khepera status device.

Definition at line 58 of file kh3moves.c.

knet_dev_t* lMot

Khepera's left motor.

Definition at line 60 of file kh3moves.c.

char quitReq = 0

program ends, if this is set to 1

Definition at line 40 of file kh3.c.

knet_dev_t* rMot

Khepera's right motor.

Definition at line 62 of file kh3moves.c.


Generated on Sun Sep 28 21:20:01 2008 for Guard by  doxygen 1.5.6