Example #1
0
def setup_uarm():
    global paper_height
    bot = uarm_scan_and_connect()
    if input('Type any letter then ENTER to home: '):
        bot.home()
    reset_uarm(bot)
    return bot
from uarm import uarm_scan_and_connect

robot = uarm_scan_and_connect()

# reset the uarm, and move it to it's centered position
robot.home()

# NOTE: learn more about the uArm's coordinate system in their manual
#       `uArm-Python-SDK -> doc -> manuals -> Quick Starter Guide`

# move to absolute coordinates
robot.move_to(x=150)
robot.move_to(y=100, z=120)
robot.move_to(y=-100, z=50)

# move to relative coordinates
robot.move_relative(x=20)
robot.move_relative(y=100)
robot.move_relative(z=20)

# Telling the robot to move will send a command over the USB serial port
# however, it might still be moving when the Python command returns.
# If you need to know when it is finished moving, using `wait_for_arrival()`

# A minor issue with this is that movement will be slightly less smooth,
# because you are waiting for the device to stop while sending it more data

robot.move_to(x=150, y=100)
robot.wait_for_arrival()  # returns when the robot has stopped moving
    for blob_pos in blob_poses:
        hover_pos = blob_pos.copy()
        hover_pos['z'] += 5
        robot.move_to(**hover_pos).move_to(**blob_pos).move_to(**hover_pos)
    robot.sleep()


if __name__ == '__main__':

    settings_dir = None
    if len(sys.argv) > 1 and os.path.isdir(os.path.abspath(sys.argv[1])):
        settings_dir = os.path.abspath(sys.argv[1])
        print('Saving OpenMV calibration to -> {0}'.format(settings_dir))
    exit()

    robot = uarm_scan_and_connect(settings_dir=settings_dir)
    atexit.register(robot.sleep)

    camera = openmv.OpenMV(robot)
    camera.calibration_default()
    camera._general_offset = get_openmv_offset('general')  # default offset
    robot.hardware_settings_default().tool_mode('general').home()

    robot.disable_all_motors()
    input('Place nozzle on center of calibration dots, and press ENTER')
    robot.enable_all_motors()
    robot.update_position()
    start_pos = robot.position

    # hover the camera over the starting point
    camera.move_relative(z=15)