/
main.cpp
53 lines (35 loc) · 1.14 KB
/
main.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
#include <hal/HAL.h>
#include <iostream>
#include <chrono>
#include <thread>
#include "rev/CANBridge.h"
#include "rev/MockDS.h"
#include <rev/CANSparkMax.h>
int main(int argc, char** argv) {
HAL_Initialize(500, 0);
frc::MockDS ds;
ds.start();
HAL_ObserveUserProgramStarting();
ds.enable();
std::cout << "Running Scan..." << std::endl;
auto handle = CANBridge_Scan();
std::cout << "Scan Complete" << std::endl;
int numDevices = CANBridge_NumDevices(handle);
std::cout << "Found " << numDevices << " Devices: " << std::endl;
if (numDevices == 0) {
return 0;
}
for (int i=0;i<numDevices;i++) {
std::cout << "\t" << CANBridge_GetDeviceName(handle, i) << " - " << CANBridge_GetDeviceDescriptor(handle, i) << std::endl;
}
if (numDevices == 1) {
std::cout << "Registering single device to HAL" << std::endl;
CANBridge_RegisterDeviceToHAL(CANBridge_GetDeviceDescriptor(handle, 0), 0, 0);
}
CANBridge_FreeScan(handle);
std::cout << "Starting Robot... Press 'a' to stop" << std::endl;
rev::CANSparkMax m_motor(61, rev::CANSparkMax::MotorType::kBrushed);
m_motor.Set(0.5);
std::cin.get();
return 0;
}