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/circle20/en.py | 22 +++++++++++++-- robot/problems/introduction/countlines/common.py | 6 ++--- robot/problems/introduction/countlines/en.py | 25 ++++++++++++++++- robot/problems/introduction/en.py | 2 ++ robot/problems/introduction/followline/en.py | 34 +++++++++++++++++++++++- robot/problems/introduction/forward/en.py | 17 +++++++++++- robot/problems/introduction/forward1m/en.py | 21 +++++++++++++-- robot/problems/introduction/forward1m/sl.py | 2 +- 8 files changed, 118 insertions(+), 11 deletions(-) create mode 100644 robot/problems/introduction/en.py (limited to 'robot/problems/introduction') diff --git a/robot/problems/introduction/circle20/en.py b/robot/problems/introduction/circle20/en.py index 8210d71..c677cce 100644 --- a/robot/problems/introduction/circle20/en.py +++ b/robot/problems/introduction/circle20/en.py @@ -7,8 +7,26 @@ name = 'Circle 20 cm' slug = 'Circle 20 cm' description = '''\ -''' +

Write a program that will make the robot drive in circle (r=20cm) and stop after one loop.

''' hint = { - + 'mW_init':mod.hint['init'], + 'connectMotorLeft':mod.hint['connectMotorLeft'], + 'connectMotorRight':mod.hint['connectMotorRight'], + 'moveSteering':mod.hint['moveSteering'], + 'onForSeconds':mod.hint['onForSeconds'], + 'direction':mod.hint['direction']+['''

The value of this parameter should be such that would make the robot circle with radius 20cm. This value highly depends on the construction of the robot.

''', + '''

robot.move_steering( 'on_for_seconds', direction=20, ... ).

'''], + 'seconds':mod.hint['seconds']+['''

Experimentally determine the time (in seconds) the robot needs for one loop.

''', + '''

robot.move_steering( 'on_for_seconds', direction=0, seconds=3 ).

'''], } + +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. calculate the turn so that the robot would drive in circle with radius 20 cm.
  6. +
  7. synchronize the motors and run them for a specified time, so that the robot stops after one round.
  8. +
''' +] 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. +
''' +] diff --git a/robot/problems/introduction/en.py b/robot/problems/introduction/en.py new file mode 100644 index 0000000..5236b4e --- /dev/null +++ b/robot/problems/introduction/en.py @@ -0,0 +1,2 @@ +name = 'Introduction' +description = 'Motors and sensors.' 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 diff --git a/robot/problems/introduction/forward/en.py b/robot/problems/introduction/forward/en.py index be73921..5f78d57 100644 --- a/robot/problems/introduction/forward/en.py +++ b/robot/problems/introduction/forward/en.py @@ -8,5 +8,20 @@ description = '''\ ''' hint = { - + 'mW_init':mod.hint['init'], + 'connectMotorLeft':mod.hint['connectMotorLeft'], + 'connectMotorRight':mod.hint['connectMotorRight'], + 'moveSteering':mod.hint['moveSteering'], + 'onForSeconds':mod.hint['onForSeconds'], + 'direction':mod.hint['direction']+['''

robot.move_steering( 'on_for_seconds', direction=0, ... ).

'''], + 'seconds':mod.hint['seconds']+['''

robot.move_steering( 'on_for_seconds', direction=0, seconds=3 ).

'''], } + +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. synchronize the motors and run them so that the robot would move forward for 3 seconds.
  6. +
''' +] \ No newline at end of file diff --git a/robot/problems/introduction/forward1m/en.py b/robot/problems/introduction/forward1m/en.py index bdf2a45..f923059 100644 --- a/robot/problems/introduction/forward1m/en.py +++ b/robot/problems/introduction/forward1m/en.py @@ -7,9 +7,26 @@ name = 'Forward 1m' slug = 'Forward 1m' description = '''\ - + Write a program that would make the robot drive forward and stop after 1 meter. ''' hint = { - + 'mW_init':mod.hint['init'], + 'connectMotorLeft':mod.hint['connectMotorLeft'], + 'connectMotorRight':mod.hint['connectMotorRight'], + 'moveSteering':mod.hint['moveSteering'], + 'onForRotations':mod.hint['onForRotations'], + 'direction':mod.hint['direction']+['''

robot.move_steering( '...', direction=0, ... ).

'''], + 'seconds':mod.hint['seconds']+['''

robot.move_steering( 'on_for_seconds', direction=0, seconds=3 ).

'''], + 'rotations':mod.hint['rotations'], } + +plan = ['''\ +

Program izvedemo v naslednjih korakih:

+
    +
  1. create a mindstorms_widgets() object, which represents the robot in your code.
  2. +
  3. connect the driving motors.
  4. +
  5. measure the circumference of robot's wheels and compute the number of rotations per meter.
  6. +
  7. synchronize the motors and run them so that the robot would move forward for computed number of rotations.
  8. +
''' +] diff --git a/robot/problems/introduction/forward1m/sl.py b/robot/problems/introduction/forward1m/sl.py index 2240d3c..f6209eb 100644 --- a/robot/problems/introduction/forward1m/sl.py +++ b/robot/problems/introduction/forward1m/sl.py @@ -4,7 +4,7 @@ name = 'Naprej 1m' slug = 'Naprej 1m' description = '''\ -

Napiši program, da bo robot peljal naravnost naprej 3 sekunde in se nato ustavil.

''' +

Napiši program, da bo robot peljal 1 meter naravnost in se nato ustavil.

''' hint = { 'mW_init':['''

Robota v programu predstavimo z mindstorms_widgets(): robot = mindstorms_widgets().

'''], -- cgit v1.2.1