summaryrefslogtreecommitdiff
path: root/robot/problems/introduction/wall1m/naloga06_wall1m.py
diff options
context:
space:
mode:
authorMartin Možina <martin.mozina@fri.uni-lj.si>2015-10-14 18:08:44 +0200
committerMartin Možina <martin.mozina@fri.uni-lj.si>2015-10-14 18:08:44 +0200
commit531bde7a2fe3d643e9b6ffe690405b6cc07c4964 (patch)
tree9fcdd54ec25cacc32cd5aaacfb731c174278fab8 /robot/problems/introduction/wall1m/naloga06_wall1m.py
parent1b936a961e39b2a71b5a773776474446f0c58447 (diff)
parentb1deb24a05a380450ed9dc77c3155a16bd204dfc (diff)
Merge branch 'master' of 192.168.15.97:codeq-problems
Diffstat (limited to 'robot/problems/introduction/wall1m/naloga06_wall1m.py')
-rw-r--r--robot/problems/introduction/wall1m/naloga06_wall1m.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/robot/problems/introduction/wall1m/naloga06_wall1m.py b/robot/problems/introduction/wall1m/naloga06_wall1m.py
new file mode 100644
index 0000000..e3be37c
--- /dev/null
+++ b/robot/problems/introduction/wall1m/naloga06_wall1m.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+# coding=utf-8
+
+print ("""
+Naloga 6:
+ Robota postavi pred zid, tako da bo od njega oddaljen vsaj 1 m; vmes naj ne bo ovir.
+ Napisi program, s katerim bo robot vozil naravnost proti zidu z 80% mocjo.
+ Na razdalji 50 cm od zida naj robot zmanjsa hitrost na 20%, na razdalji 20 cm od zida pa naj se ustavi.
+""")
+import sys
+sys.path.append('/home/user/codeq')
+import time
+from ev3dev import *
+from mindstorms_widgets import mindstorms_widgets
+
+robot = mindstorms_widgets()
+robot.connect_motor( 'left' )
+robot.connect_motor( 'right' )
+robot.connect_sensor( 'ultrasonic' )
+robot.move_steering( 'on', power=80 )
+while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 500:
+ pass
+robot.move_steering( 'on', power=20 )
+while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 200:
+ pass
+robot.move_steering( 'off' )
+