summaryrefslogtreecommitdiff
path: root/robot/problems/introduction/followline
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/introduction/followline
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/introduction/followline')
-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
4 files changed, 55 insertions, 11 deletions
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>
+'''
+]