(a, b, q, r)
return k, p
Compute the continuous time LQR-controller.

    The optimal control input is `u = -k.dot(x)`.

    Parameters
    ----------
    a : np.array
    b : np.array
    q : np.array
    r : np.array

    Returns
    -------
    k : np.array
        Controller matrix
    p : np.array
        Cost to go matrix
Compute the continuous time LQR-controller.
Compute the continuous time LQR - controller .
def lqr(a, b, q, r):
    """Compute the continuous time LQR-controller.

    The optimal control input is `u = -k.dot(x)`.

    Parameters
    ----------
    a : np.array
    b : np.array
    q : np.array
    r : np.array

    Returns
    -------
    k : np.array
        Controller matrix
    p : np.array
        Cost to go matrix
    """
    a, b, q, r = map(np.atleast_2d, (a, b, q, r))
    p = scipy.linalg.solve_continuous_are(a, b, q, r)

    # LQR gain
    k = np.linalg.solve(r, b.T.dot(p))

    return k, p
def lqr ( a , b , q , r ) : a , b , q , r = map ( np . atleast_2d , ( a , b , q , r ) ) p = scipy . linalg . solve_continuous_are ( a , b , q , r ) # LQR gain k = np . linalg . solve ( r , b . T . dot ( p ) ) return k , p