Available UAV platforms in PyFlyt
masterPyFlyt provides several default Unmanned Aerial Vehicle (UAV) platforms for simulation. The available platforms are:
- Fixed-wing (
drones/fixedwing) - Rocket (
drones/rocket) - QuadX (
drones/quadx)
repository·master·Indexed 42 days ago
https://github.com/jjshoots/pyflytA UAV flight simulator designed for reinforcement learning research, providing Gymnasium environments for single-agent tasks and PettingZoo environments for multi-agent scenarios. Version 0.30.0 features the Aviary API for managing drone collections, a modular drone abstraction system for custom UAV construction, and support for various drone components like motors, lifting surfaces, and cameras.
PyFlyt provides several default Unmanned Aerial Vehicle (UAV) platforms for simulation. The available platforms are:
drones/fixedwing)drones/rocket)drones/quadx)MAQuadXHoverEnvV2 environment, the objective for all agents is to maintain a hover at their initial starting positions for the maximum duration possible.The QuadX UAV follows the Quad-X configuration used by ArduPilot and PX4. You can select between two different model implementations using the drone_model parameter when initializing the drone:
cf2x (default): The standard model.primitive_drone: A simplified model variant.# Example of selecting a specific model variant
drone = QuadX(drone_model='primitive_drone')PyFlyt allows decoupling the physics simulation frequency from the drone control looprate.
Physics Frequency:
Set via physics_hz in Aviary. The default is 240 Hz. Changing this is not recommended as it may cause instability.
Control Looprate:
Set via control_hz inside the drone_options dictionary.
Constraints:
control_hz must be a common denominator of the physics_hz (i.e., physics_hz % control_hz == 0).[30, 60, 120] is valid, but [30, 40, 120] is invalid because 40/30 is not an integer).The drone_type argument in Aviary defines the type of UAV(s) to spawn. It accepts a lowercase string for a single type or a list of strings for multiple drones with different types.
Built-in drone types:
fixedwingrocketquadxSpawning Custom Drones:
To use a custom drone class, provide a mapping via drone_type_mappings where the key is the string name and the value is the class (not an instance).
# Spawning a custom drone
from my_module import MyCustomDrone
drone_type_mappings = {"mycustomdrone": MyCustomDrone}
env = Aviary(
...,
drone_type="mycustomdrone",
drone_type_mappings=drone_type_mappings
)The Camera component simulates a camera attached to a specific link on a drone. It can be configured with a gimbal to achieve a horizon lock effect.
When an image is captured, the camera returns three distinct data outputs:
Configurable parameters include:
The DroneClass is the fundamental abstraction for all UAVs in PyFlyt. It serves as the base class for defining drone behavior, physics, and state. When implementing a custom drone, you must satisfy the required attributes and methods to ensure compatibility with the simulator's physics and control loops.
physics_period and control_period.state, an aux_state for additional information, and a setpoint which represents the target state or command.The Boosters component simulates a collection of fueled propulsion units. Boosters generate thrust on specific links but do not generate torque around the thrust axis.
booster_ids: A list of IDs for the links where thrust is applied.fueltank_ids: A list of IDs for the fuel tanks whose mass and inertia properties are modified as fuel is consumed.reignitable: A boolean option indicating if the booster can be extinguished and restarted (typical for liquid fuel boosters).Thrust is controlled via ignition and pwm commands. The transformation follows these steps:
target_duty_cycle = min_thrust + (min_thrust / max_thrust) * pwm. If no fuel remains or the booster is not ignited, it is 0.actual_duty_cycle approaches the target based on a time constant tau: actual_duty_cycle += 1 / physics_hz / tau * (target_duty_cycle - actual_duty_cycle).thrust = (actual_duty_cycle * max_thrust) * (1 + noise * noise_ratio), where noise is sampled from a standard Normal distribution.Fuel burn is proportional to the thrust relative to maximum thrust: fuel_burn = thrust / max_thrust * max_fuel_burn. As fuel is consumed, the mass and inertia properties of the associated fueltank_ids are updated accordingly.
To redirect thrust, pass a rotation matrix to the physics_update method. This is designed to work seamlessly with the Gimbals component, which outputs the required rotation matrix.
PyFlyt is structured around a hierarchical relationship between environments and agents:
Aviary: The top-level domain/environment that manages the physics and the collection of drones.This modular design allows users to define new drone types by combining existing abstractions or implementing new ones.
The PyFlyt.core.abstractions.Gimbals component simulates a series of servo-actuated gimbals. It is used to redirect thrust from Motors or Boosters components by providing rotation about two different, arbitrary axes on a link.
Each gimbal setup consists of two units, gimbal_unit_1 and gimbal_unit_2. Rotation follows the right-handed rotation rule.
The Motors component simulates a series of brushless electric motor-driven propellers. Unlike Boosters, Motors feature more linear dynamics and support for reversed thrust.
The simulation follows these steps:
actual_duty_cycle ramps toward the target_duty_cycle based on a time constant tau and the physics frequency (physics_hz).actual_duty_cycle and max_rpm, subject to Gaussian noise.thrust_coef and torque_coef respectively.You can redirect the thrust direction by passing a rotation matrix to the physics_update method. This is particularly useful when integrating with the Gimbals component, which outputs the required rotation matrix.