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/countlines/common.py | 3 +-- robot/problems/introduction/countlines/naloga10_countLines.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'robot/problems/introduction/countlines') diff --git a/robot/problems/introduction/countlines/common.py b/robot/problems/introduction/countlines/common.py index 5b8db2e..6a50988 100644 --- a/robot/problems/introduction/countlines/common.py +++ b/robot/problems/introduction/countlines/common.py @@ -11,8 +11,7 @@ visible = True solution = '''\ 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/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'] -- 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/countlines/common.py | 1 + robot/problems/introduction/countlines/sl.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'robot/problems/introduction/countlines') diff --git a/robot/problems/introduction/countlines/common.py b/robot/problems/introduction/countlines/common.py index 6a50988..925fc06 100644 --- a/robot/problems/introduction/countlines/common.py +++ b/robot/problems/introduction/countlines/common.py @@ -31,6 +31,7 @@ while time.time()-start < 2.1: stevec += 1 color = c robot.move_steering( 'off' ) + print( "Stevilo crt:", stevec ) ''' 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 = { '''

Zanka je lahko časovno omejena, npr. z uporabo metode time.time().

''', '''

while time.time()-start < 1.1:.

'''], } + +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. Vklopimo oba motorja tako, da robot vozi naravnost.
  8. +
  9. V zanki naj robot bere barve in jih šteje.
  10. +
  11. Zanka naj se konča po vnaprej določenem času, npr. 3 sekunde.
  12. +
  13. Ustavimo oba motorja.
  14. +
''' +] -- cgit v1.2.1 From 0883cb2a6b0bac23bd7553618f4e8db7c882a757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=BDabkar?= Date: Tue, 15 Dec 2015 13:13:49 +0100 Subject: Popravki programov pred zagovorom projekta. --- robot/problems/introduction/countlines/common.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'robot/problems/introduction/countlines') diff --git a/robot/problems/introduction/countlines/common.py b/robot/problems/introduction/countlines/common.py index 925fc06..6d2bf13 100644 --- a/robot/problems/introduction/countlines/common.py +++ b/robot/problems/introduction/countlines/common.py @@ -11,7 +11,6 @@ visible = True solution = '''\ import time -from mindstorms_widgets import * color_table = ['none', 'black', 'blue', 'green', 'yellow', 'red', 'white', 'brown'] @@ -24,7 +23,7 @@ robot.move_steering( 'on' ) start = time.time() stevec = 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: -- 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/countlines/common.py | 6 +++--- robot/problems/introduction/countlines/en.py | 25 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'robot/problems/introduction/countlines') 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']+['''

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

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

Use the while loop: inside, the robot should read the current color and increase the counter when the color changes.

''', + '''

Interrupt the loop after a certain amount of time; determine the time the robot needs to drive over all the colors experimentally; use time.time().

''', + '''

while time.time()-start < 1.5:.

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

The program should:

+
    +
  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. synchronize the motors and run them so that the robot would move forward.
  8. +
  9. inside the loop, let the robot recognize colors and increase the counter.
  10. +
  11. interrupt the loop after a certain amount of time.
  12. +
  13. stop the motors.
  14. +
''' +] -- 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/countlines/en.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'robot/problems/introduction/countlines') diff --git a/robot/problems/introduction/countlines/en.py b/robot/problems/introduction/countlines/en.py index 009a752..7655b21 100644 --- a/robot/problems/introduction/countlines/en.py +++ b/robot/problems/introduction/countlines/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 = 206 name = 'Count lines' -- cgit v1.2.1