Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
lehrkraefte:blc:informatik:glf20:robotik:mgr:start [2021/03/26 06:51] michael.greminger |
lehrkraefte:blc:informatik:glf20:robotik:mgr:start [2021/03/26 12:09] (current) michael.greminger |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Robotik ====== | ====== Robotik ====== | ||
- | {{lehrkraefte: | + | {{lehrkraefte: |
===== Begriffe, Definitionen ===== | ===== Begriffe, Definitionen ===== | ||
Line 33: | Line 33: | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
<code python> | <code python> | ||
- | kommt bald... | + | from simrobot import * |
+ | RobotContext.enableTrace(True) | ||
+ | robot = LegoRobot() | ||
+ | gear = Gear(); | ||
+ | robot.addPart(gear); | ||
+ | |||
+ | gear.forward() | ||
+ | for i in range(3): | ||
+ | gear.rightArc(0.15) | ||
+ | Tools.delay(4000) | ||
+ | gear.right(1100) | ||
+ | robot.exit() | ||
</ | </ | ||
</ | </ | ||
Line 42: | Line 53: | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
<code python> | <code python> | ||
- | kommt bald... | + | from simrobot import * |
+ | RobotContext.enableTrace(True) | ||
+ | robot = LegoRobot() | ||
+ | gear = Gear(); | ||
+ | robot.addPart(gear); | ||
+ | |||
+ | radius = 0.05 | ||
+ | gear.forward() | ||
+ | while not robot.isEscapeHit(): | ||
+ | gear.rightArc(radius) | ||
+ | Tools.delay(2000) | ||
+ | radius = radius * 1.1 | ||
+ | robot.exit() | ||
</ | </ | ||
</ | </ | ||
Line 71: | Line 94: | ||
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
<code python> | <code python> | ||
- | kommt bald... | + | from simrobot import * |
+ | from random import randrange | ||
+ | RobotContext.useBackground(" | ||
+ | RobotContext.setStartPosition(350 + randrange(50), | ||
+ | RobotContext.setStartDirection(135+randrange(90)) | ||
+ | |||
+ | robot = LegoRobot() | ||
+ | gear = Gear() | ||
+ | robot.addPart(gear) | ||
+ | ls = LightSensor(SensorPort.S3) | ||
+ | robot.addPart(ls) | ||
+ | ls.activate(True) | ||
+ | gear.forward() | ||
+ | |||
+ | while not robot.isEscapeHit(): | ||
+ | v = ls.getValue() | ||
+ | if v > 500: | ||
+ | break | ||
+ | | ||
+ | robot.exit() | ||
</ | </ | ||
</ | </ |