Пример #1
0
def new_robot(s, log):
    body = MockBody(s.get("pos"), s.get("heading"))
    network = MockNetwork(log, s.get("ID"))
    bot = PerimeterDefenseRobot(body, network, 0.02)
    bot.turn_on()
    return bot
Пример #2
0
def new_robot(s, log):
    body = MockBody(s.get("pos"), s.get("heading") )
    network = MockNetwork(log,s.get("ID"))
    bot = PerimeterDefenseRobot( body, network, 0.02)
    bot.turn_on()
    return bot
Пример #3
0
    num_friends = float(sys.argv[1])-1
except:
    num_friends = 4-1

# These parameters have to be manually
# set for each robot.
init_pos = s["position"]
init_heading = s["heading"]
ID=s["ID"]
slot = s["slot"]


mylock = Lock()
body = ebotBody( init_pos , init_heading, mylock)
network = XBeeExpirationNetwork( 1.4, slot, slot+0.1, 1, ID , mylock)
robot = PerimeterDefenseRobot( body, network, 0.02 )
robot.turn_on()
robot.broadcast_state()

friends = len(robot.get_agents())
patience = 50

while friends < num_friends and patience>0:
    patience -= 1
    print "# Only %i friends detected so far"%friends
    print "#", "\t".join(robot.get_agents().keys())
    friends = len(robot.get_agents())
    robot.broadcast_state()
    sleep(0.2)

# MAIN LOOP
Пример #4
0
speed = 0.15

log = open("the_cloud.dat", "w+")
settings = []
settings.append({"ID": 1, "position": [0.0, 0.0], "heading": 0.})
settings.append({"ID": 2, "position": [0.5, 0.0], "heading": 0.})
settings.append({"ID": 3, "position": [0.0, 0.5], "heading": 0.})
settings.append({"ID": 4, "position": [-0.5, 0.0], "heading": 0.})
settings.append({"ID": 5, "position": [0.0, -0.5], "heading": 0.})
settings.append({"ID": 6, "position": [0.5, 0.5], "heading": 0.})
settings.append({"ID": 7, "position": [0.5, -0.5], "heading": 0.})
settings.append({"ID": 8, "position": [-0.5, -0.5], "heading": 0.})
settings.append({"ID": 9, "position": [-0.5, 0.5], "heading": 0.})

robots = [
    PerimeterDefenseRobot(MockBody(s.get("position"), s.get("heading")),
                          MockNetwork(log, s.get("ID")), 1.e-8)
    for s in settings
]

[robot.body.load_obstacles("map_data.dat") for robot in robots]
[robot.turn_on() for robot in robots]

try:
    [robot.broadcast_state() for robot in robots]

    #robot.start_printing(0.5)

    # MAIN LOOP
    init_time = time()
    end_time = init_time + total_time
    for it in range(int(total_time / dt)):