ronelib
Operating System for the r-one robot
 All Data Structures Files Functions Variables Typedefs
neighborListOps.h File Reference

Operations on lists of neighbors. More...

Go to the source code of this file.

Functions

void nbrListCreate (NbrList *nbrListPtr)
 Fills the provided nbrList with the current set of neighbors. More...
 
void nbrListClear (NbrList *nbrListPtr)
 Sets the size of nbrList to 0. More...
 
void nbrListPrintDebug (NbrList *nbrListPtr, char *name)
 Prints the IDs and update times for all robots in the neighbor list. More...
 
void nbrListAddNbr (NbrList *nbrListPtr, Nbr *nbrPtr)
 Adds a neighbor to a neighbor's linked list of neighbors if there is room. More...
 
void nbrListRemoveNbr (NbrList *nbrListPtr, Nbr *nbrPtr)
 Removes nbrPtr from list (if it exists). More...
 
void nbrListCopy (NbrList *nbrListDstPtr, NbrList *nbrListSrcPtr)
 Copies the neighbor list from SRC to DST. More...
 
int16 nbrListAverageBearing (NbrList *nbrListPtr)
 Determines average bearing of all neighbors using sum of vectors method (optimized). More...
 
Nbr * nbrListGetFirst (NbrList *nbrListPtr)
 Returns a pointer to the neighbor at the head of the list, or NULL. More...
 
Nbr * nbrListGetSecond (NbrList *nbrListPtr)
 Returns a pointer to the neighbor second in the list, or NULL. More...
 
Nbr * nbrListGetNbrWithID (NbrList *nbrListPtr, uint8 ID)
 Returns a pointer to the neighbor with ID, or NULL. More...
 
Nbr * nbrListGetSmallestAngleDeviation2 (NbrList *nbrListPtr, Nbr *nbrPtr)
 returns the neighbor whose bearing is closest to nbrPtr's bearing, NULL if list is empty. More...
 
Nbr * nbrListGetClosestNbrToBearing (NbrList *nbrListPtr, int16 bearing)
 returns the neighbor whose bearing is closest to bearing, NULL if list is empty. More...
 
NbrList * nbrListUnion (NbrList *nbrListOutPtr, NbrList *nbrList1Ptr, NbrList *nbrList2Ptr)
 Computes the union of the two input neighbor lists. More...
 
NbrList * nbrListFindNbrsWithDataEqual (NbrList *nbrListOutPtr, NbrList *nbrListInPtr, NbrData *nbrDataPtr, uint8 val)
 returns a pointer to the list of neighbors with the same data value More...
 
NbrList * nbrListFindNbrsWithDataEqual2 (NbrList *nbrListOutPtr, NbrList *nbrListInPtr, NbrData *nbrDataPtr, uint8 val1, uint8 val2)
 returns a pointer to the list of neighbors with the same data values More...
 
Nbr * nbrListGetNbrMinBearing (NbrList *nbrListInPtr)
 Finds the neighbor with the minimum bearing in a list of neighbors. More...
 
NbrList * nbrListSortByBearing (NbrList *nbrListOutPtr, NbrList *nbrListInPtr)
 Sorts the nbr List in counter clockwise order by bearing. More...
 
NbrList * nbrListIncludeSectorInclusive (NbrList *nbrListOutPtr, NbrList *nbrListInPtr, int16 angleStart, int16 angleEnd)
 Creates a list of neighbors that lie within the specified sector between angleStart and angleEnd. More...
 
NbrList * nbrListIncludeSectorExclusive (NbrList *nbrListOutPtr, NbrList *nbrListInPtr, int16 angleStart, int16 angleEnd)
 Creates a list of neighbors that lie outside of the specified sector between angleStart and angleEnd. More...
 
NbrList * nbrListGetRobots (NbrList *nbrListOutPtr, NbrList *nbrListInPtr)
 Finds neighbors that are robots. More...
 

Detailed Description

Operations on lists of neighbors.

This includes adding/removing neighbors, searching for neighbors, and looking for robots with certain bearings.

Since
September 13, 2011
Author
James McLurkin

Function Documentation

void nbrListAddNbr ( NbrList *  nbrListPtr,
Nbr *  nbrPtr 
)

Adds a neighbor to a neighbor's linked list of neighbors if there is room.

Parameters
nbrListPtrthe neighbor's linked list
nbrPtra new neighbor
Returns
void
int16 nbrListAverageBearing ( NbrList *  nbrListPtr)

Determines average bearing of all neighbors using sum of vectors method (optimized).

Parameters
nbrListPtrlist of neighbors
Returns
average bearing (milliradians)
void nbrListClear ( NbrList *  nbrListPtr)

Sets the size of nbrList to 0.

Parameters
nbrListPtrpointer for the list of neighbors to be altered
Returns
void
void nbrListCopy ( NbrList *  nbrListDstPtr,
NbrList *  nbrListSrcPtr 
)

Copies the neighbor list from SRC to DST.

Parameters
nbrListSrcPtr(unchanged)
nbrListDstPtrbecomes a copy of nbrListSrcPtr
Returns
void
void nbrListCreate ( NbrList *  nbrListPtr)

Fills the provided nbrList with the current set of neighbors.

Parameters
nbrListPtrfor the list of neighbors
Returns
void
NbrList* nbrListFindNbrsWithDataEqual ( NbrList *  nbrListOutPtr,
NbrList *  nbrListInPtr,
NbrData *  nbrDataPtr,
uint8  val 
)

