-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCanard.h
More file actions
38 lines (29 loc) · 893 Bytes
/
Canard.h
File metadata and controls
38 lines (29 loc) · 893 Bytes
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
#include <Servo.h>
class Canard
{
public:
void setup(int);
inline void set_angle(double);
inline double get_angle() const;
inline void set_offset(double);
private:
Servo _servo;
double _angle;
double _angle_offset;
};
void Canard::setup(int pin_number)
{
_servo.attach(pin_number);
}
inline void Canard::set_angle(double angle)
{
// The input is in a domain from +-90 degrees. It should be noted that offsets might limit this domain.
angle = angle + _angle_offset;
if (angle >= 90){_angle = 90;}
else if (angle <= -90){_angle = -90;}
else { _angle = angle; }
_servo.write(_angle + 90);
}
inline double Canard::get_angle() const { return _angle; }
// Note that this will limit the angles that the fin can move. A signifigant offset shouldn't be used.
inline void Canard::set_offset(double angle_offset){ _angle_offset = angle_offset; }