Project

General

Profile

Revision 1950

Added mapping capabilites

View differences:

trunk/code/projects/traffic_navigation/mapping.h
1
//Representation of an edge (road)
2
typedef struct {
3
    int to;
4
    int dist;
5
}edge
6

  
7
//Representation of an intersection on the graph
8
typedef struct {
9
    int type;
10
    int numOut;
11
    edge[] outgoingEdges;
12
}node
trunk/code/projects/traffic_navigation/mapping.c
1
#include "mapping.h"
2
#include "lineDrive.h"
3
#include <dragonfly_lib.h>
4

  
5
//The last intersection that we encountered
6
int lastInt;
7

  
8
//Current encoder reading
9
int distance;
10

  
11

  
12
/* 
13
 * Traverses the map using DFS 
14
 * Returns 0 if all of the intersections in the database were seen
15
 * 1 otherwise 
16
 */
17
int createMap(){
18
    
19
    int seen = 0
20
    int currInt = 0;
21
    int barcode;
22
    int outEdges;
23
    struct node currInt;
24
    int i;
25
    
26
    /* Holds the number of intersections we have seen */
27
    char[] intseen;
28

  
29
    /* Drives to the nearest intersection */
30
    barcode = nextInt();
31
        
32
	while(seen < numIntersections)
33
	{
34
		 /* Given the barcode reading, returns the struct representing
35
     		  * the intersection */
36
    		currInt = lookup(barcode);
37
		
38
		/* Update the nodes that you have seen */
39
		intseen[currInt] = 1;
40
		
41
		outEdges = currInt.numOut;
42

  
43
		//Go through every outgoing edge 
44
		for(i = 0; i< outEdges; i++)
45
		{
46
			//Step out 
47
		}
48
	}
49

  
50
	return 0;
51
}
52

  
53
/* Creates an edge in the graph */
54
int insertEdge(){
55
}
56

  
57

  
58
/* 
59
 * Drives to the next intersection and returns its ID
60
 * If we are at a dead end, returns -1
61
 */
62
int nextInt(){
63
    
64
}

Also available in: Unified diff