-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencoderStuff.h
More file actions
42 lines (31 loc) · 898 Bytes
/
encoderStuff.h
File metadata and controls
42 lines (31 loc) · 898 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
40
41
42
#pragma once
#include <Zumo32U4.h>
class encoderStuff {
public:
void resetEncoderCounts();
void correctOffset(int, int);
/// for movement turning amount of degrees
void setExpectedLeftEncoderCount(int);
/// for movement turning precise amount of degrees
void setExpectedRightEncoderCount(int);
int getCorrectLeft();
int getCorrectRight();
/// debug method
void printCorrectionValues();
private:
Zumo32U4Encoders encoders;
/// old name: calculateCorrectStrengt(int x)
///
/// make motor strength more realistic
int NormaliseStrength(int32_t);
int expectedLeftEncoderCount = 0;
int expectedRightEncoderCount = 0;
double offsetLeftEncoderCount = 1;
double offsetRightEncoderCount = 1;
int correctLeft = 0;
int correctRight = 0;
int countsLeft = 0;
int countsRight = 0;
int lastEncodersCheckTime = 0;
const int ALLOWED_SPEED_OFFSET = 20;
};