forked from Team612/612-2014
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncodeDistance.cpp
executable file
·49 lines (40 loc) · 1.07 KB
/
EncodeDistance.cpp
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
#include "main.h"
#include "ports.h"
EncodeDistance::EncodeDistance(uint8_t modLA, uint32_t chanLA,
uint8_t modLB, uint32_t chanLB,
uint8_t modRA, uint32_t chanRA,
uint8_t modRB, uint32_t chanRB)
{
EncoderL = new Encoder(modLA, chanLA,
modLB, chanLB);
EncoderR = new Encoder(modRA, chanRA,
modRB, chanRB);
EncoderL->SetDistancePerPulse(dist);
EncoderR->SetDistancePerPulse(dist);
}
EncodeDistance::~EncodeDistance()
{
delete EncoderL;
delete EncoderR;
}
double EncodeDistance::getLDistance()
{
return EncoderL->GetDistance();
}
double EncodeDistance::getRDistance()
{
return EncoderR->GetDistance();
}
double EncodeDistance::getAvgDistance()
{
return (getLDistance() + getRDistance()) / 2;
}
double EncodeDistance::convertTickToDist(double pulse)
{
return (pulse/EncoderR->GetRate());
}
double EncodeDistance::convertDistToTick(double distance)
{
// TODO
return (EncoderR->GetRate());
}