-
Notifications
You must be signed in to change notification settings - Fork 0
/
project (2).cpp
80 lines (72 loc) · 1.49 KB
/
project (2).cpp
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
80
//Begin page Go_to_positionA
void go_to_positionA(){
target[0]=0.97;
if (myZRState[0] < target[0]){
api.setPositionTarget(positionA);
}
else {
step++;
}
}
//End page Go_to_positionA
//Begin page Go_to_positionB
void go_to_positionB(){
target[0]=0.97;
if (myZRState[0] < target[0]){
api.setPositionTarget(positionB);
}
else {
step++;
}
}
//End page Go_to_positionB
//Begin page Go_to_positionC
void go_to_positionC(){
target[0]=0.03;
if (myZRState[0] > target[0]){
api.setPositionTarget(positionC);
}
else {
step++;
}
}
//End page Go_to_positionC
//Begin page main
//Declare any variables shared between functions here
float positionA[3];
float positionB[3];
float positionC[3];
float myZRState[12];
float target[3];
int step;
void init(){
//This function is called once when your code is first loaded.
//IMPORTANT: make sure to set any variables that need an initial value.
//Do not assume variables will be set to 0 automatically!
positionA[0]=1.0;
positionA[1]=0.0;
positionA[2]=0.0;
positionB[0]=0.0;
positionB[1]=0.0;
positionB[2]=1.0;
positionC[0]=0.0;
positionC[1]=1.0;
positionC[2]=0.0;
}
void loop(){
//This function is called once per second. Use it to control the satellite.
api.getMyZRState(myZRState);
if (step==0){
go_to_positionA();
}
else if (step==1){
go_to_positionC();
}
else if (step==2){
go_to_positionB();
}
else{
step=0;
}
}
//End page main