-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (49 loc) · 1.78 KB
/
main.cpp
File metadata and controls
58 lines (49 loc) · 1.78 KB
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
#include <iostream>
#include "classes.h"
#include <chrono>
#include <thread>
using namespace std;
using Clock = chrono::high_resolution_clock;
using Duration = chrono::duration<int, milli>;
int main() {
/*
cout << "Program started\n";
unique_ptr<VehicleController> System(new VehicleController());
unique_ptr<PIDController> PID(new PIDController(2.0, 0.1, 1.5, 0.01 ));
const int period_ms = 10; // the period of the occuration
const Duration period = Duration(period_ms);
chrono::time_point<Clock> nextTime = Clock::now();
while(true) {
//Delay by 10ms
this_thread::sleep_until(nextTime);
//Works, updates
double outputPID = PID->compute(20,19);
System->update();
cout << outputPID << endl << "Program is working\n";
// Updating nextTime to be suitable and periodly
nextTime += period;
}
/*
CanFrame frame;
CanManeger M;
float throttle = 60.2;
float brake = -45;
float steering = -35;
M.packingCommandControl(throttle,brake,steering,frame);
cout << "ID: 0x" << hex << frame.id << endl;
cout << "Data: " <<dec<< int(frame.data[0]) << endl;
cout << "Data: " <<dec<< int(frame.data[1]) << endl;
cout << "Data: " <<dec<< int(frame.data[2]) << endl;
//Testing the rolling attack and checksum
for(int i =0; i < 20;i++) {
throttle += 1.0f;
M.packingCommandControl(throttle,brake,steering,frame);
cout << "Msg " << i+1
<< " | Counter (Byte 6): " << (int)frame.data[6]
<< " | Checksum (Byte 7): 0x" << hex << (int)frame.data[7] << dec
<< " | Data[0]: " << (int)frame.data[0] // Print first data byte to verify inputs
<< endl;
}
*/
return 0;
}