User Tools

Site Tools


getting_started:tutorials:sequencer4

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
getting_started:tutorials:sequencer4 [2018/06/28 13:36] grafgetting_started:tutorials:sequencer4 [2021/03/31 15:40] (current) – [Monitor Checking two Sequences] ursgraf
Line 1: Line 1:
-====== How to Organize Sequences and Steps ====== 
-Sometimes its not obvious what sould go into a separate step and what to pack directly into a sequence. Let's study the following example. \\ 
-A robot finished a homing sequence. It should move to a ready position before further action can happen. For this purpose a sequence ''readying'' is implemented as follows: 
-<code cpp> 
-class Readying : public Sequence { 
-public: 
-  Readying(std::string name, Sequencer& seq) : Sequence(name, seq) {setNonBlocking();} 
  
-  int action() { 
-    cs.pathPlanner.move(readyPos);  // we assume that the control system comprises of a path planner 
-  } 
-  
-  bool checkExitCondition() { 
-    bool end = cs->pathPlanner.endReached(); 
-    if (end) safetySystem->triggerEvent(safetyProperties->readyDone); 
-    return end; 
-  } 
-}; 
-</code> 
  
-The sequence consists of a single action - set the final destination of the path planner. It will terminate as soon as the path planner has reached this position. Before returning it will trigger a safety event which causes the safety system to switch to the next level. +====== Sequence with two Monitors ======
  
-==== Alternative Solution ==== +In the EEROS library you will find a directory with examples. For this example see [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest40.cpp|SequencerTest40.cpp]]. 
-The same goal as above could be achieved as follows: + 
-<code cpp> +Open a shell in the build directory of your EEROS library and run  
-class Move : public Step { +<code> 
-  Move(std::string nameSequencer& seqBaseSequence* caller) : Step(nameseqcaller) { } +$ ./examples/sequencer/sequencerTest40 
-   +</code>  
-  int action() { + 
-    cs.pathPlanner.move(readyPos);  // we assume that the control system comprises of a path planner +This example shows a sequence with two associated monitors. The ''Main Sequence'' tries to run several steps called ''Step A''. After each step a counter is incremented. A monitor checks for this count to reach a given level (''MyMonitor''). As soon as this happens an exception sequence is started. After termination of the exception sequence the original sequence resumes because the monitor property is set to ''resume''. The ''Main Sequence'' continues and is soon interrupted by its timeout monitor because its timeout limit has expired. The timeout monitor has no exception sequence assigned to it and immediately aborts the ''Main Sequence'' and with it the application because its monitor property is set to //abort//
-  } +[{{ .:sequencerexample4.png?450 | //Two monitors checking the same sequence// }}] 
-  +\\ 
-  bool checkExitCondition() { + 
-    return cs->pathPlanner.endReached(); + 
-  } + 
-}+==== Altering the Monitor Behavior ==== 
 +Change the behavior of ''My Monitor'' to ''restart'', recompile, and observe what happens. After the exception sequence the ''Main Sequence'' restarts. This causes the counter to start with 0 and the timeout will be reset as well. Hence, the timeout monitor will never fire.\\ 
 +If you change the behavior of the timeout monitor to ''restart''things get more complicated. ''MyMonitor'' will firethe exception sequence will runthe ''Main Sequence'' will resumeand the timeout monitor will fire. This monitor has no exception sequence but will simply restart the whole procedure.  
 + 
 +===== Monitor Checking two Sequences ===== 
 +The next example is [[https://github.com/eeros-project/eeros-framework/blob/master/examples/sequencer/SequencerTest41.cpp|SequencerTest41.cpp]]. 
 +Open a shell in the build directory of your EEROS library and run  
 +<code> 
 +$ ./examples/sequencer/sequencerTest41 
 +</code 
 + 
 +This example shows a sequence with two associated monitorsThe ''Main Sequence'' tries to run several steps called ''Step A''. After each step a counter is incremented. A monitor checks for this count to reach a given level (''MyMonitor''). As soon as this happens an exception sequence is started. After termination of the exception sequence the original sequence resumes because the monitor property is set to ''resume''. The ''Main Sequence'' continues and is soon interrupted by its timeout monitor because its timeout limit has expired. The timeout monitor also has an exception sequence assigned to it. After this the sequence continues because its monitor behavior is set to //resume// as well. Both monitors will fire again as their conditions are met again before the sequence finally terminates 
 +[{{ .:sequencerexample5.png?450 | //Two monitors with two exception sequences// }}
 +\\
  
-class Readying : public Sequence { 
-public: 
-  Readying(std::string name, Sequencer& seq) : Sequence(name, seq), move("move", seq, this) {setNonBlocking();} 
  
-  int action() { 
-    move(readyPos); 
-    safetySystem->triggerEvent(safetyProperties->readyDone); 
-  } 
-private: 
-  Move move; 
-}; 
-</code> 
getting_started/tutorials/sequencer4.1530185781.txt.gz · Last modified: 2018/06/28 13:36 (external edit)