This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
State.h
76 lines (55 loc) · 1.45 KB
/
State.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef FIRMWARE_STATE_H
#define FIRMWARE_STATE_H
#include <Arduino.h>
#include "Processes.h"
#include "Adafruit_NeoPixel.h"
#define motor_count 3
#define NUM_PIXELS 10
#define PIXEL_PIN 5
/*
Generic motor structure, carries around all needed information.
IT IS ASSUMED that the encoders are connected in the same order
that the motors are added to the motors array.
*/
typedef struct {
int port;
int power;
int desired_power;
int direction;
long disp;
int disp_delta;
float speed;
float delta_speed;
unsigned long last_write;
} motor;
enum GrabberState {
Opening, Holding, Open, Closing, Squeezing, Closed
};
enum KickerState {
Kicking, Idle
};
class State {
public:
void setup();
int battery;
uint8_t status_led;
const uint8_t status_led_pin = 13;
float heading;
motor* motors[motor_count];
// Rotation stuff
long initial_displacement[motor_count];
long rotation_delta;
process* rotation_process;
// Allows kicking and grabbing to execute without blocking
process* kick_handler;
process* grab_handler;
process* shuntkick_handler;
KickerState kicker_state;
GrabberState grabber_state;
long grabber_diff;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
// For holonomics
static const float velo_coupling_mat[3][3];
};
extern State state;
#endif //FIRMWARE_STATE_H