summaryrefslogtreecommitdiff
path: root/robot/problems
diff options
context:
space:
mode:
authorMartin Možina <martin.mozina@fri.uni-lj.si>2015-12-28 10:23:46 +0100
committerMartin Možina <martin.mozina@fri.uni-lj.si>2015-12-28 10:23:46 +0100
commit165c7165bb2184c9c9e0576a074ba4f29052bf8f (patch)
tree9b86dbbd1d4c39b52bfd7f54cfb13c2354727a53 /robot/problems
parent4cdea335b0951e3c12dfb7b906f958d6b5be25c6 (diff)
parentc1bb0d56b2c0482c766d094c65fdf0fd9d1aa0ba (diff)
Merge branch 'master' of 192.168.15.97:codeq-problems
Conflicts: python/problems/functions/palindrome/sl.py python/problems/functions/palindromic_numbers/sl.py
Diffstat (limited to 'robot/problems')
-rw-r--r--robot/problems/introduction/circle20/common.py5
-rw-r--r--robot/problems/introduction/circle20/en.py24
-rw-r--r--robot/problems/introduction/circle20/sl.py12
-rw-r--r--robot/problems/introduction/countlines/common.py11
-rw-r--r--robot/problems/introduction/countlines/en.py27
-rw-r--r--robot/problems/introduction/countlines/naloga10_countLines.py3
-rw-r--r--robot/problems/introduction/countlines/sl.py13
-rw-r--r--robot/problems/introduction/en.py2
-rw-r--r--robot/problems/introduction/followline/common.py12
-rw-r--r--robot/problems/introduction/followline/en.py36
-rw-r--r--robot/problems/introduction/followline/naloga12_followLine.py3
-rw-r--r--robot/problems/introduction/followline/sl.py15
-rw-r--r--robot/problems/introduction/forward/common.py3
-rw-r--r--robot/problems/introduction/forward/en.py20
-rw-r--r--robot/problems/introduction/forward/sl.py10
-rw-r--r--robot/problems/introduction/forward1m/common.py3
-rw-r--r--robot/problems/introduction/forward1m/en.py23
-rw-r--r--robot/problems/introduction/forward1m/sl.py16
-rw-r--r--robot/problems/introduction/gyro90/common.py7
-rw-r--r--robot/problems/introduction/gyro90/sl.py11
-rw-r--r--robot/problems/introduction/gyrosquare/common.py24
-rw-r--r--robot/problems/introduction/gyrosquare/sl.py11
-rw-r--r--robot/problems/introduction/mindstorms_widgets_OLD.py1
-rw-r--r--robot/problems/introduction/printcolors/common.py4
-rw-r--r--robot/problems/introduction/printcolors/naloga09_printColors.py3
-rw-r--r--robot/problems/introduction/printcolors/sl.py13
-rw-r--r--robot/problems/introduction/rotateback/common.py3
-rw-r--r--robot/problems/introduction/rotateback/naloga11_rotateBack.py3
-rw-r--r--robot/problems/introduction/rotateback/sl.py12
-rw-r--r--robot/problems/introduction/sl.py2
-rw-r--r--robot/problems/introduction/spotturn90/common.py5
-rw-r--r--robot/problems/introduction/spotturn90/sl.py11
-rw-r--r--robot/problems/introduction/square20/common.py3
-rw-r--r--robot/problems/introduction/square20/sl.py11
-rw-r--r--robot/problems/introduction/wall1m/common.py7
-rw-r--r--robot/problems/introduction/wall1m/sl.py14
36 files changed, 302 insertions, 81 deletions
diff --git a/robot/problems/introduction/circle20/common.py b/robot/problems/introduction/circle20/common.py
index 879f198..4d283d0 100644
--- a/robot/problems/introduction/circle20/common.py
+++ b/robot/problems/introduction/circle20/common.py
@@ -10,14 +10,11 @@ number = 5
visible = True
solution = '''\
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
-
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
robot.connect_motor( 'right' )
-fct = 9 # full circle time
+fct = 8.9 # full circle time
rad = 20 # Direction to make a good radius for the circle
robot.move_steering( 'on_for_seconds', direction=rad, power=40, seconds=fct )
'''
diff --git a/robot/problems/introduction/circle20/en.py b/robot/problems/introduction/circle20/en.py
index 8210d71..d2c410c 100644
--- a/robot/problems/introduction/circle20/en.py
+++ b/robot/problems/introduction/circle20/en.py
@@ -1,14 +1,32 @@
# coding=utf-8
import server
-mod = server.problems.load_language('python', 'en')
+mod = server.problems.load_language('robot', 'en')
id = 205
name = 'Circle 20 cm'
slug = 'Circle 20 cm'
description = '''\
-'''
+<p>Write a program that will make the robot drive in circle (r=20cm) and stop after one loop.</p>'''
hint = {
-
+ 'mW_init':mod.hint['init'],
+ 'connectMotorLeft':mod.hint['connectMotorLeft'],
+ 'connectMotorRight':mod.hint['connectMotorRight'],
+ 'moveSteering':mod.hint['moveSteering'],
+ 'onForSeconds':mod.hint['onForSeconds'],
+ 'direction':mod.hint['direction']+['''<p>The value of this parameter should be such that would make the robot circle with radius 20cm. This value highly depends on the construction of the robot.</p>''',
+ '''<p><code>robot.move_steering( 'on_for_seconds', direction=20, ... )</code>.</p>'''],
+ 'seconds':mod.hint['seconds']+['''<p>Experimentally determine the time (in seconds) the robot needs for one loop.</p>''',
+ '''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</code>.</p>'''],
}
+
+plan = ['''\
+<p>The program should:</p>
+<ol>
+ <li>create a mindstorms_widgets() object, which represents the robot in your code.</li>
+ <li>connect the driving motors.</li>
+ <li>calculate the turn so that the robot would drive in circle with radius 20 cm.</li>
+ <li>synchronize the motors and run them for a specified time, so that the robot stops after one round.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/circle20/sl.py b/robot/problems/introduction/circle20/sl.py
index 219f9c7..735458a 100644
--- a/robot/problems/introduction/circle20/sl.py
+++ b/robot/problems/introduction/circle20/sl.py
@@ -13,7 +13,7 @@ hint = {
'''<p><code>robot.connect_motor( 'left' )</code>.</p>'''],
'connectMotorRight':['''<p>Robotu priključi desni motor</p>''',
'''<p><code>robot.connect_motor( 'right' )</code>.</p>'''],
- 'moveSteering':['''<p>Sinhroniziraj motorja in ju zaženi za 3 sekunde.</p>''',
+ 'moveSteering':['''<p>Sinhroniziraj motorja.</p>''',
'''<p>Za sinhronizirano vožnjo je najbolj primerna metoda <code>robot.move_steering( ... )</code>.</p>'''],
'onForSeconds':['''<p>Prvi argument metode <code>robot.move_steering</code> naj pove, da bo delovanje motorjev časovno omejeno.</p>''',
'''<p><code>robot.move_steering('on_for_seconds', ... )</code>.</p>'''],
@@ -24,3 +24,13 @@ hint = {
'''<p>Za dani polmer izmeri čas, ki ga robot potrebuje za en obhod.</p>''',
'''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</code>.</p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Izračunamo ostrino zavoja, pri kateri bo robot vozil po krogu s polmerom 20 cm.</li>
+ <li>Sinhronizirano poženemo oba motorja za premik v izračunani smeri in časovno omejimo na en obhod.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/countlines/common.py b/robot/problems/introduction/countlines/common.py
index 5b8db2e..bf5343b 100644
--- a/robot/problems/introduction/countlines/common.py
+++ b/robot/problems/introduction/countlines/common.py
@@ -11,8 +11,6 @@ visible = True
solution = '''\
import time
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
color_table = ['none', 'black', 'blue', 'green', 'yellow', 'red', 'white', 'brown']
@@ -23,16 +21,17 @@ robot.connect_sensor( 'color' )
robot.move_steering( 'on' )
start = time.time()
-stevec = 0
+counter = 0
color = -1
-while time.time()-start < 2.1:
+while time.time()-start < 1.2:
c = robot.color_sensor_measure( 'color' ) # values: 0-7 see the scale above
if c!=color:
if c!=6 and c!=0:
- stevec += 1
+ counter += 1
color = c
robot.move_steering( 'off' )
-print( "Stevilo crt:", stevec )
+
+print( "Number of lines:", counter )
'''
hint_type = {
diff --git a/robot/problems/introduction/countlines/en.py b/robot/problems/introduction/countlines/en.py
index 8b3b275..7655b21 100644
--- a/robot/problems/introduction/countlines/en.py
+++ b/robot/problems/introduction/countlines/en.py
@@ -1,14 +1,37 @@
# coding=utf-8
import server
-mod = server.problems.load_language('python', 'en')
+mod = server.problems.load_language('robot', 'en')
id = 206
name = 'Count lines'
slug = 'Count lines'
description = '''\
+ Write a program to count the color lines on white background using the robot with a color sensor. The robot should drive forward, crossing the lines and count them.
'''
hint = {
-
+ 'mW_init':mod.hint['init'],
+ 'connectMotorLeft':mod.hint['connectMotorLeft'],
+ 'connectMotorRight':mod.hint['connectMotorRight'],
+ 'moveSteeringOn':mod.hint['moveSteering']+['''<p>Use move_steering method with 'on' as the first parameter <code>robot.move_steering( 'on',... )</code>.</p>'''],
+ 'moveSteeringOff':mod.hint['moveSteeringOff'],
+ 'connectColorSensor':mod.hint['connectColorSensor'],
+ 'colorSensorMeasure':mod.hint['colorSensorMeasure'],
+ 'while':['''<p>Use the while loop: inside, the robot should read the current color and increase the counter when the color changes.</p>''',
+ '''<p>Interrupt the loop after a certain amount of time; determine the time the robot needs to drive over all the colors experimentally; use <code>time.time()</code>.</p>''',
+ '''<p><code>while time.time()-start < 1.5:</code>.</p>'''],
}
+
+plan = ['''\
+<p>The program should:</p>
+<ol>
+ <li>create a mindstorms_widgets() object, which represents the robot in your code.</li>
+ <li>connect the driving motors.</li>
+ <li>connect the color sensor.</li>
+ <li>synchronize the motors and run them so that the robot would move forward.</li>
+ <li>inside the loop, let the robot recognize colors and increase the counter.</li>
+ <li>interrupt the loop after a certain amount of time.</li>
+ <li>stop the motors.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/countlines/naloga10_countLines.py b/robot/problems/introduction/countlines/naloga10_countLines.py
index d1a8326..7079f7c 100644
--- a/robot/problems/introduction/countlines/naloga10_countLines.py
+++ b/robot/problems/introduction/countlines/naloga10_countLines.py
@@ -7,8 +7,7 @@ Naloga 10:
"""
import time
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
+from mindstorms_widgets import *
color_table = ['none', 'black', 'blue', 'green', 'yellow', 'red', 'white', 'brown']
diff --git a/robot/problems/introduction/countlines/sl.py b/robot/problems/introduction/countlines/sl.py
index 4e1c3d4..1f8ea18 100644
--- a/robot/problems/introduction/countlines/sl.py
+++ b/robot/problems/introduction/countlines/sl.py
@@ -24,3 +24,16 @@ hint = {
'''<p>Zanka je lahko časovno omejena, npr. z uporabo metode <code>time.time()</code>.</p>''',
'''<p><code>while time.time()-start < 1.1:</code>.</p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Povežemo barvni senzor.</li>
+ <li>Vklopimo oba motorja tako, da robot vozi naravnost.</li>
+ <li>V zanki naj robot bere barve in jih šteje.</li>
+ <li>Zanka naj se konča po vnaprej določenem času, npr. 3 sekunde.</li>
+ <li>Ustavimo oba motorja.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/en.py b/robot/problems/introduction/en.py
new file mode 100644
index 0000000..5236b4e
--- /dev/null
+++ b/robot/problems/introduction/en.py
@@ -0,0 +1,2 @@
+name = 'Introduction'
+description = 'Motors and sensors.'
diff --git a/robot/problems/introduction/followline/common.py b/robot/problems/introduction/followline/common.py
index 3e84cd4..e28ca35 100644
--- a/robot/problems/introduction/followline/common.py
+++ b/robot/problems/introduction/followline/common.py
@@ -11,8 +11,6 @@ visible = True
solution = '''\
import time
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
@@ -21,10 +19,10 @@ robot.connect_sensor( 'color' )
start = time.time()
while time.time()-start < 10:
- if robot.color_sensor_measure('reflected_light_intensity') < 30:
- L, R = 0, 20
+ if robot.color_sensor_measure('reflected_light_intensity') < 50:
+ L, R = 0, 30
else:
- L, R = 20, 0
+ L, R = 30, 0
robot.move_tank( 'on', lr_power=[L,R])
robot.move_tank( 'off' )
'''
@@ -61,13 +59,13 @@ def hint( code):
if not (has_token_sequence(tokens, ['connect_sensor', '(' ]) and 'color' in code):
return [{'id': 'connectColorSensor'}]
- if not (has_token_sequence(tokens, ['move_steering', '(']) and 'on' in code):
+ if not (has_token_sequence(tokens, ['move_tank', '(']) and 'on' in code):
return [{'id': 'moveTankOn'}]
if not 'lr_power' in code:
return [{'id': 'lrPower'}]
- if not (has_token_sequence(tokens, ['move_steering', '(']) and 'off' in code):
+ if not (has_token_sequence(tokens, ['move_tank', '(']) and 'off' in code):
return [{'id': 'moveTankOff'}]
if not (has_token_sequence(tokens, ['color_sensor_measure', '(']) and 'reflected_light_intensity' in code):
diff --git a/robot/problems/introduction/followline/en.py b/robot/problems/introduction/followline/en.py
index 3f816fe..9a588bc 100644
--- a/robot/problems/introduction/followline/en.py
+++ b/robot/problems/introduction/followline/en.py
@@ -1,14 +1,46 @@
# coding=utf-8
import server
-mod = server.problems.load_language('python', 'en')
+mod = server.problems.load_language('robot', 'en')
id = 207
name = 'Line following'
slug = 'Line following'
description = '''\
+ Write the program for line following. The robot should use the color sensor to follow the black line on white background.
'''
hint = {
-
+ 'mW_init':mod.hint['init'],
+ 'connectMotorLeft':mod.hint['connectMotorLeft'],
+ 'connectMotorRight':mod.hint['connectMotorRight'],
+ 'moveSteeringOn':mod.hint['moveSteering']+['''<p>Use move_steering method with 'on' as the first parameter <code>robot.move_steering( 'on',... )</code>.</p>'''],
+ 'moveSteeringOff':mod.hint['moveSteeringOff'],
+ 'connectColorSensor':mod.hint['connectColorSensor'],
+ 'colorSensorMeasureRLI':mod.hint['colorSensorMeasureRLI'],
+ 'while':['''<p>Use the loop, inside which the robot would follow the line.</p>''',
+ '''<p>The loop should be time constrained, e.g. <code>time.time()</code>.</p>''',
+ '''<p><code>start = time.time()\nwhile time.time()-start < 10:</code>.</p>'''],
+ 'moveTankOn':mod.hint['moveTankOn'],
+ 'lrPower': mod.hint['lrPower'],
+ 'moveTankOff': mod.hint['moveTankOff'],
+ 'time': ['''Use time() to measure time.''',
+ '''<p><code>start = time.time()\nwhile time.time()-start < 10:</code></p>'''],
+ 'if': ['''<p>Use conditional statement inside the loop...</p>''',
+ '''<p>If the robot sees the line, it should turn slightly to go off the line; if the robot sees the background, it should turn towards the line.</p>''']
}
+
+plan = ['''\
+<p>The program should do the following:</p>
+<ol>
+ <li>create a mindstorms_widgets() object, which represents the robot in your code.</li>
+ <li>connect the driving motors.</li>
+ <li>connect the color sensor.</li>
+ <li>in a loop, the robot should read the color sensor to check whether it is on or off line.</li>
+ <li>if it sees black, it should turn right/left; if it sees white, it should turn left/right.</li>
+ <li>break the loop after specified time, 10 seconds.</li>
+ <li>stop the motors.</li>
+</ol>
+<p>Note: you may need to calibrate the color sensor before running the program on the robot.</p>
+'''
+]
diff --git a/robot/problems/introduction/followline/naloga12_followLine.py b/robot/problems/introduction/followline/naloga12_followLine.py
index 347e89e..e6e19a0 100644
--- a/robot/problems/introduction/followline/naloga12_followLine.py
+++ b/robot/problems/introduction/followline/naloga12_followLine.py
@@ -8,8 +8,7 @@ Naloga 12:
import sys
sys.path.append('/home/user/codeq')
import time
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
+from mindstorms_widgets import *
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
diff --git a/robot/problems/introduction/followline/sl.py b/robot/problems/introduction/followline/sl.py
index 848fe2b..cdc6e19 100644
--- a/robot/problems/introduction/followline/sl.py
+++ b/robot/problems/introduction/followline/sl.py
@@ -32,3 +32,18 @@ hint = {
'if': ['''<p>V zanki uporabi pogojni stavek...</p>''',
'''<p>Če robot vidi črto, naj zavije z nje; če vidi podlago, naj zavije proti črti.</p>''']
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Povežemo barvni senzor.</li>
+ <li>V zanki preverjamo, kakšno barvo vidi robot s senzorjem.</li>
+ <li>Če vidi črno, naj zavije desno, če vidi belo, naj zavije levo. (Sledi desnemu robu črte).</li>
+ <li>Zanka naj se konča po vnaprej določenem času, 10 sekund.</li>
+ <li>Ustavimo oba motorja.</li>
+</ol>
+<p>Opomba: potrebna je predhodna kalibracija barvnega senzorja.</p>
+'''
+]
diff --git a/robot/problems/introduction/forward/common.py b/robot/problems/introduction/forward/common.py
index 5a46d86..0793d72 100644
--- a/robot/problems/introduction/forward/common.py
+++ b/robot/problems/introduction/forward/common.py
@@ -9,9 +9,6 @@ number = 1
visible = True
solution = '''\
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
-
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
robot.connect_motor( 'right' )
diff --git a/robot/problems/introduction/forward/en.py b/robot/problems/introduction/forward/en.py
index be73921..400c452 100644
--- a/robot/problems/introduction/forward/en.py
+++ b/robot/problems/introduction/forward/en.py
@@ -1,5 +1,8 @@
# coding=utf-8
+import server
+mod = server.problems.load_language('robot', 'en')
+
name = 'Forward 3s'
slug = 'Forward 3s'
@@ -8,5 +11,20 @@ description = '''\
'''
hint = {
-
+ 'mW_init':mod.hint['init'],
+ 'connectMotorLeft':mod.hint['connectMotorLeft'],
+ 'connectMotorRight':mod.hint['connectMotorRight'],
+ 'moveSteering':mod.hint['moveSteering'],
+ 'onForSeconds':mod.hint['onForSeconds'],
+ 'direction':mod.hint['direction']+['''<p><code>robot.move_steering( 'on_for_seconds', direction=0, ... )</code>.</p>'''],
+ 'seconds':mod.hint['seconds']+['''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</code>.</p>'''],
}
+
+plan = ['''\
+<p>The program should:</p>
+<ol>
+ <li>create a mindstorms_widgets() object, which represents the robot in your code.</li>
+ <li>connect the driving motors.</li>
+ <li>synchronize the motors and run them so that the robot would move forward for 3 seconds.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/forward/sl.py b/robot/problems/introduction/forward/sl.py
index a6f7e86..cd9b096 100644
--- a/robot/problems/introduction/forward/sl.py
+++ b/robot/problems/introduction/forward/sl.py
@@ -21,3 +21,13 @@ hint = {
'seconds':['''<p>Napiši časovno omejitev v sekundah.</p>''',
'''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</code>.</p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Vklopimo oba motorja v sinhronem načinu tako, da robot vozi naravnost.</li>
+ <li>Določimo čas trajanja vožnje 3 sekunde.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/forward1m/common.py b/robot/problems/introduction/forward1m/common.py
index a8dd9ad..201a981 100644
--- a/robot/problems/introduction/forward1m/common.py
+++ b/robot/problems/introduction/forward1m/common.py
@@ -10,9 +10,6 @@ number = 2
visible = True
solution = '''\
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
-
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
robot.connect_motor( 'right' )
diff --git a/robot/problems/introduction/forward1m/en.py b/robot/problems/introduction/forward1m/en.py
index bdf2a45..f47d088 100644
--- a/robot/problems/introduction/forward1m/en.py
+++ b/robot/problems/introduction/forward1m/en.py
@@ -1,15 +1,32 @@
# coding=utf-8
import server
-mod = server.problems.load_language('python', 'en')
+mod = server.problems.load_language('robot', 'en')
id = 208
name = 'Forward 1m'
slug = 'Forward 1m'
description = '''\
-
+ Write a program that would make the robot drive forward and stop after 1 meter.
'''
hint = {
-
+ 'mW_init':mod.hint['init'],
+ 'connectMotorLeft':mod.hint['connectMotorLeft'],
+ 'connectMotorRight':mod.hint['connectMotorRight'],
+ 'moveSteering':mod.hint['moveSteering'],
+ 'onForRotations':mod.hint['onForRotations'],
+ 'direction':mod.hint['direction']+['''<p><code>robot.move_steering( '...', direction=0, ... )</code>.</p>'''],
+ 'seconds':mod.hint['seconds']+['''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</code>.</p>'''],
+ 'rotations':mod.hint['rotations'],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>create a mindstorms_widgets() object, which represents the robot in your code.</li>
+ <li>connect the driving motors.</li>
+ <li>measure the circumference of robot's wheels and compute the number of rotations per meter.</li>
+ <li>synchronize the motors and run them so that the robot would move forward for computed number of rotations.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/forward1m/sl.py b/robot/problems/introduction/forward1m/sl.py
index 8045d58..f6209eb 100644
--- a/robot/problems/introduction/forward1m/sl.py
+++ b/robot/problems/introduction/forward1m/sl.py
@@ -4,7 +4,7 @@ name = 'Naprej 1m'
slug = 'Naprej 1m'
description = '''\
-<p>Napiši program, da bo robot peljal naravnost naprej 3 sekunde in se nato ustavil.</p>'''
+<p>Napiši program, da bo robot peljal 1 meter naravnost in se nato ustavil.</p>'''
hint = {
'mW_init':['''<p>Robota v programu predstavimo z mindstorms_widgets(): <code>robot = mindstorms_widgets()</code>.</p>'''],
@@ -12,12 +12,22 @@ hint = {
'''<p><code>robot.connect_motor( 'left' )</code>.</p>'''],
'connectMotorRight':['''<p>Robotu priključi desni motor</p>''',
'''<p><code>robot.connect_motor( 'right' )</code>.</p>'''],
- 'moveSteering':['''<p>Sinhroniziraj motorja in ju zaženi za 3 sekunde.</p>''',
+ 'moveSteering':['''<p>Sinhroniziraj motorja in ju zaženi.</p>''',
'''<p>Za sinhronizirano vožnjo je najbolj primerna metoda <code>robot.move_steering( ... )</code>.</p>'''],
'onForRotations':['''<p>Prvi argument metode <code>robot.move_steering</code> naj pove, da bo delovanje motorjev določeno s številom obratov.</p>''',
'''<p><code>robot.move_steering('on_for_rotations', ... )</code>.</p>'''],
'direction':['''<p>Navedi smer premikanja motorjev, naravnost = 0.</p>''',
'''<p><code>robot.move_steering( 'on_for_rotations', direction=0, ... )</code>.</p>'''],
- 'rotations':['''<p>Določi število obratov; za koliko obratov naj se zavrtita motorja? Izmeri dolžino 1m, izpisuj obrate <code>print(robot.motor['left'].count_per_rot, robot.motor['right'].count_per_rot)</code> in tako določi ustrezno število obratov.</p>''',
+ 'rotations':['''<p>Določi število obratov; za koliko obratov naj se zavrtita motorja? Izmeri obseg kolesa in preračunaj, koliko obratov je potrebnih za 1m.</p>''',
'''<p><code>robot.move_steering( 'on_for_rotations', direction=0, rotations=5 )</code>.</p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Vklopimo oba motorja v sinhronem načinu tako, da robot vozi naravnost.</li>
+ <li>Glede na obseg koles izračunamo, koliko obratov mora narediti kolo na dolžini 1m; ustrezno nastavimo število obratov, po katerih se robot ustavi.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/gyro90/common.py b/robot/problems/introduction/gyro90/common.py
index 06b4f1d..1828001 100644
--- a/robot/problems/introduction/gyro90/common.py
+++ b/robot/problems/introduction/gyro90/common.py
@@ -10,9 +10,6 @@ number = 7
visible = True
solution = '''\
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
-
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
robot.connect_motor( 'right' )
@@ -21,11 +18,11 @@ robot.connect_sensor( 'gyro' )
robot.gyro_set_mode( 'angle' )
robot.reset_gyro()
-power = 15
+power = 10
robot.move_tank( 'on', lr_power=[power,-power] )
while robot.gyro_sensor_measure() < 90:
pass
-robot.move_tank( 'off' )
+robot.move_tank( 'off', brake_at_end=True )
'''
hint_type = {
diff --git a/robot/problems/introduction/gyro90/sl.py b/robot/problems/introduction/gyro90/sl.py
index 0a82c6d..c0f9451 100644
--- a/robot/problems/introduction/gyro90/sl.py
+++ b/robot/problems/introduction/gyro90/sl.py
@@ -27,3 +27,14 @@ hint = {
'while':['''<p>Program naj teče dokler je kot zasuka manjši od 90 stopinj.</p>''',
'''<p><code>robot.gyro_sensor_measure() < 90:</code></p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Povežemo žiroskop in ga resetiramo.</li>
+ <li>Vklopimo oba motorja tako, da se vrtita z enako močjo, a v različnih smereh; robot se začne obračati na mestu.</li>
+ <li>V zanki merimo kot zasuka in zanko končamo, ko kot doseže 90 stopinj.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/gyrosquare/common.py b/robot/problems/introduction/gyrosquare/common.py
index 5bf6068..79ae131 100644
--- a/robot/problems/introduction/gyrosquare/common.py
+++ b/robot/problems/introduction/gyrosquare/common.py
@@ -10,8 +10,7 @@ number = 8
visible = True
solution = '''\
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
+import time
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
@@ -19,20 +18,21 @@ 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 )
+def forward_and_turnRight(power=10, angle=90):
+ robot.move_steering( 'on_for_seconds', direction=0, power=power, seconds=5 )
+ time.sleep(.5)
+ robot.reset_gyro()
+ robot.gyro_set_mode( 'angle' )
+ print(robot.gyro_sensor_measure( ))
robot.move_tank( 'on', lr_power=[power,-power] )
- while robot.gyro_sensor_measure( 'angle' ) < angle:
+ while robot.gyro_sensor_measure( ) < angle:
pass
- robot.move_tank( 'off' )
+ robot.move_tank( 'off', brake_at_end=True )
+ print(robot.gyro_sensor_measure( ))
-forward_and_turnRight(power, 89)
-forward_and_turnRight(power, 179)
-forward_and_turnRight(power, 269)
-forward_and_turnRight(power, 359)
+for i in range(4):
+ forward_and_turnRight()
'''
hint_type = {
diff --git a/robot/problems/introduction/gyrosquare/sl.py b/robot/problems/introduction/gyrosquare/sl.py
index 16b2c94..7d1f832 100644
--- a/robot/problems/introduction/gyrosquare/sl.py
+++ b/robot/problems/introduction/gyrosquare/sl.py
@@ -36,3 +36,14 @@ hint = {
'seconds':['''<p>Napiši časovno omejitev v sekundah.</p>''',
'''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</code>.</p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Povežemo žiroskop in ga resetiramo.</li>
+ <li>Napišemo funkcijo, ki robota pelje naravnost po stranici, nato pa ga na mestu obrne za 90 stopinj.</li>
+ <li>Zgornja funkcijo pokličemo 4-krat zaporedoma.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/mindstorms_widgets_OLD.py b/robot/problems/introduction/mindstorms_widgets_OLD.py
index 4151133..f69f5c7 100644
--- a/robot/problems/introduction/mindstorms_widgets_OLD.py
+++ b/robot/problems/introduction/mindstorms_widgets_OLD.py
@@ -302,6 +302,7 @@ class mindstorms_widgets:
if mode == 'on' and pulse:
self._led_pulse( color )
pass
+
# the sensor should be perfectly still while resetting the gyro
def resetGyro(self):
self.gs.mode = 'GYRO-RATE'
diff --git a/robot/problems/introduction/printcolors/common.py b/robot/problems/introduction/printcolors/common.py
index 4377c57..79f4d2a 100644
--- a/robot/problems/introduction/printcolors/common.py
+++ b/robot/problems/introduction/printcolors/common.py
@@ -11,8 +11,6 @@ visible = True
solution = '''\
import time
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
color_table = ['none', 'black', 'blue', 'green', 'yellow', 'red', 'white', 'brown']
@@ -24,7 +22,7 @@ robot.connect_sensor( 'color' )
robot.move_steering( 'on')
start = time.time()
color = -1
-while time.time()-start < 2.1:
+while time.time()-start < 1.2:
c = robot.color_sensor_measure('color')
if c!=color:
print( c, color_table[c])
diff --git a/robot/problems/introduction/printcolors/naloga09_printColors.py b/robot/problems/introduction/printcolors/naloga09_printColors.py
index 59dfdb0..2e9d323 100644
--- a/robot/problems/introduction/printcolors/naloga09_printColors.py
+++ b/robot/problems/introduction/printcolors/naloga09_printColors.py
@@ -17,8 +17,7 @@ Naloga 9:
import sys
sys.path.append('/home/user/codeq')
import time
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
+from mindstorms_widgets import *
color_table = ['none', 'black', 'blue', 'green', 'yellow', 'red', 'white', 'brown']
diff --git a/robot/problems/introduction/printcolors/sl.py b/robot/problems/introduction/printcolors/sl.py
index d233b0e..c705eaa 100644
--- a/robot/problems/introduction/printcolors/sl.py
+++ b/robot/problems/introduction/printcolors/sl.py
@@ -34,3 +34,16 @@ hint = {
'''<p><code>while time.time()-start < 1.1:</code>.</p>'''],
'print':['''<p>V zanki na zaslon izpisuj barvo, ki jo zazna robot.</p>''']
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Povežemo barvni senzor.</li>
+ <li>Vklopimo oba motorja tako, da robot vozi naravnost.</li>
+ <li>V zanki naj robot bere barve in vsako izpiše na zaslon.</li>
+ <li>Zanka naj se konča po vnaprej določenem času, npr. 3 sekunde.</li>
+ <li>Ustavimo oba motorja.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/rotateback/common.py b/robot/problems/introduction/rotateback/common.py
index 10cca87..7c8ce44 100644
--- a/robot/problems/introduction/rotateback/common.py
+++ b/robot/problems/introduction/rotateback/common.py
@@ -10,9 +10,6 @@ number = 11
visible = True
solution = '''\
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
-
def sgn(x):
return -1 if x<0 else (1 if x>0 else 0)
diff --git a/robot/problems/introduction/rotateback/naloga11_rotateBack.py b/robot/problems/introduction/rotateback/naloga11_rotateBack.py
index 0bab735..2677f05 100644
--- a/robot/problems/introduction/rotateback/naloga11_rotateBack.py
+++ b/robot/problems/introduction/rotateback/naloga11_rotateBack.py
@@ -2,12 +2,11 @@
# coding=utf-8
print ("""
-Naloga 11:
+Naloga 11: Robot naj drži smer - če ga obrnemo iz začetne smeri, naj se zasuka nazaj v prvotno smer. Ob pritisku na stikalo, naj se resetira (smer nastavi na 0).
""")
import sys
sys.path.append('/home/user/codeq')
import time
-from ev3dev import *
from mindstorms_widgets import mindstorms_widgets
def sgn(x):
diff --git a/robot/problems/introduction/rotateback/sl.py b/robot/problems/introduction/rotateback/sl.py
index 269ea34..3242a80 100644
--- a/robot/problems/introduction/rotateback/sl.py
+++ b/robot/problems/introduction/rotateback/sl.py
@@ -31,3 +31,15 @@ hint = {
'while':['''<p>Program naj teče v neskončni zanki.</p>''',
'''<p><code>while 1:</code></p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Robotu dodamo žiroskop in ga resetiramo.</li>
+ <li>Robotu dodamo stikalo.</li>
+ <li>V neskončni zanki beremo vrednost kota z žiroskopom.</li>
+ <li>Glede na zasuk iz začetne lege, robota na mestu obrnemo v začetno smer.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/sl.py b/robot/problems/introduction/sl.py
new file mode 100644
index 0000000..24a72ca
--- /dev/null
+++ b/robot/problems/introduction/sl.py
@@ -0,0 +1,2 @@
+name = 'Uvod'
+description = 'Premikanje in zaznavanje.'
diff --git a/robot/problems/introduction/spotturn90/common.py b/robot/problems/introduction/spotturn90/common.py
index add6643..e01de39 100644
--- a/robot/problems/introduction/spotturn90/common.py
+++ b/robot/problems/introduction/spotturn90/common.py
@@ -10,9 +10,6 @@ number = 3
visible = True
solution = '''\
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
-
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
robot.connect_motor( 'right' )
@@ -30,7 +27,7 @@ hint_type = {
'seconds': Hint('seconds'),
}
-def hint( code):
+def hint( code ):
tokens = get_tokens(code)
# if code does not include mindstorms_widgets(), a student gets a hint that the robot should be somehow represented in the program
diff --git a/robot/problems/introduction/spotturn90/sl.py b/robot/problems/introduction/spotturn90/sl.py
index fe477aa..e3541c0 100644
--- a/robot/problems/introduction/spotturn90/sl.py
+++ b/robot/problems/introduction/spotturn90/sl.py
@@ -19,3 +19,14 @@ hint = {
'seconds':['''<p>Napiši časovno omejitev v sekundah.</p>''',
'''<p><code>robot.move_tank( 'on_for_seconds', ..., seconds=... )</code>.</p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Povežemo barvni senzor.</li>
+ <li>Vklopimo oba motorja tako, da se z enako močjo vrtita v različnih smereh.</li>
+ <li>Motorja izlopimo po pretečenem času, ki pri izbrani moči obrne robota za 90 stopinj.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/square20/common.py b/robot/problems/introduction/square20/common.py
index a293712..ce8bc14 100644
--- a/robot/problems/introduction/square20/common.py
+++ b/robot/problems/introduction/square20/common.py
@@ -10,9 +10,6 @@ number = 4
visible = True
solution = '''\
-from ev3dev import *
-from mindstorms_widgets import mindstorms_widgets
-
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
robot.connect_motor( 'right' )
diff --git a/robot/problems/introduction/square20/sl.py b/robot/problems/introduction/square20/sl.py
index f52ddf7..50b335f 100644
--- a/robot/problems/introduction/square20/sl.py
+++ b/robot/problems/introduction/square20/sl.py
@@ -27,3 +27,14 @@ hint = {
'lrPower': ['''<p>Za obrat na mestu se morata kolesi vrteti z enako močjo in v nasprotni smeri.</p>''',
'''<p><code>robot.move_tank( 'on_for_seconds', lr_power=[20,-20], seconds=.95 )</code>.</p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Vklopimo oba motorja tako, da robot vozi naravnost.</li>
+ <li>Robot se na mestu obrne za 90 stopinj; motorja z enako močjo, v različnih smereh.</li>
+ <li>Še 3-krat ponovimo koraka 3 in 4.</li>
+</ol>'''
+]
diff --git a/robot/problems/introduction/wall1m/common.py b/robot/problems/introduction/wall1m/common.py
index 07d1e1a..e8a5917 100644
--- a/robot/problems/introduction/wall1m/common.py
+++ b/robot/problems/introduction/wall1m/common.py
@@ -10,18 +10,15 @@ number = 6
visible = True
solution = '''\
-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:
+while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 50:
pass
robot.move_steering( 'on', power=20 )
-while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 200:
+while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 20:
pass
robot.move_steering( 'off' )
'''
diff --git a/robot/problems/introduction/wall1m/sl.py b/robot/problems/introduction/wall1m/sl.py
index 18518d5..cbb27ed 100644
--- a/robot/problems/introduction/wall1m/sl.py
+++ b/robot/problems/introduction/wall1m/sl.py
@@ -29,3 +29,17 @@ hint = {
'while':['''<p>Uporabi zanko: robot naj se pelje naprej, dokler ne pride do razdalje 50 cm od zida.</p>''',
'''<p>Uporabi še eno zanko: robot naj se pelje naprej z 20% močjo, dokler ne pride do razdalje 20 cm od zida.</p>'''],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.</li>
+ <li>Nanj povežemo oba pogonska motorja.</li>
+ <li>Robotu dodamo ultrazvočni senzor.</li>
+ <li>Vklopimo oba motorja tako, da robot vozi naravnost; moč nastavimo na 80.</li>
+ <li>V zanki merimo razdaljo z UZ senzorjem; zanko končamo, ko je razdalja <50 cm.</li>
+ <li>Moč motorjev nastavimo na 20.</li>
+ <li>V zanki merimo razdaljo z UZ senzorjem; zanko končamo, ko je razdalja <20 cm.</li>
+ <li>Ustavimo oba motorja.</li>
+</ol>'''
+]