roneos
Operating System for the r-one robot
 All Data Structures Files Functions Variables Typedefs Groups
neighbors.h File Reference

Used to maintain information about network neighbors, sets up data storage, and sets up callbacks. More...

Go to the source code of this file.

Data Structures

struct  NbrData
 Linked list of data on messages. More...
 
struct  NbrMsgRadioNbrData
 The IR message a neighbor has. More...
 
struct  NbrMsgRadio
 Linked list of a neighbor's messages. More...
 
struct  Nbr
 Information stored on a network neighbor. More...
 
struct  NbrDatabase
 Array containing data on all the network neighbors. More...
 
struct  NbrList
 Array containing pointers to all the network neighbors' data. More...
 
struct  IRRangeData
 Data from IR signal. More...
 

Typedefs

typedef struct NbrData NbrData
 Linked list of data on messages.
 
typedef struct NbrMsgRadioNbrData NbrMsgRadioNbrData
 The IR message a neighbor has.
 
typedef struct NbrMsgRadio NbrMsgRadio
 Linked list of a neighbor's messages.
 
typedef struct Nbr Nbr
 Information stored on a network neighbor.
 
typedef struct NbrDatabase NbrDatabase
 Array containing data on all the network neighbors.
 
typedef struct NbrList NbrList
 Array containing pointers to all the network neighbors' data.
 
typedef struct IRRangeData IRRangeData
 Data from IR signal.
 

Functions

void neighborsInit (uint32 neighbor_period)
 Initialize neighbors and start neighbors task. More...
 
void neighborsDisable (void)
 Disable neighbor xmit/recv. More...
 
void neighborsXmitEnable (boolean neighbor_xmit_enable_arg)
 Enable neighbor to transmit messages. More...
 
void neighborsSetPeriod (uint32 neighbor_period_arg)
 Set neighbor period, neighbor timeout, and obstacle timeout proportional to argument. More...
 
void neighborsSetTimeoutRounds (uint8 timeoutRounds, uint8 minActive, uint8 maxInactive)
 Set neighbor period, neighbor timeout, and obstacle timeout proportional to argument. More...
 
uint32 neighborsGetPeriod (void)
 Get neighbor period. More...
 
void neighborsGetMutex (void)
 Get neighbors mutex. More...
 
void neighborsPutMutex (void)
 Put neighbors mutex. More...
 
uint32 neighborsGetRound (void)
 Get neighbor round from neighbor data. More...
 
boolean neighborsNewRoundCheck (uint32 *roundOldPtr)
 Check to see if there is a new neighbor round. Updates the variable at the pointer. More...
 
void neighborsIgnore (uint8 neighborID)
 Tries add neighborID to list of neighbors to ignore. More...
 
uint8 irObstaclesGetBits (void)
 Get IR obstacle bits. More...
 
uint8 * irObstaclesGetRangeBits (void)
 Get IR obstacle range bits. More...
 
uint8 * irObstaclesGetBitMatrix (void)
 Get IR obstacle bit matrix. More...
 
int16 irObstaclesGetBearing (void)
 Get IR obstacle bearing. More...
 
void obstaclePrint (void)
 Print the obstacle data from the IR sensors. More...
 
uint8 nbrGetID (Nbr *nbrPtr)
 Get neighbor ID. More...
 
int32 nbrGetBearing (Nbr *nbrPtr)
 Get neighbor bearing. More...
 
int32 nbrGetOrientation (Nbr *nbrPtr)
 Get neighbor orientation. More...
 
int32 nbrGetRange (Nbr *nbrPtr)
 Get neighbor range. More...
 
boolean nbrGetOrientationValid (Nbr *nbrPtr)
 Get neighbor orientation valid. More...
 
uint8 nbrGetRangeBits (Nbr *nbrPtr)
 Get neighbor range bits. More...
 
uint8 nbrGetReceiverBits (Nbr *nbrPtr)
 Get neighbor receiver bits. More...
 
uint8 nbrGetTransmitterBits (Nbr *nbrPtr)
 Get neighbor transmitter bits. More...
 
uint32 nbrGetUpdateTime (Nbr *nbrPtr)
 Get neighbor update time. More...
 
uint32 nbrGetUpdateRound (Nbr *nbrPtr)
 Get neighbor update round. More...
 
