-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wheel.cpp
41 lines (33 loc) · 758 Bytes
/
Wheel.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
/*
* Wheel.cpp
*
* Created on: Jul 10, 2016
* Author: amarnath
*/
#include "Wheel.h"
Wheel::Wheel() {
// TODO Auto-generated constructor stub
this->diameter = 10.0 ; // wheel diameter
this->nSlots = 24; // encoder slots
this->dAngle = 0.0; // radians
this->totalAngle = 0.0; // radians
}
Wheel::~Wheel() {
// TODO Auto-generated destructor stub
}
void Wheel::rotate(float RPM, float runTime){
// No. of Rotations * PI
dAngle = 3.14*RPM*runTime/60.0;
totalAngle += dAngle;
}
int Wheel::getSlotsPassed(){
// nSlots for complete rotation
// Calculate for RPM*time no of rotations
return int(nSlots*dAngle/(2*3.14));
}
float Wheel:: getAngleRotated(){
return this->dAngle;
}
float Wheel:: getDiameter(){
return this->diameter;
}