returns a pointer to the list of neighbors with the same data value

Parameters
nbrListOutPtrpointer to output list of neighbors
nbrListInPtrpointer to input list of neighbors
nbrDataPtrlist of data on messages
valvalue of data to match
Returns
a pointer to the output list of neighbors with the same data value
NbrList* nbrListFindNbrsWithDataEqual2 ( NbrList *  nbrListOutPtr,
NbrList *  nbrListInPtr,
NbrData *  nbrDataPtr,
uint8  val1,
uint8  val2 
)

returns a pointer to the list of neighbors with the same data values

Parameters
nbrListOutPtrpointer to output list of neighbors
nbrListInPtrpointer to input list of neighbors
nbrDataPtrlist of data on messages
val1first value of data to match
val2second value of data to match
Returns
a pointer to the output list of neighbors with the same data values
Nbr* nbrListGetClosestNbrToBearing ( NbrList *  nbrListPtr,
int16  bearing 
)

returns the neighbor whose bearing is closest to bearing, NULL if list is empty.

Parameters
nbrListPtrlist of neighbors
bearinga reference bearing
Returns
pointer to neighbor whose bearing is closest to bearing, NULL if list is empty.
Nbr* nbrListGetFirst ( NbrList *  nbrListPtr)

Returns a pointer to the neighbor at the head of the list, or NULL.

Parameters
nbrListPtrpointer for the list of neighbors
Returns
a pointer to the neighbor at the head of the list, or NULL
Nbr* nbrListGetNbrMinBearing ( NbrList *  nbrListInPtr)

Finds the neighbor with the minimum bearing in a list of neighbors.

Parameters
nbrListInPtrpointer to the neighbor list to search
Returns
pointer to the neighbor with the minimum bearing
Nbr* nbrListGetNbrWithID ( NbrList *  nbrListPtr,
uint8  ID 
)

Returns a pointer to the neighbor with ID, or NULL.

Parameters
nbrListPtrpointer for the list of neighbors
IDthe unique number of the robot being searched for
Returns
a pointer to the neighbor with ID, or NULL
NbrList* nbrListGetRobots ( NbrList *  nbrListOutPtr,
NbrList *  nbrListInPtr 
)

Finds neighbors that are robots.

Parameters
nbrListOutPtrpointer to the neighbor list updated by this function
nbrListInPtrpointer to the neighbor list to search for robots
Returns
updated nbrListOutPtr that contains only neighbors that are robots
Nbr* nbrListGetSecond ( NbrList *  nbrListPtr)

Returns a pointer to the neighbor second in the list, or NULL.

Parameters
nbrListPtrpointer for the list of neighbors
Returns
a pointer to the neighbor second in the list, or NULL
Nbr* nbrListGetSmallestAngleDeviation2 ( NbrList *  nbrListPtr,
Nbr *  nbrPtr 
)

returns the neighbor whose bearing is closest to nbrPtr's bearing, NULL if list is empty.

Parameters
nbrListPtrlist of neighbors
nbrPtra neighbor used as a reference
Returns
pointer to neighbor whose bearing is closest to nbrPtr's bearing, NULL if list is empty.
NbrList* nbrListIncludeSectorExclusive ( NbrList *  nbrListOutPtr,
NbrList *  nbrListInPtr,
int16  angleStart,
int16  angleEnd 
)

Creates a list of neighbors that lie outside of the specified sector between angleStart and angleEnd.

Parameters
nbrListOutPtrpointer to the memory location where the generated list should be stored
nbrListInPtrpointer to the list of neighbors to check
angleStartstarting bearing of the sector
angleEndending bearing of the sector
Returns
the list of neighbors outside of the specified sector
NbrList* nbrListIncludeSectorInclusive ( NbrList *  nbrListOutPtr,
NbrList *  nbrListInPtr,
int16  angleStart,
int16  angleEnd 
)

Creates a list of neighbors that lie within the specified sector between angleStart and angleEnd.

Parameters
nbrListOutPtrpointer to the memory location where the generated list should be stored
nbrListInPtrpointer to the list of neighbors to check
angleStartstarting bearing of the sector
angleEndending bearing of the sector
Returns
the list of neighbors within the specified sector
void nbrListPrintDebug ( NbrList *  nbrListPtr,
char *  name 
)

Prints the IDs and update times for all robots in the neighbor list.

Formated as follows: {name, ID updateTime, ID updateTime, ...}

Parameters
nbrListPtrpointer for the neighborlist
namefor the list name
Returns
void
void nbrListRemoveNbr ( NbrList *  nbrListPtr,
Nbr *  nbrPtr 
)

Removes nbrPtr from list (if it exists).

Parameters
nbrListPtrlist of neighbors
nbrPtra neighbor to be removed
Returns
void
NbrList* nbrListSortByBearing ( NbrList *  nbrListOutPtr,
NbrList *  nbrListInPtr 
)

Sorts the nbr List in counter clockwise order by bearing.

Parameters
nbrListOutPtrpointer to output list of neighbors
nbrListInPtrpointer to input list of neighbors
Returns
a sorted list of neighbors
NbrList* nbrListUnion ( NbrList *  nbrListOutPtr,
NbrList *  nbrList1Ptr,
NbrList *  nbrList2Ptr 
)

Computes the union of the two input neighbor lists.

Parameters
nbrListOutPtrpointer to the list created from the union
nbrList1Ptrfirst neighbor list
nbrList2Ptrsecond neighbor list
Returns
a pointer to a neighbor list that is the union of the two input lists