Ejemplo n.º 1
0
def set_level(leveldir, offset):
    """
    Set level, idk if we use this
    Returns the final level and offset
    """
    atmega.write("l {} {}\n".format(leveldir, offset))
    offset = atmega.readline().strip().split(" ")
    if offset[0] != "ll":
        logger.error("Expected 'll' as response to 'l' command, got {}".format(
            offset[0]))
    return int(offset[0]), float(offset[1])
Ejemplo n.º 2
0
def get_state():
    """ Requests and returns the state from the atmega """
    atmega.write("c\n")
    # get the line, strip the newline char, split it
    arr = atmega.readline().strip().split(" ")
    if arr[0] != "s":
        logger.error("Expected reply starting with 's' from control when asked"
                     " for state, got {}".format(arr[0]))
        return State(*([0] * 6))
    # exclude the first 's' char
    arr = [float(i) for i in arr[1:]]
    return State(*arr)
Ejemplo n.º 3
0
def killed():
    """ Get the status of the kill switch """
    atmega.write("a\n")
    k = atmega.readline().strip()
    try:
        k = int(k)
    except:
        logger.critical(
            "Recieved {} instead of an 1 or 0 from atmega, continuing".format(
                k))
        return True
    return True if k == 0 else False
Ejemplo n.º 4
0
def set_state(state):
    """ Sends desired state to control """
    logger.info("Set desired state to {}".format(state))
    if modeling.current_confidence > 0.5:
        atmega.write("n {} {}\n".format(modeling.current_state.x,
                                        modeling.current_state.y))
        set_speed(.1)
        set_power(.3)
    else:
        set_speed(config.mission.SPEED)
        set_speed(config.mission.POWER)
    atmega.write("s {}\n".format(state))
    return state
Ejemplo n.º 5
0
def set_speed(val):
    """ sets speed of sub, I don't know if we use this """
    return atmega.write("o {}\n".format(val))
Ejemplo n.º 6
0
def kill():
    """ Sets the motor power to 0 """
    return atmega.write("p 0\n")
    return atmega.write("o 0\n")
Ejemplo n.º 7
0
def set_power(val):
    """ Sets the motor power """
    return atmega.write("p {}\n".format(val))
Ejemplo n.º 8
0
def drop():
    """ Activates dropper """
    return atmega.write("r 3\n")
Ejemplo n.º 9
0
def untilt():
    """ Sets pitch and roll to 0 to level out the sub """
    return atmega.write("u\n")
Ejemplo n.º 10
0
def activate_relay(index):
    """ Activates the relay at the specified index """
    return atmega.write("r {}\n".format(index))
Ejemplo n.º 11
0
def set_config(index, val):
    """ Set a desired config value on the arduino """
    return atmega.write("e {} {}\n".format(index, val))