pid
Torch-based PID controllers for batched simulation.
类:
| 名称 | 描述 |
|---|---|
PID |
Vectorized PID controller for multiple environments. |
FlightController |
PID flight controller (batched). |
PID
PID(Kp: Tensor, Ki: Tensor | None = None, Kd: Tensor | None = None, dt: float = 0.01, N: float = 100.0, integral_limit: Tensor | None = None, num_envs: int = 1)
Vectorized PID controller for multiple environments.
Initialize PID gains and state tensors.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
Tensor
|
Proportional gain tensor with a leading environment dimension. |
必需 |
|
Tensor | None
|
Integral gain tensor with the same shape as |
None
|
|
Tensor | None
|
Derivative gain tensor with the same shape as |
None
|
|
float
|
Controller time step. |
0.01
|
|
float
|
First-order derivative filter coefficient. |
100.0
|
|
Tensor | None
|
Optional clamp applied elementwise to the integral state. |
None
|
|
int
|
Number of environments. |
1
|
方法:
| 名称 | 描述 |
|---|---|
reset |
Reset PID state for selected environments. |
update |
Compute PID output for the given error tensor. |
reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None
Reset PID state for selected environments.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
slice | Sequence[int] | Tensor
|
Indices or slice selecting which environments to reset. |
必需 |
update
update(error: Tensor) -> torch.Tensor
Compute PID output for the given error tensor.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
Tensor
|
Batched control error tensor compatible with the internal
state shape determined from |
必需 |
返回:
| 类型 | 描述 |
|---|---|
Tensor
|
torch.Tensor: Combined P+I+D control output. |
FlightController
FlightController(params: VehicleParams = VehicleParams(), control_mask: dict | None = None, gains: dict | None = None, limits: dict | None = None, num_envs: int = 1, device: str | device = 'cpu')
Bases: ControllerBase
PID flight controller (batched).
Initialize the batched flight PID controller.
方法:
| 名称 | 描述 |
|---|---|
randomize |
Randomize configured PID gains, controller limits, and physical params. |
reset |
Reset PID loops for selected environments. |
update |
Update controller. |
gains_to_randomization_ranges |
Convert static gains dict to domain randomization min/max ranges. |
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
params |
VehicleParams
|
Vehicle parameters for the controller. |
params
instance-attribute
params: VehicleParams = params
Vehicle parameters for the controller.
randomize
randomize(env_ids=None, gains=None, limits=None, params=None)
Randomize configured PID gains, controller limits, and physical params.
reset
reset(env_ids)
Reset PID loops for selected environments.
update
update(target: ControllerTarget, state: ControllerState) -> torch.Tensor
Update controller.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
ControllerTarget
|
ControllerTarget with batched tensors, keys matching mask. |
必需 |
|
ControllerState
|
ControllerState: pos(N,3), vel(N,3), att_euler(N,3), ang_vel(N,3). |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
Tensor |
(N, 4)
|
[thrust, roll_moment, pitch_moment, yaw_moment]. |
gains_to_randomization_ranges
classmethod
gains_to_randomization_ranges(gains=None, scale=0.2)
Convert static gains dict to domain randomization min/max ranges.
Each non-zero gain is scaled by (1-scale) for min and (1+scale) for max.
Defaults to cls.DEFAULT_GAINS when gains is None.