Project

General

Profile

Revision 1071

Deleted random files in top level directory.

View differences:

branches/simulator/projects/simulator/Rangefinder_with_noise.c
1
 /**
2
 * @file rangefinder_with_noise.c
3
 * @author Colony Project
4
 *
5
 * @brief Returns rangefinder units with noise given distance in cm.
6
 *
7
 * Adds a random, normal amount of noise to a rangefinder
8
 * value given in cm. Returns approximate IR units .
9
 **/
10

  
11

  
12
double get_rangefinder(double dist_in_cm)
13
{
14
	double cm, IR, noise;
15
	// gauss_init(1, 0); // Params are chaos scalar and seed
16

  
17
	// noise = gauss_noise(void); // Gives ther noise
18

  
19
	cm = dist_in_cm; // Enter value between 7 and 18 for accurate results
20

  
21
	IR = 15.4005 * cm; // 15.4005 is an experimental value
22
	
23

  
24
	/*  Rangefinder is good for values between 7 and 18.
25
	*	3 < cm < 7 AND 18 < cm < 22 are significantly more erroneous.
26
	*	cm < 3 and cm > 22, rangefinder reports -1
27
	*/
28
	if ( cm < 3 || cm > 22 )
29
	{
30
		return -1;
31
	}
32
	else if( cm < 7 || cm > 18 )
33
	{
34
		gauss_init(2, 0);
35
		noise = gauss_noise();
36
		return IR + noise;
37
	}
38
	else 
39
	{
40
		gauss_init(1, 0);
41
		noise = gauss_noise();
42
		return IR + noise;
43
	}
44
  
45
}
branches/simulator/projects/simulator/rayHits.c
1
#include <stdlib.h>
2
#include <math.h>
3

  
4
double Xr, Yr, Tr, Xc, Yc, Rc; // (X,Y,theta for ray) (X,Y,radius for circle)
5

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

  
13
	if (D < Rc )
14
	{
15
		return true;
16
	}
17
	else
18
	{
19
		return false;
20
	}
21

  
22
	return false;
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