This is an old revision of the document!
Your First EEROS Project
First of all, make sure that you have set up your environment as described in Install and Setup Development Environment. The following example shows a typical EEROS application.
int main() { std::cout << "SCARA Robot Control started" << std::endl; // Define logger StreamLogWriter w(std::cout); w.show(); Logger<LogWriter>::setDefaultWriter(&w); // Get HAL istance HAL& hal = HAL::instance(); // Get Control System instance MyControlSystem controlSystem; // Get Safety System instance double dt = 0.001; MySafetyProperties safetyProperties(&controlSystem); SafetySystem safetySystem (safetyProperties, dt); Sequencer sequencer; MySequencer mainSequence(&sequencer, &controlSystem, &safetySystem); sequencer.start(&mainSequence); while(sequencer.getState() != state::terminated) { usleep(10000); } controlSystem.stop(); safetySystem.shutdown(); sequencer.shutdown(); std::cout << "SCARA Robot Control stopped" << std::endl; return 0; }
To start, create an instance of the Control System and Safety System. Since the safety system is closely connected to the Hardware which is accessed through the Hardware Abstraction Layer (HAL), inputs and outputs for the HAL have to be defined and assigned to the HAL.
Then you have to define the Safety Properties and start the safety system. The safety system will power-up the system and do all the necessary initialization, such as enabling actors and homing them.
Finally, a sequence has to be defined and assigned to a Sequencer. The program will run as long as the sequencer does not terminate.
Here follows the basic implementation of the three subsystems of a simple EEROS application:
Control System:
.hpp:
.cpp:
Safety System:
.hpp:
.cpp:
Main Sequencer:
.hpp:
.cpp: