-
Notifications
You must be signed in to change notification settings - Fork 2
/
Test_Code_2.txt
80 lines (70 loc) · 1.66 KB
/
Test_Code_2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# turns left in the amount of degrees specified (if negative turns right)
func _turn(int deg)
{
drone_enum turnDir;
if (deg > 0)
{
turnDir = LEFT;
}
elseif (deg < 0)
{
turnDir = RIGHT;
deg = -1 * deg;
}
for (int i = 0; i < deg; i = i + 1)
{
&turn(turnDir);
}
}
# function for drone to spray a rectangular area, assumes that drone is located right on the left bottom corner and facing north. Left bottom corner of rectangle is (0,0)
func _sprayParalelo( int length, int width)
{
&connectTo(197.6.0.200);
real firstAlti = &getAltitude(); # Altitude at the release
real cruiseAlti = firstAlti + 5;
real areaGoal = length * width; # Area to be covered
real areaDone = 0; # Area covered
int curX = 0;
int curY = 0;
$output("Area to be covered is ");
$output(areaGoal);
while( firstAlti <= cruiseAlti){
&climb(UP);
}
for( int i = 1; i < width; i = i + 2){
while(curX <= length){
&toggleSpray(ON);
&move(FORWARD);
}
areaDone = areaDone + length;
$output("Area Covered is: ");
$output(areaDone);
&toggleSpray(OFF);
_turn(-60);
while(width - curY <= width - i){
&toggleSpray(ON);
&move(FORWARD);
}
_turn(-120);
&toggleSpray(OFF);
while(curX >= 0){
&toggleSpray(ON);
&move(FORWARD);
}
areaDone = areaDone + length;
$output("Area Covered is: ");
$output(areaDone);
_turn(120);
&toggleSpray(OFF);
while(width - curY <= width - (i + 1) ){
&toggleSpray(ON);
&move(FORWARD);
}
_turn(60);
}
}
main(){
length = 10;
width = 5;
_sprayParalelo( length, width);
}