-
Notifications
You must be signed in to change notification settings - Fork 0
/
HexapodLeg.h
58 lines (47 loc) · 1.88 KB
/
HexapodLeg.h
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
#ifndef HEXAPODLEG_H
#define HEXAPODLEG_H
#include <Servo.h>
class HexapodLeg
{
protected:
Servo s_hipLat; // Hip servo that controls lateral movement
Servo s_hipLon; // Hip servo that controls longitudinal movement
Servo s_knee; // Self-explanitory
int p_hipLat = 0; // Positions of respective servos, initialized to zero but modified by the constructor
int p_hipLon = 0;
int p_knee = 0;
public:
HexapodLeg(); // Default constructor required for declarations (does nothing special)
HexapodLeg(int hipLatPin, int hipLonPin, int kneePin, int hipLatPos, int hipLonPos, int kneePos);
~HexapodLeg();
void WriteToServos();
void SetPositions(int hipLat, int hipLon, int knee); // Set positions of all servos in leg
// These functions are pure virtual, since the two subclasses need to specify their own functions
virtual void FlexJoints(int hipLatDeg, int hipLonDeg, int kneeDeg) = 0; // Shorthand way to modify entire leg
virtual void FlexHipLat(int degrees) = 0;
virtual void FlexHipLon(int degrees) = 0;
virtual void FlexKnee(int degrees) = 0;
};
class HexapodLeftLeg : public HexapodLeg
{
public:
HexapodLeftLeg(); // Default constructor required for declarations (does nothing special)
HexapodLeftLeg(int hipLatPin, int hipLonPin, int kneePin, int hipLatPos, int hipLonPos, int kneePos);
~HexapodLeftLeg();
void FlexHipLat(int degrees);
void FlexHipLon(int degrees);
void FlexKnee(int degrees);
void FlexJoints(int hipLatDeg, int hipLonDeg, int kneeDeg);
};
class HexapodRightLeg : public HexapodLeg
{
public:
HexapodRightLeg(); // Default constructor required for declarations (does nothing special)
HexapodRightLeg(int hipLatPin, int hipLonPin, int kneePin, int hipLatPos, int hipLonPos, int kneePos);
~HexapodRightLeg();
void FlexHipLat(int degrees);
void FlexHipLon(int degrees);
void FlexKnee(int degrees);
void FlexJoints(int hipLatDeg, int hipLonDeg, int kneeDeg);
};
#endif