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.py6
-rw-r--r--robot/problems/introduction/countlines/en.py25
2 files changed, 27 insertions, 4 deletions
diff --git a/robot/problems/introduction/countlines/common.py b/robot/problems/introduction/countlines/common.py
index 6d2bf13..bf5343b 100644
--- a/robot/problems/introduction/countlines/common.py
+++ b/robot/problems/introduction/countlines/common.py
@@ -21,17 +21,17 @@ robot.connect_sensor( 'color' )
robot.move_steering( 'on' )
start = time.time()
-stevec = 0
+counter = 0
color = -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..009a752 100644
--- a/robot/problems/introduction/countlines/en.py
+++ b/robot/problems/introduction/countlines/en.py
@@ -7,8 +7,31 @@ 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>'''
+]