summaryrefslogtreecommitdiff
path: root/robot/problems/introduction/countlines
diff options
context:
space:
mode:
Diffstat (limited to 'robot/problems/introduction/countlines')
-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
4 files changed, 44 insertions, 10 deletions
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>'''
+]