getting_started:tutorials:mockrobot
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
getting_started:tutorials:mockrobot [2019/03/28 12:30] – [Sequencer] graf | getting_started:tutorials:mockrobot [2021/03/31 17:45] (current) – [Safety System] ursgraf | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Mock Robot Example ====== | ====== Mock Robot Example ====== | ||
- | This tutorial demonstrates an EEROS application complete with a control system, a safety system, and a sequencer. You can find the code in the directory | + | This tutorial demonstrates an EEROS application complete with a control system, a safety system, and a sequencer. You can find the code under [[https:// |
+ | |||
+ | Start the program | ||
+ | <code cpp> | ||
+ | $ sudo ./examples/system/ | ||
+ | </ | ||
===== The Full Picture ===== | ===== The Full Picture ===== | ||
This example does not need any hardware. The moving of a robot is pretended by using integrators summing up. This represents the position on an axis. Before a robot can be moved it has usually to be homed. | This example does not need any hardware. The moving of a robot is pretended by using integrators summing up. This represents the position on an axis. Before a robot can be moved it has usually to be homed. | ||
- | The main application defines a control system and a safety system. The safety system is assigned as main task and passed to the executor. Further, a main sequence is defined and added to the sequencer | + | The main application defines a control system and a safety system. The safety system is assigned as main task and passed to the executor. Further, a main sequence is defined and added to the sequencer |
<code cpp> | <code cpp> | ||
Line 21: | Line 26: | ||
MainSequence mainSeq(" | MainSequence mainSeq(" | ||
sequencer.addSequence(mainSeq); | sequencer.addSequence(mainSeq); | ||
- | mainSeq.start(); | + | mainSeq(); |
... | ... | ||
Line 43: | Line 48: | ||
===== Safety System ===== | ===== Safety System ===== | ||
The safety system has four levels and a couple of safety events to switch between these levels. | The safety system has four levels and a couple of safety events to switch between these levels. | ||
- | [{{ : | + | [{{ : |
The event '' | The event '' | ||
Line 55: | Line 60: | ||
} else if(ss.getCurrentLevel() == sp.slReady) { | } else if(ss.getCurrentLevel() == sp.slReady) { | ||
wait(2); | wait(2); | ||
+ | cs.sw.switchToInput(1); | ||
ss.triggerEvent(sp.startMoving); | ss.triggerEvent(sp.startMoving); | ||
} else if(ss.getCurrentLevel() == sp.slMoving) { | } else if(ss.getCurrentLevel() == sp.slMoving) { | ||
Line 61: | Line 67: | ||
wait(0.1); | wait(0.1); | ||
} | } | ||
+ | return 0; | ||
} | } | ||
</ | </ | ||
Line 73: | Line 80: | ||
int action() { | int action() { | ||
- | cs.setpointX.setValue(0.1); | + | cs.setpoint.setValue({0.1, 0.1}); |
- | cs.setpointY.setValue(0.1); | + | |
} | } | ||
bool checkExitCondition() { | bool checkExitCondition() { | ||
- | bool done = cs.iX.getOut().getSignal().getValue() >= 1.0 && | + | Matrix< |
- | if (cs.iX.getOut().getSignal().getValue() | + | bool done = val[0] |
- | if (cs.iY.getOut().getSignal().getValue() >= 1.0) cs.setpointY.setValue(0); | + | if (val[0] |
+ | if (val[1] | ||
if (done) ss.triggerEvent(sp.homingDone); | if (done) ss.triggerEvent(sp.homingDone); | ||
return done; | return done; | ||
} | } | ||
- | private: | ||
MockRobotControlSystem& | MockRobotControlSystem& | ||
+ | SafetySystem& | ||
+ | MockRobotSafetyProperties& | ||
}; | }; | ||
</ | </ | ||
Line 96: | Line 104: | ||
MoveUp(std:: | MoveUp(std:: | ||
int action() { | int action() { | ||
- | | + | |
- | cs.setpointY.setValue(0.3); | + | cs.pp.move(dest); |
+ | return | ||
} | } | ||
- | bool checkExitCondition() {return cs.iX.getOut().getSignal().getValue() >= 5.0;} | + | bool checkExitCondition() {return cs.pp.endReached();} |
- | private: | + | |
MockRobotControlSystem& | MockRobotControlSystem& | ||
}; | }; | ||
Line 108: | Line 116: | ||
MoveDown(std:: | MoveDown(std:: | ||
int action() { | int action() { | ||
- | cs.setpointX.setValue(-0.6); | + | |
- | | + | |
+ | | ||
} | } | ||
- | bool checkExitCondition() {return cs.iX.getOut().getSignal().getValue() <= -5.0;} | + | bool checkExitCondition() {return cs.pp.endReached();} |
- | private: | + | |
MockRobotControlSystem& | MockRobotControlSystem& | ||
}; | }; | ||
Line 128: | Line 136: | ||
moveDown(); | moveDown(); | ||
} | } | ||
+ | return 0; | ||
} | } | ||
- | private: | ||
MoveUp moveUp; | MoveUp moveUp; | ||
MoveDown moveDown; | MoveDown moveDown; |
getting_started/tutorials/mockrobot.1553772605.txt.gz · Last modified: 2019/03/28 12:30 by graf