-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathSensors.cpp
96 lines (78 loc) · 1.92 KB
/
Sensors.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <AnalogChannel.h>
#include "ports.h"
#include "Sensors.h"
#include "main.h"
#include "612.h"
// everything in inches
Sensors::Sensors(main_robot* r,
uint8_t usMod, uint32_t usChan, uint8_t isMod, uint32_t isChan,
uint8_t ilMod, uint32_t ilChan,
uint8_t gyMod, uint32_t gyChan)
{
robot = r;
ultrasonic = new AnalogChannel(usMod, usChan);
infraredShooter = new AnalogChannel(isMod, isChan);
infraredLoad = new AnalogChannel(ilMod, ilChan);
//gyro612 = new Gyro(GYMOD, GYCHAN);
// robot -> update -> addFunctions(&updateHelper, (void*)this);
}
Sensors::~Sensors()
{
delete ultrasonic;
delete infraredShooter;
delete infraredLoad;
}
//all values are in inches
float Sensors::getVoltsInfShooter()
{
return infraredShooter->GetVoltage();
}
float Sensors::getVoltsInfLoad()
{
return infraredLoad->GetVoltage();
}
float Sensors::getVoltsUltra()
{
return ((ultrasonic->GetVoltage()));
}
float Sensors::getInfraredShooter()
{
// 18.77cm/V = 7.38976in/V
return (getVoltsInfShooter() * VPMINF );
}
bool Sensors::getInfraredLoad()
{
float loadDistance = getVoltsInfLoad() * VPMINF ;
if(loadDistance < LOAD_THRESHOLD)
return true;
else
return false;
}
float Sensors::getUltrasonic()
{
// 9.8mV/in = 0.0098V/in
return ((getVoltsUltra() / VPIULTRA) + ULTRA_YINT);
}
/*void Sensors::updateHelper(void* instName)
{
Sensors* sensorsObj = (Sensors*)instName;
sensorsObj -> robot -> netcom -> primeLocation(sensorsObj -> getUltrasonic());
}*/
float Sensors::getGyroAngle()
{
float gyAngle = 4.20; //gyro612->GetAngle();
return gyAngle;
}
double Sensors::getGyroRate()
{
double gyRate = 4.20; //gyro612->GetRate();
return gyRate;
}
void Sensors::gyroReset()
{
//gyro612->Reset();
}
void Sensors::setGyroSens(float vpdps /*Volts Per Degree Per Second*/)
{
//gyro612->SetSensitivity(vpdps);
}