User Tools

Site Tools


eeros_architecture:control_system:executor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
eeros_architecture:control_system:executor [2016/10/18 21:42] – created grafeeros_architecture:control_system:executor [2021/02/10 15:28] (current) – [Using the Executor] ursgraf
Line 1: Line 1:
 ====== Executor ====== ====== Executor ======
  
-The executor is responsible to run various different time domains in seperated threads of execution.  +The executor is responsible to run various different time domains in separated threads of execution. The execution periods of different time domains are generally in a harmonic relationship to each other.  
 + 
 +===== Harmonic Tasks ===== 
 +As the following figure shows each harmonic is run by its own thread of execution.  
 +{{ :eeros_architecture:control_system:executor.png?600 | }} 
 +In this example we have the safety system as the main task. It has the fastest execution period together with the time domain 1. The time domain 2 runs with the same period but only after time domain 1 has finished. Time domain 3 has a harmonic relationship to the main task with a ratio of 2. 
 +     
 +===== Using the Executor  ====== 
 +First you have to define the executor. 
 +<code cpp> 
 +  eeros::Executor& executor = eeros::Executor::instance();  
 +</code> 
 + 
 +Next we have to define the main task. In general the main task will be the safety system.  
 +<code cpp> 
 +  SafetySystem ss(properties, 0.001); // runs every millisecond 
 +  executor.setMainTask(ss);  
 +</code> 
 + 
 +Now we create time domains and add it to the executor. 
 +<code cpp> 
 +  eeros::control::TimeDomain td1("td1", 0.001, true); 
 +  executor.add(td1);  
 +</code> 
 + 
 +This creates a time domain which should run in real-time with a period of 1 millisecond. Obviously the time domain has no blocks yet and therefore doesn't do any meaningful work yet. 
 + 
 +You could also create a periodic task as a separate object and assign it a time domain as follows. 
 +<code cpp> 
 +  eeros::control::TimeDomain td1("td1", 0.001, true); 
 +  eeros::task::Periodic per1("per1", 0.001, td1); 
 +  executor.add(per1);  
 +</code> 
 + 
 +Finally you have to start the executor with: 
 +<code cpp> 
 +  executor.run();  
 +</code> 
 + 
 +This call does not complete until you stop the main task with a special signal. 
 + 
 +IMPORTANT Please make sure to run an application using the executor with root privileges. This is necessary for the executor to be able to create threads with realtime priorities.  
 + 
 +===== Add More Time Domains ====== 
 +The picture at the top of this page shows another two time domains. Time domain 2 runs after time domain 1. It can be created and added to time domain 1 as follows 
 +<code cpp> 
 +  eeros::control::TimeDomain td1("td1", 0.001, true); 
 +  eeros::task::Periodic per1("per1", 0.001, td1); 
 +  eeros::control::TimeDomain td2("td2", 0.001, true); 
 +  eeros::task::Periodic per2("per2", 0.001, td2); 
 +  per1.after.push_back(per2); 
 +  executor.add(per1);  
 +</code> 
 +Time domain 3 runs concurrently to time domain 1. It can therefore be created simply with 
 +<code cpp> 
 +  eeros::control::TimeDomain td3("td3", 0.002, true); 
 +  executor.add(td3);  
 +</code>
eeros_architecture/control_system/executor.1476819770.txt.gz · Last modified: 2016/10/18 21:42 by graf