summaryrefslogtreecommitdiff
path: root/robot/problems/introduction/gyrosquare/naloga08_gyroSquare.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/gyrosquare/naloga08_gyroSquare.py
parent1b936a961e39b2a71b5a773776474446f0c58447 (diff)
parentb1deb24a05a380450ed9dc77c3155a16bd204dfc (diff)
Merge branch 'master' of 192.168.15.97:codeq-problems
Diffstat (limited to 'robot/problems/introduction/gyrosquare/naloga08_gyroSquare.py')
-rw-r--r--robot/problems/introduction/gyrosquare/naloga08_gyroSquare.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/robot/problems/introduction/gyrosquare/naloga08_gyroSquare.py b/robot/problems/introduction/gyrosquare/naloga08_gyroSquare.py
new file mode 100644
index 0000000..ec0dd2f
--- /dev/null
+++ b/robot/problems/introduction/gyrosquare/naloga08_gyroSquare.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+# coding=utf-8
+
+print ("""
+Naloga 8:
+ Robot naj prevozi kvadrat s stranico 20 cm; pri tem naj si pomaga z ziroskopom.
+""")
+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( 'gyro' )
+
+robot.gyro_set_mode( 'angle' )
+robot.reset_gyro()
+
+power = 20
+def forward_and_turnRight(power, angle):
+ robot.move_steering( 'on_for_seconds', direction=0, power=power, seconds=2 )
+ robot.move_tank( 'on', lr_power=[power,-power] )
+ while robot.gyro_sensor_measure( 'angle' ) < angle:
+ pass
+ robot.move_tank( 'off' )
+
+forward_and_turnRight(power, 89)
+forward_and_turnRight(power, 179)
+forward_and_turnRight(power, 269)
+forward_and_turnRight(power, 359)