-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquadcopter.cpp
85 lines (70 loc) · 1.46 KB
/
quadcopter.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
81
82
83
84
85
#include "quadcopter.h"
#include <stdlib.h>
#include <iostream>
double pitch = 100;
double roll = -100;
uint8_t FR = 0;
uint8_t FL = 0;
uint8_t BR = 0;
uint8_t BL = 0;
double height = 0;
double vel = 0;
int8_t getPitch()
{
return pitch;
}
int8_t getRoll()
{
return roll;
}
void setFR(uint8_t setNum)
{
FR = setNum;
}
void setFL(uint8_t setNum)
{
FL = setNum;
}
void setBR(uint8_t setNum)
{
BR = setNum;
}
void setBL(uint8_t setNum)
{
BL = setNum;
}
uint8_t getHeight()
{
return height;
}
void move()
{
pitch += BR*aNum + BL*aNum;
pitch -= FR*aNum + FL*aNum;
pitch += rand()%9 - 4;
roll += FL*aNum + BL*aNum;
roll -= FR*aNum + BR*aNum;
roll += rand()%9 - 4;
vel = (FR*aNum + FL*aNum + BR*aNum + BL*aNum) - 30;
height += vel;
height = (height < 0) ? 0 : height;
std::cout << "FL: " << (int)FL << " FR: " << (int)FR << std::endl;
std::cout << "BL: " << (int)BL << " BR: " << (int)BR << std::endl;
std::cout << "Pitch: " << pitch << " Roll: " << roll << std::endl;
std::cout << "Height: " << height << std::endl;
for(int i = 0; i < 53; i++)
{
if(i == (int)(51 - (height/3)))
{
std::cout << " ####################\n";
}
else if(i == 52)
{
std::cout << "_________________________________________________________________________________________________________________________________________________________________\n";
}
else
{
std::cout << "\n";
}
}
}