control.state_controller¶
lsy_drone_racing.control.state_controller
¶
Controller that follows a pre-defined trajectory.
It uses a cubic spline interpolation to generate a smooth trajectory through a series of waypoints. At each time step, the controller computes the next desired position by evaluating the spline.
.. note:: The waypoints are hard-coded in the controller for demonstration purposes. In practice, you would need to generate the splines adaptively based on the track layout, and recompute the trajectory if you receive updated gate and obstacle poses.
Classes¶
StateController(obs, info, config)
¶
Bases: Controller
State controller following a pre-defined trajectory.
Initialization of the controller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
dict[str, NDArray[floating]]
|
The initial observation of the environment's state. See the environment's observation space for details. |
required |
info
|
dict
|
The initial environment information from the reset. |
required |
config
|
dict
|
The race configuration. See the config files for details. Contains additional information such as disturbance configurations, randomizations, etc. |
required |
Source code in lsy_drone_racing/control/state_controller.py
Methods:¶
compute_control(obs, info=None)
¶
Compute the next desired state of the drone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
dict[str, NDArray[floating]]
|
The current observation of the environment. See the environment's observation space for details. |
required |
info
|
dict | None
|
Optional additional information as a dictionary. |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[floating]
|
The drone state [x, y, z, vx, vy, vz, ax, ay, az, yaw, rrate, prate, yrate] as a numpy array. |
Source code in lsy_drone_racing/control/state_controller.py
episode_callback()
¶
episode_reset()
¶
render_callback(sim)
¶
Visualize the desired trajectory and the current setpoint.
Source code in lsy_drone_racing/control/state_controller.py
reset()
¶
step_callback(action, obs, reward, terminated, truncated, info)
¶
Increment the time step counter.
Returns:
| Type | Description |
|---|---|
bool
|
True if the controller is finished, False otherwise. |