Project

General

Profile

Revision 1980

Fixed all compilation errors and warnings in traffic_navigation. If you committed these
abominations, I hope you're sorry. I only made things compile. If I fixed your code, it
might no longer do what you intended, but I can pretty much guarantee that it didn't do
what you intended anyway, so no complaining. Some undefined or implicitly defined
functions had no clear fix without writing new code, so I just added comments
recommending that the maintainers fix the problems. If that's you, I'd get on that.

View differences:

trunk/code/projects/traffic_navigation/sendGraph.c
61 61
        for(i=0; i< NUM_FEATURES; i++){
62 62
                graph.n = intersections[i];
63 63
                wl_basic_send_global_packet(42, graph.array, 12);
64
                wl_basic_send_global_packet(42, '\n', 1);
64
                wl_basic_send_global_packet(42, "\n", 1);
65 65
        }
66 66
}
trunk/code/projects/traffic_navigation/sendGraph.h
6 6
 * ...
7 7
 * ...
8 8
 */
9
void sendIntersectionGraph();
9
void sendIntersectionGraph(void);
10 10

  
11 11

  
12 12
/* Representation of an edge (road) */
trunk/code/projects/traffic_navigation/mapping.c
1
#include ""
2 1
#include "mapping.h"
3 2
#include "lineDrive.h"
4 3
#include <dragonfly_lib.h>
4
#include <wl_basic.h>
5 5

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

  
9
/* This array holds all of the intersections that are represented in the graph
10
 * after its creation, the graph is transmitted wirelessly */
11
node intersections[NUM_FEATURES]; 
9 12

  
10 13
/* 
11 14
 * Traverses the map using DFS 
......
17 20
	char time;
18 21
	rtc_init(SIXTEENTH_SECOND, NULL);
19 22
	rtc_reset();
20
	while(barcode = NOBARCODE){
23
    do
24
    {
21 25
		barcode = (char) doDrive(200);
22
	}
26
    } while(barcode == NOBARCODE);
23 27
	time = rtc_get();
24
	newEdge.to = barcode;
25
	newEdge.dist = time;
28
	newEdge->to = barcode;
29
	newEdge->dist = time;
26 30
	return 0;
27 31
}
28 32

  
......
31 35
    int seenout_count = 0;			/* The number of intersections we have completely seen */
32 36
    //int hist_count = 0;			/* The size of our history stack */ 
33 37

  
34
    char[NUM_FEATURES] seen;		/* Have we seen this node? */
35
    char[NUM_FEATURES] seenout;		/* Have we seen the outoging edges of this node? */
36
    //char[NUM_FEATURES] history;		/* A stack representing the history */
38
    char seen[NUM_FEATURES];		/* Have we seen this node? */
39
    char seenout[NUM_FEATURES];		/* Have we seen the outoging edges of this node? */
37 40

  
38 41
    int i;
39 42
    int outEdges, currInt, chosenEdge;
