PyFlyt/QuadX-Waypoints-v3
#
Task Description#
The goal of this environment is to fly a quadrotor aircraft towards a set of waypoints as fast as possible.
Usage#
import gymnasium
import PyFlyt.gym_envs
env = gymnasium.make("PyFlyt/QuadX-Waypoints-v3", render_mode="human")
term, trunc = False, False
obs, _ = env.reset()
while not (term or trunc):
obs, rew, term, trunc, _ = env.step(env.action_space.sample())
Flattening the Environment#
This environment uses the Dict
and Sequence
spaces from Gymnasium
, which are spaces with non-constant sizes.
This allows them to have complete observability without observation padding while making (human-)readability easier.
However, this results in them not being compatible with most popular reinforcement learning libraries like Stable Baselines 3 without custom wrappers.
If you would like to use this environment with those libraries, you can flatten the environment using the FlattenWaypointEnv
wrapper, where the argument context_length
specifies how many immediate targets are included in the observation.
import gymnasium
import PyFlyt.gym_envs
from PyFlyt.gym_envs import FlattenWaypointEnv
env = gymnasium.make("PyFlyt/QuadX-Waypoints-v3", render_mode="human")
env = FlattenWaypointEnv(env, context_length=2)
term, trunc = False, False
obs, _ = env.reset()
while not (term or trunc):
obs, rew, term, trunc, _ = env.step(env.action_space.sample())
Environment Options#
- class PyFlyt.gym_envs.quadx_envs.quadx_waypoints_env.QuadXWaypointsEnv(sparse_reward: bool = False, num_targets: int = 4, use_yaw_targets: bool = False, goal_reach_distance: float = 0.2, goal_reach_angle: float = 0.1, flight_mode: int = 0, flight_dome_size: float = 5.0, max_duration_seconds: float = 10.0, angle_representation: Literal['euler', 'quaternion'] = 'quaternion', agent_hz: int = 30, render_mode: None | Literal['human', 'rgb_array'] = None, render_resolution: tuple[int, int] = (480, 480))#
QuadX Waypoints Environment.
Actions are vp, vq, vr, T, ie: angular rates and thrust. The target is a set of [x, y, z, (optional) yaw] waypoints in space.
- Parameters:
sparse_reward (bool) – whether to use sparse rewards or not.
num_targets (int) – number of waypoints in the environment.
use_yaw_targets (bool) – whether to match yaw targets before a waypoint is considered reached.
goal_reach_distance (float) – distance to the waypoints for it to be considered reached.
goal_reach_angle (float) – angle in radians to the waypoints for it to be considered reached, only in effect if use_yaw_targets is used.
flight_mode (int) – the flight mode of the UAV.
flight_dome_size (float) – size of the allowable flying area.
max_duration_seconds (float) – maximum simulation time of the environment.
angle_representation (Literal["euler", "quaternion"]) – can be “euler” or “quaternion”.
agent_hz (int) – looprate of the agent to environment interaction.
render_mode (None | Literal["human", "rgb_array"]) – render_mode
render_resolution (tuple[int, int]) – render_resolution.