brain.c File Reference

This file implements brain definitions. More...

#include "brain.h"
#include "kh3moves.h"
#include "logger.h"
#include "guardmodes.h"
#include "netfunctions.h"
#include "sensorwatcher.h"
#include "blobtracker.h"
#include "scheduler.h"

Include dependency graph for brain.c:

Go to the source code of this file.

Data Structures

struct  commands_s
 Definition of possible commands robots can send to each other. More...

Functions

char onMark (char inverseBottomMarkings)
 Reads the bottom sensors and tells if we are over a mark or not.
int sendCommand (char command)
 Sends a command to the other robot.
int reconnect (void)
 Reconnects on broken TCP connection.
void closeConnections (void)
int performBottomMarkDetection (char inversBottomMarkings)
 Capsules bottom mark detection.
void * brain (void *arg)
 This thread is responsible for detecting markings on the ground.

Variables

knet_dev_t * dsPic
 Khepera's status information device.
char guardMode
 The guard's mode: running or watching.
char guardSide
 Tells if the guard is running along the left or right wall.
WINDOW * bLogWindow = NULL
 ncurses window, where the logging output will go to.
char brainQuitReq = 0
 Set to 1 to end the thread.
char markDetected = 0
 Will be set to 1 if a mark is detected.
char guardNetMode = GUARD_MODE_UNDEF
 Network mode of this guard - is it a client or server? For possible values see Robots' Network Modes.
char * partnerName = DEFAULT_PARTNER_NAME
char * scheduleFileName = DEFAULT_SCHEDULE_FILE_NAME
int servSock = -1
 Server socket.
int partner = -1
 Connection socket to our partner.
short blackMarkTresh = 2900
 Invensity treshhold for black markings (in sensor values).
short whiteMarkTresh = 2500
 Invensity treshhold for white markings (in sensor values).
struct commands_s commands
 Definition of possible commands robots can send to each other.


Detailed Description

This file implements brain definitions.

It is intended to be run as a thread.

Version:
Id
brain.c,v 1.24 2008/09/18 12:59:01 prokop Exp

Definition in file brain.c.


Function Documentation

void* brain ( void *  arg  ) 

This thread is responsible for detecting markings on the ground.

Each mark could mean a vertex of our polygon. It will set the variable markDetected once for every marking it just encountered and will not set it again unless the robot has left the marked area.

Parameters:
arg Arguments for this thread. Currently unused.

Definition at line 277 of file brain.c.

void closeConnections ( void   ) 

Definition at line 233 of file brain.c.

char onMark ( char  inverseBottomMarkings  ) 

Reads the bottom sensors and tells if we are over a mark or not.

Returns:
1 if over a mark, 0 otherwise

Definition at line 80 of file brain.c.

int performBottomMarkDetection ( char  inversBottomMarkings  )  [inline]

Capsules bottom mark detection.

Returns:
1 if a new mark was detected, 0 otherwise.

Definition at line 246 of file brain.c.

int reconnect ( void   ) 

Reconnects on broken TCP connection.

The reconnection method will block until a connection has been established or brainQuitReq has been set.

Returns:
1 on success or 0 if no connection could be established before the quit requst.

Definition at line 127 of file brain.c.

int sendCommand ( char  command  ) 

Sends a command to the other robot.

If the command cannot be send this function will try to reconnect until it succeeds or brainQuitReq is set - in other words it will block.

Parameters:
command one byte command to send to the other robot
Returns:
1 on success or 0 on failure.

Definition at line 110 of file brain.c.


Variable Documentation

short blackMarkTresh = 2900

Invensity treshhold for black markings (in sensor values).

Definition at line 65 of file brain.c.

WINDOW* bLogWindow = NULL

ncurses window, where the logging output will go to.

Definition at line 44 of file brain.c.

char brainQuitReq = 0

Set to 1 to end the thread.

Definition at line 46 of file brain.c.

Definition of possible commands robots can send to each other.

knet_dev_t* dsPic

Khepera's status information device.

See also:
kh3moves.c */
Khepera status device.

Definition at line 58 of file kh3moves.c.

char guardMode

The guard's mode: running or watching.

See also:
guard.c
See Possible Guard Modes

Definition at line 136 of file guard.c.

char guardNetMode = GUARD_MODE_UNDEF

Network mode of this guard - is it a client or server? For possible values see Robots' Network Modes.

Definition at line 51 of file brain.c.

char guardSide

Tells if the guard is running along the left or right wall.

See also:
guard.c
See Guard's side

Definition at line 140 of file guard.c.

char markDetected = 0

Will be set to 1 if a mark is detected.

Must be externally reset to 0 after the "mark event" has been proceeded. The markDetector will not set this variable unless the robot has left the last marking

Definition at line 47 of file brain.c.

int partner = -1

Connection socket to our partner.

Definition at line 62 of file brain.c.

char* partnerName = DEFAULT_PARTNER_NAME

Definition at line 53 of file brain.c.

char* scheduleFileName = DEFAULT_SCHEDULE_FILE_NAME

Definition at line 54 of file brain.c.

int servSock = -1

Server socket.

Definition at line 60 of file brain.c.

short whiteMarkTresh = 2500

Invensity treshhold for white markings (in sensor values).

Definition at line 67 of file brain.c.


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