Permalink
Browse files

Implement enter_field ver0

Just navigate towards the field forward (no turn corrections yet).
  • Loading branch information...
m3d committed Nov 29, 2017
1 parent a0c1fe3 commit be43ec0394ee0fc20eb9b9db176394160ac6b499
Showing with 44 additions and 7 deletions.
  1. +2 −2 README.md
  2. +42 −5 myr2017.py
@@ -17,7 +17,7 @@ https://robotika.cz/competitions/move-your-robot/2017/
python3 -h
usage: myr2017.py [-h] [--host HOST] [--port PORT] [--note NOTE] [--verbose]
[--video-port VIDEO_PORT] [--replay REPLAY] [--force]
[--test {1m,90deg,loops}]
[--test {1m,90deg,loops,enter}]
Navigate Naio robot in "Move Your Robot" competition
@@ -32,7 +32,7 @@ optional arguments:
video"
--replay REPLAY replay existing log file
--force, -F force replay even for failing output asserts
--test {1m,90deg,loops}
--test {1m,90deg,loops,enter}
test cases
```
@@ -22,6 +22,12 @@
VIDEO_COMPRESSION_LEVEL = 7 # zlib parameter
# Row navigation constants
MAX_GAP_SIZE = 13 # defined for plants on both sides
OPEN_SIZE = 17
OFFSET_SIZE = 5
END_OF_ROW_SIZE = 18 + 19 # for 180deg FOV
class WrapperIO:
def __init__(self, soc, log, ignore_ref_output=False):
@@ -143,11 +149,35 @@ def turn_left_90deg(robot):
robot.annot(b'TAG:turn_left_90deg:END')
def enter_field(robot, verbose):
robot.annot(b'TAG:enter_field:BEGIN')
if verbose:
print('enter_field')
if robot.time is None:
robot.update()
robot.move_forward()
start_time = robot.time
while robot.time - start_time < timedelta(minutes=1):
robot.update()
triplet = laser2ascii(robot.laser)
s, left, right = triplet
if left + right < END_OF_ROW_SIZE:
# i.e. there is some obstacle within 1 meter radius
break
if verbose:
print('max_dist', max(robot.laser))
robot.stop()
robot.update()
robot.annot(b'TAG:enter_field:END')
def navigate_row(robot, verbose):
MAX_GAP_SIZE = 13 # defined for plants on both sides
OPEN_SIZE = 17
OFFSET_SIZE = 5
END_OF_ROW_SIZE = 18 + 19 # for 180deg FOV
"""navigate in 70cm rows or on the field border"""
# first make sure you are in the field
enter_field(robot, verbose)
robot.move_forward()
end_of_row = False
@@ -291,6 +321,11 @@ def test_loops(robot, verbose):
robot.update()
def test_enter(robot, verbose):
enter_field(robot, verbose)
robot.wait(timedelta(seconds=3))
def play_game(robot, verbose):
# 1st row
@@ -331,6 +366,8 @@ def run_robot(robot, verbose=False, test_case=None):
test_90deg(robot)
elif test_case == 'loops':
test_loops(robot, verbose=verbose)
elif test_case == 'enter':
test_enter(robot, verbose=verbose)
else:
assert False, test_case # not supported
@@ -350,7 +387,7 @@ def run_robot(robot, verbose=False, test_case=None):
parser.add_argument('--force', '-F', dest='force', action='store_true',
help='force replay even for failing output asserts')
parser.add_argument('--test', dest='test_case', help='test cases',
choices=['1m', '90deg', 'loops'])
choices=['1m', '90deg', 'loops', 'enter'])
args = parser.parse_args()
if args.replay is None:

0 comments on commit be43ec0

Please sign in to comment.