Project

General

Profile

Revision 1881

Merged the types of doubles into the crossing type. Also fixed comments
that were never updated and implements things of type DOUBLE as DOUBLE_T's
if you dont specify because DOUBLE_T is more safe.

View differences:

validTurns.c
1 1
/*
2
 * Deterministic turning implemented using randomness. Using a
3
 * random number generator, the robot decides to go straight, 
4
 * left, right, or u-turn.
2
 * Deterministic turning implemented using table lookup. Using a
3
 * table, the function looks up a value from the table using the 
4
 * barcode value, and then the robot decides to go straight, 
5
 * left, right, or u-turn depending on the valid turn types
6
 * for the intersection it is at.
5 7
 *
6 8
 */
7 9

  
8 10
#include <dragonfly_lib.h>
9 11
#include "validTurns.h"
10 12

  
11
#define NOBARCODE -1
12
/*
13

  
14
/******************************Random Num Gen Version of validTurns
13 15
int randomNumGen(int max){
14 16
	int x = range_read_distance(IR2);
15 17
	if (x>0) return range_read_distance(IR2)%max;
......
40 42

  
41 43
int getCrossType(int barcode){
42 44
	int crosstype = (barcode>>2)&3;
43
	if (crosstype == DOUBLE) crosstype = (barcode>>4)&7;
44 45
	return crosstype;
45 46
}
46 47
int getCrossPos(int barcode, int max){
......
51 52
{
52 53
	int cross_type;
53 54
	int cross_pos;
54
	if( barcode == NOBARCODE ) return -1;
55 55
	cross_type = getCrossType(barcode);
56 56
	switch (cross_type)
57 57
	{
......
62 62
			return turn_type;
63 63
		break;
64 64
		}
65
		case DOUBLE:   //Implements DOUBLE as DOUBLE_T
65 66
		case DOUBLE_T:
66 67
		{
67 68
			cross_pos = getCrossPos(barcode, 3);

Also available in: Unified diff