This repository has been archived by the owner on Nov 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelta.cpp
72 lines (57 loc) · 1.78 KB
/
delta.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
#include <iostream>
#include <ostream>
#include <fstream>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <eeros/hal/HAL.hpp>
#include <eeros/core/Executor.hpp>
#include <eeros/safety/SafetySystem.hpp>
#include <eeros/logger/StreamLogWriter.hpp>
#include <eeros/sequencer/Sequencer.hpp>
#include "control/DeltaControlSystem.hpp"
#include "safety/DeltaSafetyProperties.hpp"
#include "sequence/MainSequence.hpp"
using namespace eeros;
using namespace eeros::hal;
using namespace eeros::control;
using namespace eeros::safety;
using namespace eeros::logger;
using namespace eeros::sequencer;
using namespace eeduro::delta;
void signalHandler(int signum){
SafetySystem::exitHandler();
Sequencer::instance().abort();
}
int main(int argc, char **argv) {
StreamLogWriter w(std::cout);
Logger::setDefaultWriter(&w);
Logger log;
// w.show();
log.info() << "Start Delta application";
log.info() << "Initializing Hardware...";
HAL& hal = HAL::instance();
hal.readConfigFromFile(&argc, argv);
signal(SIGINT, signalHandler);
// Create the control system
DeltaControlSystem controlSys;
// Create and initialize a safety system
DeltaSafetyProperties safetyProp{controlSys};
SafetySystem safetySys{safetyProp, dt};
controlSys.timedomain.registerSafetyEvent(safetySys, safetyProp.doEmergency);
Calibration calibration{};
calibration.loadDefaults();
if (!calibration.load()) {
log.warn() << "could not load calibration";
}
auto& seq = Sequencer::instance();
MainSequence mainSequence("Main Sequence", seq, controlSys, safetySys, safetyProp, calibration);
seq.addSequence(mainSequence);
mainSequence.start();
auto &executor = Executor::instance();
executor.setMainTask(safetySys);
executor.run();
seq.wait();
log.info() << "Delta application finished";
return 0;
}