A monitor allows to supervise certain conditions of a robot during a sequence. Examples could include the following situations:
All these situations have in common, that a user does want to check for a given set of conditions during the running of the sequence (including subsequences or steps).
Implement your condition by extending the class Condition
as given below:
class MyCondition : public Condition { public: MyCondition() : { } // initialize any attributes necessary bool validate() {return yourTest;} // implement whatever your condition should check };
The method validate must return true
in order for the monitor checking this condition to fire.
Every Sequence or step already has a timeout condition (of class ConditionTimeout
). It allows for checking a maximum duration of execution. Also, every sequence has an abort condition (of class ConditionAbort
). This condition makes it possible to abort a sequence, e.g. by pressing Ctrl-C
.
Make sure that your condition is properly set and reset. To give an example: A condition might be the state of a button. As soon as the button is pressed, the condition might return true
and the associated monitor fires. This might lead to an abortion of the current sequence together with all its blocking subsequences. This might take some time. You have to make sure that the condition delivers true
until this work is done. If the condition is simply the state of the button this might be too short, if you press only for a short time.
The second step is to define a monitor and assign it a condition.
SequenceA seq(...); // define a sequence MyCondition myCondition; // and a condition Monitor myMonitor("myMon", &seq, myCondition, SequenceProp::abort); // create an associated monitor setExceptionSequence(exceptionSeq); // choose a sequence to run in case of a condition to become false seq.addMonitor(&myMonitor); // and add it to the sequence
Here again, every sequence or step already has a timeout monitor which helps to check its associated timeout condition. A second monitor checks the abort condition.