summaryrefslogtreecommitdiff
path: root/robot
diff options
context:
space:
mode:
authorJure Žabkar <jure.zabkar@fri.uni-lj.si>2015-12-23 11:28:05 +0100
committerJure Žabkar <jure.zabkar@fri.uni-lj.si>2015-12-23 11:28:05 +0100
commitf80206e6a4e4cec1574a375cb04dbdf07d3e02cd (patch)
treef5e9c17d8b5d4f212b7460496fdbb7226253f086 /robot
parent0883cb2a6b0bac23bd7553618f4e8db7c882a757 (diff)
angleska verzija
Diffstat (limited to 'robot')
-rw-r--r--robot/en.py42
-rw-r--r--robot/problems/introduction/circle20/en.py22
-rw-r--r--robot/problems/introduction/countlines/common.py6
-rw-r--r--robot/problems/introduction/countlines/en.py25
-rw-r--r--robot/problems/introduction/en.py2
-rw-r--r--robot/problems/introduction/followline/en.py34
-rw-r--r--robot/problems/introduction/forward/en.py17
-rw-r--r--robot/problems/introduction/forward1m/en.py21
-rw-r--r--robot/problems/introduction/forward1m/sl.py2
9 files changed, 160 insertions, 11 deletions
diff --git a/robot/en.py b/robot/en.py
index f296516..61314e9 100644
--- a/robot/en.py
+++ b/robot/en.py
@@ -3,5 +3,47 @@
name = 'Robot'
description = 'Introductory Robot course.'
+
hint = {
+ 'init':['''<p>In code the robot is represented by mindstorms_widgets(): <code>robot = mindstorms_widgets()</code>.</p>'''],
+ 'connectMotorLeft':['''<p>Connect the left motor to the robot.</p>''',
+ '''<p><code>robot.connect_motor( 'left' )</code>.</p>'''],
+ 'connectMotorRight':['''<p>Connect the right motor to the robot.</p>''',
+ '''<p><code>robot.connect_motor( 'right' )</code>.</p>'''],
+ 'moveSteering':['''<p>Synchronize the motors.</p>''',
+ '''<p>Use move_steering method for synchonization <code>robot.move_steering( ... )</code>.</p>'''],
+ 'moveSteeringOff':['''<p>Stop the motors.</p>''',
+ '''<p><code>robot.move_steering( 'off' )</code>.</p>'''],
+ 'onForSeconds':['''<p>The first argument of <code>robot.move_steering</code> should specify that the motors will run for a certain amount of time.</p>''',
+ '''<p><code>robot.move_steering('on_for_seconds', ... )</code>.</p>'''],
+ 'direction':['''<p>Define the direction of moving; negative/positive values represent a left/right turn.</p>'''],
+ 'seconds':['''<p>Determine the running time of the motors.</p>'''],
+ 'connectColorSensor':['''<p>Connect the color sensor to the robot.</p>''',
+ '''<p><code>robot.connect_sensor( 'color' )</code>.</p>'''],
+ 'colorSensorMeasure':['''<p>While the robot is moving forward, it should use the color sensor in 'color' mode to recognize the colors.</p>''',
+ '''<p><code>robot.color_sensor_measure( 'color' )</code>.</p>'''],
+ 'colorSensorMeasureRLI':['''<p>Use the color sensor in 'reflected_light_intensity' mode.</p>''',
+ '''<p><code>robot.color_sensor_measure( 'reflected_light_intensity' )</code>.</p>'''],
+ 'moveTankOn':['''<p>Use the method for separate motor control, to set each motor's power separately.</p>''',
+ '''<p>The most appropriate for this is <code>robot.move_tank( ... )</code>.</p>''',
+ '''<p><code>robot.move_tank( 'on', ...)</code></p>'''],
+ 'lrPower': ['''<p>Set the powers of the left and right motor.</p>''',
+ '''<p><code>robot.move_tank( 'on', lr_power=[ ... ])</code></p>'''],
+ 'moveTankOff': ['''Stop the robot.''',
+ '''<p><code>robot.move_tank( 'off' )</code></p>'''],
+ 'onForRotations':['''<p>Set the first argument of <code>robot.move_steering</code> method so that the motors will run for the specified number of rotations.</p>''',
+ '''<p><code>robot.move_steering('on_for_rotations', ... )</code>.</p>'''],
+ 'rotations':['''<p>Determine the number of rotations; how many turns should the motors do in a meter? Measure the circumference of the wheel and compute the number of rotations per meter.</p>''',
+ '''<p><code>robot.move_steering( 'on_for_rotations', direction=0, rotations=5 )</code>.</p>'''],
+ 'no_hint': ['''\
+<p>No hint here!</p>
+'''],
+
+ 'system_error': ['''\
+<p><span style="color: red;">System error:</span> [%=message%].</p>
+'''],
+
+ 'test_results': ['''\
+<p>Your program passed [%=passed%] / [%=total%] tests.</p>
+'''],
}
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 = '''\
-'''
+<p>Write a program that will make the robot drive in circle (r=20cm) and stop after one loop.</p>'''
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']+['''<p>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.</p>''',
+ '''<p><code>robot.move_steering( 'on_for_seconds', direction=20, ... )</code>.</p>'''],
+ 'seconds':mod.hint['seconds']+['''<p>Experimentally determine the time (in seconds) the robot needs for one loop.</p>''',
+ '''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</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>calculate the turn so that the robot would drive in circle with radius 20 cm.</li>
+ <li>synchronize the motors and run them for a specified time, so that the robot stops after one round.</li>
+</ol>'''
+]
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>'''
+]
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']+['''<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>
+'''
+] \ 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']+['''<p><code>robot.move_steering( 'on_for_seconds', direction=0, ... )</code>.</p>'''],
+ 'seconds':mod.hint['seconds']+['''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</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>synchronize the motors and run them so that the robot would move forward for 3 seconds.</li>
+</ol>'''
+] \ 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']+['''<p><code>robot.move_steering( '...', direction=0, ... )</code>.</p>'''],
+ 'seconds':mod.hint['seconds']+['''<p><code>robot.move_steering( 'on_for_seconds', direction=0, seconds=3 )</code>.</p>'''],
+ 'rotations':mod.hint['rotations'],
}
+
+plan = ['''\
+<p>Program izvedemo v naslednjih korakih:</p>
+<ol>
+ <li>create a mindstorms_widgets() object, which represents the robot in your code.</li>
+ <li>connect the driving motors.</li>
+ <li>measure the circumference of robot's wheels and compute the number of rotations per meter.</li>
+ <li>synchronize the motors and run them so that the robot would move forward for computed number of rotations.</li>
+</ol>'''
+]
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 = '''\
-<p>Napiši program, da bo robot peljal naravnost naprej 3 sekunde in se nato ustavil.</p>'''
+<p>Napiši program, da bo robot peljal 1 meter naravnost in se nato ustavil.</p>'''
hint = {
'mW_init':['''<p>Robota v programu predstavimo z mindstorms_widgets(): <code>robot = mindstorms_widgets()</code>.</p>'''],