Exemplo n.º 1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Patrols the edges of the map going clockwise. Just drives around in circles,
taking pains not to hit a wall.

When we see a wall, turn right a little.
"""

from courier import RoboLink

robot = RoboLink.connect(name="Patroller", scanner=2, engine=5)
#                                          ^^^ by default, we get a 5-quality
#                            scanner and a 2-quality engine. well, we want to
#                            move faster, so we'll soup up our engine instead.

# Should probably be handled by RoboLink.connect, but whatever.
if not robot:
    print "Error connecting"
    exit(1)

# The below will be changed to 'while not robot.dead:' just as soon as I
# implement that.
while True:

    # Full speed ahead! Doing this every tic just in case we hit a wall or stop
    # or something. Setting the throttle doesn't take very long.
    robot.throttle = 100

    if robot.scan_wall() is not None:
        # If we see a wall, turn right ten degrees.
Exemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Sitting duck. We'll just spin in circles.
"""
from courier import RoboLink
import random

robot = RoboLink.connect(name="Sitting Duck")

if not robot:
    print "Error connecting"
    exit(1)

while True:
    # Just sit here and spin in clockwise circles.
    robot.turret_rotation = random.randint(0, 365)
    robot.turn(90)
Exemplo n.º 3
0
Arquivo: patrol.py Projeto: gcr/robots
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Patrols the edges of the map going clockwise. Just drives around in circles,
taking pains not to hit a wall.

When we see a wall, turn right a little.
"""

from courier import RoboLink

robot = RoboLink.connect(name="Patroller", scanner=2, engine=5)
#                                          ^^^ by default, we get a 5-quality
#                            scanner and a 2-quality engine. well, we want to
#                            move faster, so we'll soup up our engine instead.


# Should probably be handled by RoboLink.connect, but whatever.
if not robot:
    print "Error connecting"
    exit(1)


# The below will be changed to 'while not robot.dead:' just as soon as I
# implement that.
while True:

    # Full speed ahead! Doing this every tic just in case we hit a wall or stop
    # or something. Setting the throttle doesn't take very long.
    robot.throttle = 100
Exemplo n.º 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tracker.

We'll just sit there and track you forever, halving our scan arc each step.
"""
from courier import RoboLink

robot = RoboLink.connect(name="Tracker")

if not robot:
    print "Error connecting"
    exit(1)

# The max we can scan
biggest_arc = 90.
# How thin our arc is. As factor increases, our arc grows finer.
factor = 1

while True:
    # Scan for a robot
    scan_results = robot.scan(biggest_arc / (2**factor))
    # scan_results is now an array of multiple robots.

    if scan_results:
        # If we found them, record their distance and accuracy (will be either
        # -1, -.5, 0, .5, 1; the angle is this times your scan width)
        dist, accuracy = scan_results[0]['distance'], scan_results[0][
            'bearing']
        # Steer our turret to face our target (this is instantaneous).
Exemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Tracker.

We'll just sit there and track you forever, halving our scan arc each step.
"""
from courier import RoboLink

robot = RoboLink.connect(name="Tracker")

if not robot:
    print "Error connecting"
    exit(1)

# The max we can scan
biggest_arc = 90.
# How thin our arc is. As factor increases, our arc grows finer.
factor = 1

while True:
    # Scan for a robot
    scan_results = robot.scan(biggest_arc / (2**factor))
    # scan_results is now an array of multiple robots.

    if scan_results:
        # If we found them, record their distance and accuracy (will be either
        # -1, -.5, 0, .5, 1; the angle is this times your scan width)
        dist, accuracy = scan_results[0]['distance'], scan_results[0]['bearing']
        # Steer our turret to face our target (this is instantaneous).
Exemplo n.º 6
0
Arquivo: sduck.py Projeto: gcr/robots
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Sitting duck. We'll just spin in circles.
"""
from courier import RoboLink
import random

robot = RoboLink.connect(name="Sitting Duck")

if not robot:
    print "Error connecting"
    exit(1)

while True:
    # Just sit here and spin in clockwise circles.
    robot.turret_rotation = random.randint(0, 365)
    robot.turn(90)