跳转至

xadap

Python implementation of Learning-based Controller for Extreme Adaptation.

Based on: Dingqi Zhang, Antonio Loquercio, Jerry Tang, Ting-Hao Wang, Jitendra Malik, Mark W. Mueller. "A Learning-based Quadcopter Controller with Extreme Adaptation" IEEE Transactions on Robotics, 41(2):3948-3964, 2025. https://doi.org/10.1109/TRO.2025.3577037

类:

名称 描述
ModelType

Enumeration for model normalization variants.

ButterworthFilter

Low-pass filter for smoothing sensor measurements.

NeuralNetworkModel

Neural network model for adaptation.

Xadap_NN_control

Controller combining high-level controller with neural adaptation.

ModelType

Bases: Enum

Enumeration for model normalization variants.

ButterworthFilter

ButterworthFilter(cutoff_freq=30, sample_rate=100)

Low-pass filter for smoothing sensor measurements.

Initialize filter coefficients and buffers.

参数:

名称 类型 描述 默认

cutoff_freq

float

Cutoff frequency in Hz.

30

sample_rate

float

Sampling rate in Hz.

100

方法:

名称 描述
run

Filter a new sample and return the smoothed value.

run

run(x_new: ndarray) -> np.ndarray

Filter a new sample and return the smoothed value.

参数:

名称 类型 描述 默认

x_new

ndarray

New sample vector.

必需

返回:

类型 描述
ndarray

np.ndarray: Filtered sample.

NeuralNetworkModel

NeuralNetworkModel()

Neural network model for adaptation.

Initialize ONNX model paths, load normalization parameters, and activate sessions.

方法:

名称 描述
activate

Initialize ONNX runtime sessions.

normalize_obs

Normalize observations based on model type.

predict

Run inference through both networks.

activate

activate()

Initialize ONNX runtime sessions.

normalize_obs

normalize_obs(obs: ndarray, model_type: ModelType) -> np.ndarray

Normalize observations based on model type.

参数:

名称 类型 描述 默认

obs

ndarray

Raw observation array.

必需

model_type

ModelType

Which normalization scheme to apply.

必需

返回:

类型 描述
ndarray

np.ndarray: Normalized observations.

predict

predict(cur_obs: ndarray, last_act: ndarray, obs_history: ndarray, act_history: ndarray) -> tuple[np.ndarray, np.ndarray]

Run inference through both networks.

参数:

名称 类型 描述 默认

cur_obs

ndarray

Current observation vector.

必需

last_act

ndarray

Previous action vector.

必需

obs_history

ndarray

Flattened observation history.

必需

act_history

ndarray

Flattened action history.

必需

返回:

类型 描述
tuple[ndarray, ndarray]

tuple[np.ndarray, np.ndarray]: Normalized and raw actions.

Xadap_NN_control

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

Bases: FlightController

Controller combining high-level controller with neural adaptation.

Initialize the hybrid controller and buffers.

参数:

名称 类型 描述 默认

params

VehicleParams

Vehicle parameters.

VehicleParams()

control_mask

dict | None

Dict mask for target/state channels, e.g. {"pos": [1, 1, 1], "att_euler": [0, 0, 1]}. None defaults to everything externally controlled.

None

gains

dict | None

Optional PID gains passed to FlightController.

None

方法:

名称 描述
update

Compute thrust and moments from target and state.

reset

Reset controller state and buffers.

属性:

名称 类型 描述
params VehicleParams

Vehicle parameters for the controller.

params instance-attribute

params: VehicleParams = params

Vehicle parameters for the controller.

update

update(target: dict, state: dict) -> np.ndarray

Compute thrust and moments from target and state.

参数:

名称 类型 描述 默认

target

dict

Desired state dict with keys matching the control mask.

必需

state

dict

Current state dict with keys: pos(3), vel(3), att_euler(3), ang_vel(3).

必需

返回:

类型 描述
ndarray

np.ndarray: Control output ordered as [thrust, Mx, My, Mz].

reset

reset(*args, **kwargs)

Reset controller state and buffers.