Skip to content

base

Base interfaces for LAV2 controllers.

Classes:

Name Description
ControllerState

Sparse controller state fields shared by measured state and target dicts.

ControllerBase

Abstract controller base class.

Attributes:

Name Type Description
ControllerTarget

Desired controller target fields; schema matches :class:ControllerState.

ControllerTarget module-attribute

ControllerTarget = ControllerState

Desired controller target fields; schema matches :class:ControllerState.

ControllerState

Bases: TypedDict

Sparse controller state fields shared by measured state and target dicts.

Attributes:

Name Type Description
thrust ArrayLike

Collective thrust in newtons, shape (N, 1).

pos ArrayLike

World-frame position, shape (N, 3).

vel ArrayLike

World-frame linear velocity, shape (N, 3).

vel_b ArrayLike

Body-frame linear velocity, shape (N, 3); used by ground control.

acc ArrayLike

World-frame linear acceleration, shape (N, 3).

att_euler ArrayLike

Roll, pitch, yaw angles in radians, shape (N, 3).

att_quat ArrayLike

Quaternion attitude in xyzw order, shape (N, 4).

att_rotmat ArrayLike

Flattened attitude rotation matrix, shape (N, 9).

att_rotvec ArrayLike

Attitude rotation vector in radians, shape (N, 3).

ang_vel ArrayLike

Body angular velocity in radians per second, shape (N, 3).

thrust instance-attribute

thrust: ArrayLike

Collective thrust in newtons, shape (N, 1).

pos instance-attribute

pos: ArrayLike

World-frame position, shape (N, 3).

vel instance-attribute

vel: ArrayLike

World-frame linear velocity, shape (N, 3).

vel_b instance-attribute

vel_b: ArrayLike

Body-frame linear velocity, shape (N, 3); used by ground control.

acc instance-attribute

acc: ArrayLike

World-frame linear acceleration, shape (N, 3).

att_euler instance-attribute

att_euler: ArrayLike

Roll, pitch, yaw angles in radians, shape (N, 3).

att_quat instance-attribute

att_quat: ArrayLike

Quaternion attitude in xyzw order, shape (N, 4).

att_rotmat instance-attribute

att_rotmat: ArrayLike

Flattened attitude rotation matrix, shape (N, 9).

att_rotvec instance-attribute

att_rotvec: ArrayLike

Attitude rotation vector in radians, shape (N, 3).

ang_vel instance-attribute

ang_vel: ArrayLike

Body angular velocity in radians per second, shape (N, 3).

ControllerBase

ControllerBase(params: VehicleParams, control_mask: dict | None = None, gains: dict | None = None)

Bases: ABC

Abstract controller base class.

Initialize shared controller state.

Parameters:

Name Type Description Default

params

VehicleParams

Vehicle parameters for the controller.

required

control_mask

dict | None

Dict mask mapped to state keys. e.g. {"pos": [1, 1, 1], "att_euler": [0, 0, 1]} for position+yaw control. Keys not present are cascade-computed.

None

gains

dict | None

Optional gains configuration for derived controllers.

None

Methods:

Name Description
update

Update the controller and return control outputs.

reset

Reset controller state if necessary.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask dict

Control mask dict mapped to state keys, used in update().

gains dict | None

Optional gains configuration for derived controllers.

target ControllerTarget

Latest target dict input to the controller.

params instance-attribute

params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute

control_mask: dict = control_mask if control_mask is not None else {}

Control mask dict mapped to state keys, used in update().

gains instance-attribute

gains: dict | None = gains

Optional gains configuration for derived controllers.

target instance-attribute

target: ControllerTarget = {}

Latest target dict input to the controller.

update abstractmethod

update(target: ControllerTarget, state: ControllerState)

Update the controller and return control outputs.

Parameters:

Name Type Description Default

target

ControllerTarget

Dict with state keys and desired values.

required

state

ControllerState

Dict with current state keys.

required

Returns:

Type Description

Control output array.

reset abstractmethod

reset(*args, **kwargs)

Reset controller state if necessary.