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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
float
|
Cutoff frequency in Hz. |
30
|
|
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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
ndarray
|
Raw observation array. |
必需 |
|
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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
ndarray
|
Current observation vector. |
必需 |
|
ndarray
|
Previous action vector. |
必需 |
|
ndarray
|
Flattened observation 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: list[int] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], gains: dict | None = None)
Bases: FlightController
Controller combining high-level controller with neural adaptation.
Initialize the hybrid controller and buffers.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
VehicleParams
|
Vehicle parameters. |
VehicleParams()
|
|
list[int]
|
Control mask for target/state channels. |
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
|
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. |
control_mask |
ndarray | Tensor
|
unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control. |
params
instance-attribute
params: VehicleParams = params
Vehicle parameters for the controller.
control_mask
instance-attribute
control_mask: ndarray | Tensor = control_mask
unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.
update
update(target: ndarray, state: ndarray) -> np.ndarray
Compute thrust and moments from target and state.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
ndarray
|
Desired state vector. |
必需 |
|
ndarray
|
Current state vector. |
必需 |
返回:
| 类型 | 描述 |
|---|---|
ndarray
|
np.ndarray: Control output ordered as [thrust, Mx, My, Mz]. |
reset
reset(*args, **kwargs)
Reset controller state and buffers.