Project

General

Profile

Revision 960

Small changes and comments.

View differences:

receive.c
9 9
#define WL_COM_PORT "/dev/ttyUSB1" 
10 10
#define WL_CHANNEL 0xE
11 11

  
12
#define MAP_RECEIVE_GROUP 1
13
#define MAP_REQUEST_GROUP 2
12
#define MAP_RECEIVE_GROUP 17
13
#define MAP_REQUEST_GROUP 23
14 14

  
15 15
#define POINT_RAW 1 /* packet type for map data points w/ raw encoder data*/
16 16
#define POINT_ODO 2 /* packet type for map data points w/ odometry data*/
......
92 92
		}
93 93
		else{
94 94
			double** point, **ranges, *theta, *robot;
95
			/*TODO Check for the 'already empty' case.*/
96

  
95
			
97 96
			int num_buffer_elements = tail_index - head_index;
98 97
			if(num_buffer_elements < 0) num_buffer_elements += BUFFER_SIZE;	
99 98

  
......
144 143
	wl_token_ring_register();	
145 144
	
146 145
	/*Continuously iterate over all the robots - buffering data.*/
146
	
147 147
	while(1){
148 148
		
149 149
		wl_token_iterator_begin();
......
160 160
			wl_send_robot_to_robot_global_packet(MAP_REQUEST_GROUP, 
161 161
				POINT_ODO, NULL, 0, robot_num, 0);
162 162
            	
163

  
163
			usleep(10000); /*10ms*/
164 164
		}
165 165
		
166
		/*Wait for all packets to be received before sending more requests.*/
166
		/*Wait for all packets to be received 
167
		 * before sending more requests.
168
		 * FIXME this needs to be WAAAAY more robust
169
		 * to edge cases (robot enters / leaves token
170
		 * ring etc.) For example, if a robot drops
171
		 * a packet (highly likely) it is not dealt with
172
		 * */
167 173
		while(packets_received < num_robots 
168 174
		   && packets_received < wl_token_get_num_robots()){
169 175
			

Also available in: Unified diff