Exemplo n.º 1
0
def plant(T, initD):
    gain = sm.Gain(T)
    delay_x = sm.R(0)

    delay_y = sm.FeedbackAdd(sm.Gain(1), sm.R(initD))

    return sm.Cascade(sm.Cascade(gain, delay_x), delay_y)
Exemplo n.º 2
0
def wallFinderSystem(T, initD, k):
    controller_v = controller(k)
    plant_v = plant(T, initD)
    sensor_v = sensor(initD)
    return sm.Cascade(
        sm.Gain(-1), sm.FeedbackAdd(sm.Cascade(controller_v, plant_v),
                                    sensor_v))
Exemplo n.º 3
0
def plant(t, initD):
    """
    Returns a state machine whose input is the commanded velocity
    and whose output is the distance to the wall.
    
    Args:
        t - the duration of a time step
        initD - the starting distance from the wall
    """
    movement = sm.Gain(t)
    position = sm.R(initD)
    return sm.FeedbackAdd(movement, position)
Exemplo n.º 4
0
def accumulator(init):
    """
    Args:
        init (int): the output at time 0

    Returns:
        y: a state machine whose output at time n is the sum of its inputs up to 
        and including time n
    """
    wire = sm.Gain(1)
    yDelay = sm.Delay(init)
    y = sm.FeedbackAdd(wire, yDelay)
    return y
Exemplo n.º 5
0
def accumulatorDelayScaled(s, init):
    """
    Args:
        s (int): the scale factor
        init (int): the output at time 0

    Returns:
        y: a state machine whose output at time n is the sum of the scaled 
        inputs (each scaled by s) up to and including time n-1
    """
    xScale = sm.Gain(s)
    y = sm.Cascade(xScale, accumulatorDelay(init))
    return y
Exemplo n.º 6
0
def plant(T, initD):
    return sm.Cascade(sm.Gain(-T), sm.FeedbackAdd(sm.R(initD), sm.Wire()))
Exemplo n.º 7
0
def controller(k):
    return sm.Gain(k)
Exemplo n.º 8
0
def accumulator(init):
    none_there = sm.Gain(1)
    y_delay = sm.R(init)
    y = sm.FeedbackAdd(none_there, y_delay)
    return y
Exemplo n.º 9
0
def accumulatorDelayScaled(s, init):
    x_scale = sm.Gain(s)
    return sm.Cascade(x_scale, accumulatorDelay(init))
Exemplo n.º 10
0
def accumulatorDelay(init):
    return sm.FeedbackAdd(sm.R(init), sm.Gain(1.0))
Exemplo n.º 11
0
def accumulatorDelayScaled(init, s):
    return sm.Cascade(sm.FeedbackAdd(sm.R(init), sm.Gain(1.0)), sm.Gain(s))
Exemplo n.º 12
0
def accumulator(init):
    """
    Returns a state machine such that y[n] = y[n-1] + x[n] with a starting state of init.
    """
    return sm.FeedbackAdd(sm.Gain(1), sm.R(init))
Exemplo n.º 13
0
def accumulatorDelayScaled(s, init):
    """
    Returns a state machine such that y[n] = y[n-1] + sx[n-1].
    """
    return sm.Cascade(accumulatorDelay(init), sm.Gain(s))
Exemplo n.º 14
0
def controller(k):
    """
    Returns a state machine whose output is k times its input.
    """
    return sm.Gain(k)