......
43 46
    for(i = 0; i<NUM_FEATURES; i++) {
44 47
            seen[i] = 0;
45 48
            seenout[i] = 0;
46
            history[i] = 0;
47 49
            intersections[i].type = 0;
48 50
            intersections[i].intNum = 0;
49 51
            intersections[i].numOut = 0;
......
60 62

  
61 63

  
62 64
        /* Drives to the nearest intersection */
63
        barcode = nextInt();
65
        int barcode = nextInt();
64 66

  
65 67
        while(seenout_count < NUM_FEATURES)
66 68
        {
67
                currInt = getIntersectionNum(barcode);
69
                currInt = getIntersectNum(barcode);
68 70
                seen[currInt] = 1;
69 71

  
70 72
                /* Get the number of outgoing edges */
......
72 74

  
73 75
                /* Randomly choose an outgoing edge that we have not seen to go down 
74 76
                 * if no such edge exists */
77
								// TODO: include the appropriate header file for rand()
75 78
                chosenEdge = rand() % outEdges;
76 79

  
77 80
                /* We have not seen all the outgoing edges */
78 81
                if(!seenout[currInt]){
79
                        intersection[currInt].outSeen++;
82
                        intersections[currInt].outSeen++;
80 83
                        /* We have finished seeing all outgoing edges of the intersection */
81
                        if(intersections[currInt].numOut == intersection[currInt].outSeen){
84
                        if(intersections[currInt].numOut == intersections[currInt].outSeen){
82 85
                                seenout[currInt] = 1;
83 86
                                seenout_count ++;
84 87
                        }
85 88
                }
86 89
                /* Traverses edge, stores information in struct */
87
                traverseEdge(chosenEdge, &(intersection[currInt].outgoingEdges[chosenEdge]));
90
								/* TODO: Define traverseEdge, then uncomment this line
91
                traverseEdge(chosenEdge, &(intersections[currInt].outgoingEdges[chosenEdge])); */
88 92
        }
89 93

  
90 94
        /* We are done traversing send the graph to the robots */
......
97 101
/* Given an intersection type, returns the number of outgoing edges */
98 102
int getNumOut(int type) {
99 103
    switch(type){
100
        case 0: return;
101
        case 1:	return; 
102
        case 2:	return; 
103
        case 3:	return;
104
        case 4:	return;
104
        case 0:
105
            return 0;
106
        case 1:
107
            return 1; 
108
        case 2:
109
            return 2; 
110
        case 3:
111
            return 3;
112
        case 4:
113
            return 4;
105 114
    }
106 115

  
107 116
    return -1;
......
110 119

  
111 120
/* Creates an edge in the graph */
112 121
int insertEdge(){
113

  
122
	return 0;
114 123
}
115 124

  
116 125

  
......
119 128
 * If we are at a dead end, returns -1
120 129
 */
121 130
int nextInt(){
122

  
131
	return 0;
123 132
}
124 133

  
125 134

  
......
129 138
 *
130 139
 */
131 140
int encodeNode(node n){
132

  
133

  
141
	return 0;
134 142
}
135 143

  
136
/*
137
 * Uses wireless to send the graph sructure
138
 * to other robots
139
 *
140
 * @return 
141
 *
142
 */
143
void sendIntersectionGraph() {
144
        int i;
145
        node_union graph;
146

  
147
        for(i=0; i< NUM_FEATURES; i++){
148
                graph.n = intersctions[i];
149
                wl_basic_send_global(42, graph.array, 12);
150
        }
151
}
trunk/code/projects/traffic_navigation/mapping.h
1
#ifndef __INTERSECTION_MAPPING_H__
2
#define __INTERSECTION_MAPPING_H__
3

  
1 4
#include "intersectData.h"
2 5

  
3 6
/* Data is sent in the following order
......
11 14
typedef struct {
12 15
	char to;	/* Where does this edge lead to? */
13 16
	char dist;	/* Where does it come from?	*/
14
}edge
17
} edge;
15 18

  
16 19
/* Representation of an intersection on the graph */
17 20
typedef struct {
......
19 22
	char intNum;	/* What is the intersection number */
20 23
	char numOut;	/* Note that we can have no more than 4 outgoing edges */
21 24
	char outSeen;	/* The number of the outgoing edges that we have seen for this intersection */
22
	edge[4] outgoingEdges;  
23
}node
25
	edge outgoingEdges[4];
26
} node;
24 27

  
25 28
/* A union that is used in wireless transmissions */
26 29
typedef union  {
27 30
	node n;
28 31
	char array[12];
29
}node_union
32
}node_union;
30 33

  
31
/* This array holds all of the intersections that are represented in the graph
32
 * after its creation, the graph is transmitted wirelessly */
33
node[NUM_FEATURES] intersections; 
34
int createEdge(edge* newEdge);
35
int createMap(void);
36
int getNumOut(int type);
37
int insertEdge(void);
38
int nextInt(void);
39
int encodeNode(node n);
40
void sendIntersectionGraph(void);
34 41

  
35
int createEdge(edge* newEdge);
42
extern node intersections[NUM_FEATURES];
43

  
44
#endif
trunk/code/projects/traffic_navigation/main-new.c
7 7

  
8 8
#include "traffic_navigation.h"
9 9
#include "../linefollowing/lineDrive.h"
10
#ifdef MAIN_NEW
10
#ifndef MAIN_NEW
11 11

  
12 12
	static int state, sign, turnDir;
13 13
	static char sendBuffer[PACKET_LENGTH], queuePrevBot, queueNextBot, id, nextDir, nextPath, intersectionNum, resolvPrevBotID = -3;

Also available in: Unified diff