Project

General

Profile

Revision 1067

Made some additions to rayHits.c

Not really useful, just for me

View differences:

trunk/code/projects/test/testrangefinders.c
6 6
 * - analog_init() is needed
7 7
 * - value 100 - under 5cm is not detected
8 8
 * - value 800 - over ~30cm is not detected
9
 * - at ~20cm values become increasingly erroneous
9 10
 *
10 11
 */
12
 
13
int to_mm(int rangeFinder) 
14
{
11 15

  
16
	if(rangeFinder != -1)
17
		return (int)(rangeFinder/15.112*10);
18
	else
19
		return -1;
20

  
21
}
22

  
12 23
int testrangefinders(void) {
13 24
  dragonfly_init(ANALOG);
14 25
  usb_init();
......
18 29
  int d1,d2,d3,d4,d5;
19 30
  delay_ms(1000);
20 31
  
32
  //int sum = 0;
33
  //int count = 0;
34
  //int average = 0;
35
  
21 36
  // start testing rangefinders
22 37
  while(1) {
38
	//if(count == 10000)
39
	//{
40
	//	average = sum/count;
41
	//	count = 0;
42
	//}
43
	
23 44
    // get ranges
24
    d1 = range_read_distance(IR1);
45
    //d1 = range_read_distance(IR1);
25 46
    d2 = range_read_distance(IR2);
26
    d3 = range_read_distance(IR3);
27
    d4 = range_read_distance(IR4);
28
    d5 = range_read_distance(IR5);
29
    usb_puts("d1=");
30
    usb_puti(d1);
31
    usb_puts("\td2=");
32
    usb_puti(d2);
33
    usb_puts("\td3=");
34
    usb_puti(d3);
35
    usb_puts("\td4=");
36
    usb_puti(d4);
37
    usb_puts("\td5=");
38
    usb_puti(d5);
39
    usb_puts("\r\n");    
47
    //d3 = range_read_distance(IR3);
48
    //d4 = range_read_distance(IR4);
49
    //d5 = range_read_distance(IR5);
50
    //usb_puts("d1=");
51
    //usb_puti(d1);
52
	
53
	//sum += d2;
54
	
55
    //usb_puts("\taverage of 10000=");
56
    //usb_puti(d2);
57
	
58
    //usb_puts("\td3=");
59
    //usb_puti(d3);
60
    //usb_puts("\td4=");
61
    //usb_puti(d4);
62
    //usb_puts("\td5=");
63
    //usb_puti(d5);
64
	
65
	usb_puts("\tIn mm=");
66
	usb_puti(to_mm(d2));
67
    usb_puts("\r\n");   
68
	
69
	//count++;
70
	
40 71
    delay_ms(100);
41 72
  }
42 73
  
branches/simulator/projects/simulator/rayHits.c
5 5

  
6 6
boolean rayHits(double Xr,double Yr,double Tr,double Xc,double Yc,double Rc)
7 7
{
8
	double m, b, D;
8
	double m, b, D, t;
9 9
	m = tan(Tr);
10 10
	b= -m * Xr + Yr;
11 11
	D = (abs(Yc - m * Xc - b)) / (sqrt(m * m + 1);
......
20 20
	}
21 21

  
22 22
	return false;
23
}
23
}
24

  
25

  
26
/*
27
*
28
*
29
*
30
*
31
*
32
*
33
*
34
*
35
*/
36

  
37
double a, b, c, t1, t2;
38

  
39
t1 = -(
40

  
41
((Xr - Xc)^2 + 2*cos(Tr)*(

Also available in: Unified diff