From be94b55b835283de53c686343164641e15abe806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=BDabkar?= Date: Mon, 14 Dec 2015 12:44:58 +0100 Subject: Zadnje spremembe pred zagovorom. --- robot/problems/introduction/followline/naloga12_followLine.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'robot/problems/introduction/followline') 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' ) -- cgit v1.2.1 From b4e46b75f5e2a890b41d2e20a89767590e54ccb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=BDabkar?= Date: Tue, 15 Dec 2015 10:34:40 +0100 Subject: Dodani plani za robotske probleme. --- robot/problems/introduction/followline/common.py | 8 +++----- robot/problems/introduction/followline/sl.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'robot/problems/introduction/followline') diff --git a/robot/problems/introduction/followline/common.py b/robot/problems/introduction/followline/common.py index 3e84cd4..46df5c6 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' ) ''' 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': ['''

V zanki uporabi pogojni stavek...

''', '''

Če robot vidi črto, naj zavije z nje; če vidi podlago, naj zavije proti črti.

'''] } + +plan = ['''\ +

Program izvedemo v naslednjih korakih:

+
    +
  1. Naredimo objekt mindstorms_widgets(), s katerim predstavimo robota.
  2. +
  3. Nanj povežemo oba pogonska motorja.
  4. +
  5. Povežemo barvni senzor.
  6. +
  7. V zanki preverjamo, kakšno barvo vidi robot s senzorjem.
  8. +
  9. Če vidi črno, naj zavije desno, če vidi belo, naj zavije levo. (Sledi desnemu robu črte).
  10. +
  11. Zanka naj se konča po vnaprej določenem času, 10 sekund.
  12. +
  13. Ustavimo oba motorja.
  14. +
+

Opomba: potrebna je predhodna kalibracija barvnega senzorja.

+''' +] -- cgit v1.2.1 From 6cfee9293d18efed76dc2c83d7a00b1b40230bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=BDabkar?= Date: Tue, 15 Dec 2015 10:49:23 +0100 Subject: Popravek v namigu za problem followline --- robot/problems/introduction/followline/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'robot/problems/introduction/followline') diff --git a/robot/problems/introduction/followline/common.py b/robot/problems/introduction/followline/common.py index 46df5c6..e28ca35 100644 --- a/robot/problems/introduction/followline/common.py +++ b/robot/problems/introduction/followline/common.py @@ -59,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): -- cgit v1.2.1 From f80206e6a4e4cec1574a375cb04dbdf07d3e02cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=BDabkar?= Date: Wed, 23 Dec 2015 11:28:05 +0100 Subject: angleska verzija --- robot/problems/introduction/followline/en.py | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'robot/problems/introduction/followline') diff --git a/robot/problems/introduction/followline/en.py b/robot/problems/introduction/followline/en.py index 3f816fe..1551d1b 100644 --- a/robot/problems/introduction/followline/en.py +++ b/robot/problems/introduction/followline/en.py @@ -7,8 +7,40 @@ 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']+['''

Use move_steering method with 'on' as the first parameter robot.move_steering( 'on',... ).

'''], + 'moveSteeringOff':mod.hint['moveSteeringOff'], + 'connectColorSensor':mod.hint['connectColorSensor'], + 'colorSensorMeasureRLI':mod.hint['colorSensorMeasureRLI'], + 'while':['''

Use the loop, inside which the robot would follow the line.

''', + '''

The loop should be time constrained, e.g. time.time().

''', + '''

start = time.time()\nwhile time.time()-start < 10:.

'''], + 'moveTankOn':mod.hint['moveTankOn'], + 'lrPower': mod.hint['lrPower'], + 'moveTankOff': mod.hint['moveTankOff'], + 'time': ['''Use time() to measure time.''', + '''

start = time.time()\nwhile time.time()-start < 10:

'''], + 'if': ['''

Use conditional statement inside the loop...

''', + '''

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.

'''] } + +plan = ['''\ +

The program should do the following:

+
    +
  1. create a mindstorms_widgets() object, which represents the robot in your code.
  2. +
  3. connect the driving motors.
  4. +
  5. connect the color sensor.
  6. +
  7. in a loop, the robot should read the color sensor to check whether it is on or off line.
  8. +
  9. if it sees black, it should turn right/left; if it sees white, it should turn left/right.
  10. +
  11. break the loop after specified time, 10 seconds.
  12. +
  13. stop the motors.
  14. +
+

Note: you may need to calibrate the color sensor before running the program on the robot.

+''' +] \ No newline at end of file -- cgit v1.2.1 From bebd9806a957cd91fe0e507091bc7d0fd385f865 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 23 Dec 2015 14:57:52 +0100 Subject: Fix: import robot hints from the correct directory --- robot/problems/introduction/followline/en.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'robot/problems/introduction/followline') diff --git a/robot/problems/introduction/followline/en.py b/robot/problems/introduction/followline/en.py index 1551d1b..9a588bc 100644 --- a/robot/problems/introduction/followline/en.py +++ b/robot/problems/introduction/followline/en.py @@ -1,6 +1,6 @@ # coding=utf-8 import server -mod = server.problems.load_language('python', 'en') +mod = server.problems.load_language('robot', 'en') id = 207 name = 'Line following' @@ -43,4 +43,4 @@ plan = ['''\

Note: you may need to calibrate the color sensor before running the program on the robot.

''' -] \ No newline at end of file +] -- cgit v1.2.1