-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservoHandler.hpp
More file actions
39 lines (34 loc) · 996 Bytes
/
servoHandler.hpp
File metadata and controls
39 lines (34 loc) · 996 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
39
#include <vector>
using namespace std;
struct servoData {
float angle;
float time;
int pin;
bool isLastServo;
};
class servoHandler {
// I can foresee that some servos might have different signal time // ranges, but for now i am not considering that case.
public:
servoHandler(int nServos, vector<int> indexed_list, float min_ms, float max_ms, int resolution);
~servoHandler() {};
private:
int timeResolution;
int sortTimes();
float popAngle();
float popTime();
int popPin();
// Variables
vector<float> time_vector; // Saves activation time
vector<float> angle_vector; // saves converted angle times
vector<int> index_vector; // saves the pins for each servo
vector<int> fixed_index_vector; // Saves original pins
float MIN_ms, MAX_ms;
int nServos, iterator;
public:
int setAngles(vector<float> angles);
int setTimes(vector<float> times);
int setPins(vector<int> indexed_list);
servoData popServo();
int nZeroTimeServos();
int reset();
};