simple_pendulum.controllers.lqr

Linear Quadratic Regulator (LQR)

Subpackages

Submodules

simple_pendulum.controllers.lqr.lqr

LQR solver

Adapted from Mark Wilfried Mueller

simple_pendulum.controllers.lqr.lqr.dlqr(A, B, Q, R)

Solve the discrete time lqr controller. x[k+1] = A x[k] + B u[k] cost = sum x[k].T*Q*x[k] + u[k].T*R*u[k] ref: Bertsekas, p.151

simple_pendulum.controllers.lqr.lqr.lqr(A, B, Q, R)

Solve the continuous time lqr controller. dx/dt = A x + B u cost = integral x.T*Q*x + u.T*R*u ref: Bertsekas, p.151

simple_pendulum.controllers.lqr.lqr_controller

LQR Controller

class simple_pendulum.controllers.lqr.lqr_controller.LQRController(mass=1.0, length=0.5, inertia=None, damping=0.1, coulomb_fric=0.0, gravity=9.81, torque_limit=inf, Q=array([[10, 0], [0, 1]]), R=array([[1]]), compute_RoA=False)

Bases: AbstractController

Controller which stabilizes the pendulum at its instable fixpoint.

get_control_output(meas_pos, meas_vel, meas_tau=0, meas_time=0)

The function to compute the control input for the pendulum actuator :param meas_pos: the position of the pendulum [rad] :type meas_pos: float :param meas_vel: the velocity of the pendulum [rad/s] :type meas_vel: float :param meas_tau: the meastured torque of the pendulum [Nm]

(not used)

Parameters:

meas_time (float, default=0) – the collapsed time [s] (not used)

Returns:

  • des_pos (float) – the desired position of the pendulum [rad] (not used, returns None)

  • des_vel (float) – the desired velocity of the pendulum [rad/s] (not used, returns None)

  • des_tau (float) – the torque supposed to be applied by the actuator [Nm]

set_clip()
set_goal(goal)

Set the desired state for the controller. May not be necessary.

Parameters:
``x``: ``array like``

The desired goal state of the controller

simple_pendulum.controllers.lqr.unit_test

Unit Tests

class simple_pendulum.controllers.lqr.unit_test.Test(methodName='runTest')

Bases: TestCase

epsilon = 0.01
test_0_LQR_stabilization()