def draw_robot():
    # Update the cursor that indicates the current position of the robot
    rx, ry = robot.rshm("x"), robot.rshm("y")
    #print(rx,ry)
    x, y = rob_to_screen(rx, ry)
    win.coords(
        robot_pos,
        (x - cursor_size, y - cursor_size, x + cursor_size, y + cursor_size))
    win.itemconfig(coord_txt, text="  %.3f,%.3f" % (rx, ry))
    win.coords(coord_txt, (x, y))
    global moving
    robcol = "green" if moving else "blue"
    win.itemconfig(robot_pos, fill=robcol)
Example #2
0
def follow_robot():
    """ Draw the robot position on the screen, repeatedly."""
    global calib, master, gui, oldrect
    oldrect = None  # just so that it is initialised

    gui["keep_going"] = True  # set gui["keep_going"] to False to drop out of this and stop following the robot handle
    update_ui()
    while gui["keep_going"]:
        rx, ry = robot.rshm('x'), robot.rshm('y')
        sx, sy = robot_to_screen(rx, ry)

        draw_cursor(sx, sy)

        master.update_idletasks()
        master.update()
Example #3
0
def capture(e):
    capt = []
    for _ in range(N_CAPTURE):
        x, y = robot.rshm('x'), robot.rshm('y')
        capt.append((x, y))
        time.sleep(CAPTURE_SLEEP)

    # Capture the position
    allx, ally = zip(*capt)
    capx, capy = np.mean(allx), np.mean(ally)

    global captured, current_target, targets
    targx, targy = targets[current_target]
    captured.append((targx, targy, capx, capy))

    # Show in the interface what we captured
    global gui
    gui["position"].set("x=%.3f y=%.3f" % (capx, capy))

    next_target(e)
Example #4
0
def draw_robot():
    # Update the cursor that indicates the current position of the robot
    rx, ry = robot.rshm("x"), robot.rshm("y")
    #print(rx,ry)
    x, y = rob_to_screen(rx, ry)
    global gui
    win = gui["win"]
    robot_pos = gui["robot_pos"]
    coord_txt = gui["coord_txt"]
    win.coords(
        robot_pos,
        (x - cursor_size, y - cursor_size, x + cursor_size, y + cursor_size))
    win.itemconfig(coord_txt, text="  %.3f,%.3f" % (rx, ry))
    win.coords(coord_txt, (x, y))

    win.create_oval(x - trace_size,
                    y - trace_size,
                    x + trace_size,
                    y + trace_size,
                    fill='red')
Example #5
0
def update_display_values():
    if capturing:

        # First, capture all the variables
        vals = [robot.rshm(v) for v in variables]

        # For each variable, show its value
        valbox.delete(0, END)  # remove everything
        i = 0
        for i, val in enumerate(vals):
            #val = robot.rshm(v)
            if val == None:
                valbox.insert(END, "N/A")
                continue
            if type(val) is list:
                valbox.insert(END, "(array)")
                continue

            #val = random.random()
            valbox.insert(END, str(val))
            if val < 0:
                valbox.itemconfig(i, foreground="red")
            else:
                valbox.itemconfig(i, foreground="green")
Example #6
0
def showpos():
    print(robot.rshm('x'), robot.rshm('y'))
Example #7
0
print("Position:")
showpos()

print("Now I will tell the robot to stay fixed at this position")
input()

print("Staying")
robot.stay()

input()

print("Position:")
showpos()

x, y = robot.rshm('x'), robot.rshm('y')
tx, ty = x + .1, y

print("About to move to %f,%f, okay?" % (tx, ty))

input()
robot.move_to(tx, ty, 3.)

print("Press <ENTER> to switch to stay")
input()

print("Staying")
robot.stay()

print("Press <ENTER> to unload.")
input()
import time
import robot.interface as robot
#import robot.dummy as robot


robot.load()

print("Loaded")

v = robot.dump_shm()
print(v)

print(robot.rshm('fvv_trial_phase'))

print(robot.status())

for _ in range(5):
    x,y = robot.rshm('x'),robot.rshm('y')
    time.sleep(.1)
    print(x,y)

robot.move_to(.3,.1,2)

for _ in range(20):
    x,y = robot.rshm('x'),robot.rshm('y')
    time.sleep(.1)
    print(x,y)


robot.unload()
Example #9
0
def capture_position():
    # Capture the current position
    rx, ry = robot.rshm("x"), robot.rshm("y")

    global captured
    captured.append((rx, ry))