void nbrPrint (Nbr *nbr)
 Print information on neighbor (and information of neighbor's neighbors). More...
 
void nbrPrintData (Nbr *nbr, uint32 round)
 Print header and neighbor data. More...
 
boolean nbrIsRobot (Nbr *nbrPtr)
 Returns true if this neighbor is a beacon. More...
 
boolean nbrIsBeacon (Nbr *nbrPtr)
 Returns true if this neighbor is a beacon. More...
 
void nbrMsgRadioCreate (NbrMsgRadio *nbrMsgRadioPtr, const char *name)
 Create a radio neighbor message. More...
 
void nbrMsgRadioSet (NbrMsgRadio *nbrMsgRadioPtr, char *dataPtr, uint8 length)
 Gets a radio neighbor message. More...
 
NbrMsgRadioNbrDatanbrMsgRadioGetNbr (NbrMsgRadio *nbrMsgRadioPtr, Nbr *nbrPtr)
 Gets a radio neighbor message. More...
 
void nbrMsgRadioPrint (NbrMsgRadio *nbrMsgRadioPtr, Nbr *nbrPtr)
 Prints the message data for the input neighbor. More...
 

Detailed Description

Used to maintain information about network neighbors, sets up data storage, and sets up callbacks.

Initializing neighbors initializes the neighbor period, neighbor timeout, obstacle timeout. Also initializes neighborData, sets the message length, and puts the 7-bit roneID in message. In addition, semaphore implementing neighborsMutex is created.

Since
March 2, 2011
Author
James McLurkin

Function Documentation

int16 irObstaclesGetBearing ( void  )

Get IR obstacle bearing.

This function returns the bearing of an IR obstacle. It looks for contiguous obstacle bits, to select the largest (nearest) obstacle. This could cause dithering for 1-bit sized obstacles.

Returns
the bump sensor bearing. Returns 0 if there is no obstacle.
uint8* irObstaclesGetBitMatrix ( void  )

Get IR obstacle bit matrix.

Returns
IR obstacle bit matrix
uint8 irObstaclesGetBits ( void  )

Get IR obstacle bits.

Returns
IR obstacle bits
uint8* irObstaclesGetRangeBits ( void  )

Get IR obstacle range bits.

Returns
IR obstacle range bits
int32 nbrGetBearing ( Nbr nbrPtr)

Get neighbor bearing.

Parameters
nbrPtrneighbor pointer
Returns
returns bearing. Ranges within [-pi, pi).
uint8 nbrGetID ( Nbr nbrPtr)

Get neighbor ID.

Parameters
nbrPtrneighbor pointer
Returns
ID
int32 nbrGetOrientation ( Nbr nbrPtr)

Get neighbor orientation.

Parameters
nbrPtrneighbor pointer
Returns
orientation. Ranges within [-pi, pi).
boolean nbrGetOrientationValid ( Nbr nbrPtr)

Get neighbor orientation valid.

Parameters
nbrPtrneighbor pointer
Returns
whether orientation is valid
int32 nbrGetRange ( Nbr nbrPtr)

Get neighbor range.

Parameters
nbrPtrneighbor pointer
Returns
orientation. Ranges within [-pi, pi).
uint8 nbrGetRangeBits ( Nbr nbrPtr)

Get neighbor range bits.

Range bits are recieverBitCount + orientationBitCount

Parameters
nbrPtrneighbor pointer
Returns
range bits
uint8 nbrGetReceiverBits ( Nbr nbrPtr)

Get neighbor receiver bits.

Receiver bits are the actual receivers the message was received on.

Parameters
nbrPtrneighbor pointer
Returns
receiver bits
uint8 nbrGetTransmitterBits ( Nbr nbrPtr)

Get neighbor transmitter bits.

Receiver bits are the actual transmitter the message was received from.

Parameters
nbrPtrneighbor pointer
Returns
transmitter bits
uint32 nbrGetUpdateRound ( Nbr nbrPtr)

Get neighbor update round.

Parameters
nbrPtrneighbor pointer
Returns
the last round this neighbor was heard from
uint32 nbrGetUpdateTime ( Nbr nbrPtr)

Get neighbor update time.

Parameters
nbrPtrneighbor pointer
Returns
update time
boolean nbrIsBeacon ( Nbr nbrPtr)

Returns true if this neighbor is a beacon.

Parameters
nbrPtrneighbor pointer
Returns
true if the neighbor is a IR beacon
boolean nbrIsRobot ( Nbr nbrPtr)

Returns true if this neighbor is a beacon.

Parameters
nbrPtrneighbor pointer
Returns
true if the neighbor is a IR beacon
void nbrMsgRadioCreate ( NbrMsgRadio nbrMsgRadioPtr,
const char *  name 
)

Create a radio neighbor message.

This function is called only once per program execution for each thing.

Parameters
nbrMsgRadioPtrthe pointer to the radio message
namethe name for the radio message
Returns
void
NbrMsgRadioNbrData* nbrMsgRadioGetNbr ( NbrMsgRadio nbrMsgRadioPtr,
Nbr nbrPtr 
)

Gets a radio neighbor message.

This function returns a pointer to the NbrMsgRadioNbrData struct for this neighbor.

Parameters
nbrMsgRadioPtrthe pointer to the radio message
nbrPtrpointer to the neighbor
Returns
pointer to data or NULL
void nbrMsgRadioPrint ( NbrMsgRadio nbrMsgRadioPtr,
Nbr nbrPtr 
)

Prints the message data for the input neighbor.

Parameters
nbrMsgRadioPtrpointer for the linked list of a neighbor's messages
nbrPtrpointer for the desired neighbor
Returns
void
void nbrMsgRadioSet ( NbrMsgRadio nbrMsgRadioPtr,
char *  dataPtr,
uint8  length 
)

Gets a radio neighbor message.

This function returns a pointer to the NbrMsgRadioNbrData struct for this neighbor.

Parameters
nbrMsgRadioPtrthe pointer to the radio message
dataPtrpointer to a char array of max length RADIO_COMMAND_MESSAGE_DATA_LENGTH
length
Returns
pointer to data or NULL
void nbrPrint ( Nbr nbr)

Print information on neighbor (and information of neighbor's neighbors).

Print roneID and neighbor's ID, bear, orientation, orientation valid Print name and value of each neighbor message.

Parameters
nbrneighbor pointer
Returns
void
void nbrPrintData ( Nbr nbr,
uint32  round 
)

Print header and neighbor data.

Print header once. Print id, time, round; neighbor's ID, bearing, update time; neighbor's neighbor's ID, bearing, update time.

Parameters
nbrneighbor pointer
roundthe round number
Returns
void
void neighborsDisable ( void  )

Disable neighbor xmit/recv.

Returns
void
void neighborsGetMutex ( void  )

Get neighbors mutex.

Returns
void
uint32 neighborsGetPeriod ( void  )

Get neighbor period.

Returns
void
uint32 neighborsGetRound ( void  )

Get neighbor round from neighbor data.

Returns
neighbor round
void neighborsIgnore ( uint8  neighborID)

Tries add neighborID to list of neighbors to ignore.

Parameters
neighborIDthe neighbor we want to ignore (no longer monitor)
Returns
void
void neighborsInit ( uint32  neighbor_period)

Initialize neighbors and start neighbors task.

Parameters
neighbor_periodthe neighbor period in rounds
Returns
void
boolean neighborsNewRoundCheck ( uint32 *  roundOldPtr)

Check to see if there is a new neighbor round. Updates the variable at the pointer.

Parameters
roundOldPtrpointer for previous round
Returns
TRUE if the neighbor round has changed
void neighborsPutMutex ( void  )

Put neighbors mutex.

Returns
void
void neighborsSetPeriod ( uint32  neighbor_period_arg)

Set neighbor period, neighbor timeout, and obstacle timeout proportional to argument.

Parameters
neighbor_period_argthe neighbor period length in rounds
Returns
void
void neighborsSetTimeoutRounds ( uint8  timeoutRounds,
uint8  minActive,
uint8  maxInactive 
)

Set neighbor period, neighbor timeout, and obstacle timeout proportional to argument.

Parameters
timeoutRounds
minActive
maxInactive
Returns
void
void neighborsXmitEnable ( boolean  neighbor_xmit_enable_arg)

Enable neighbor to transmit messages.

Parameters
neighbor_xmit_enable_arga boolean that allows enable or not
Returns
void
void obstaclePrint ( void  )

Print the obstacle data from the IR sensors.

Returns
void