コード例 #1
0
ファイル: command.py プロジェクト: avbotz/change-me
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])
コード例 #2
0
ファイル: query.py プロジェクト: avbotz/change-me
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)
コード例 #3
0
ファイル: query.py プロジェクト: avbotz/change-me
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
コード例 #4
0
ファイル: command.py プロジェクト: avbotz/change-me
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
コード例 #5
0
ファイル: command.py プロジェクト: avbotz/change-me
def set_speed(val):
    """ sets speed of sub, I don't know if we use this """
    return atmega.write("o {}\n".format(val))
コード例 #6
0
ファイル: command.py プロジェクト: avbotz/change-me
def kill():
    """ Sets the motor power to 0 """
    return atmega.write("p 0\n")
    return atmega.write("o 0\n")
コード例 #7
0
ファイル: command.py プロジェクト: avbotz/change-me
def set_power(val):
    """ Sets the motor power """
    return atmega.write("p {}\n".format(val))
コード例 #8
0
ファイル: command.py プロジェクト: avbotz/change-me
def drop():
    """ Activates dropper """
    return atmega.write("r 3\n")
コード例 #9
0
ファイル: command.py プロジェクト: avbotz/change-me
def untilt():
    """ Sets pitch and roll to 0 to level out the sub """
    return atmega.write("u\n")
コード例 #10
0
ファイル: command.py プロジェクト: avbotz/change-me
def activate_relay(index):
    """ Activates the relay at the specified index """
    return atmega.write("r {}\n".format(index))
コード例 #11
0
ファイル: command.py プロジェクト: avbotz/change-me
def set_config(index, val):
    """ Set a desired config value on the arduino """
    return atmega.write("e {} {}\n".format(index, val))