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.

class StateController(obs: dict[str, NDArray[np.floating]], info: dict, config: dict)#

State controller following a pre-defined trajectory.

compute_control(obs: dict[str, NDArray[np.floating]], info: dict | None = None) NDArray[np.floating]#

Compute the next desired state of the drone.

Parameters:
  • obs – The current observation of the environment. See the environment’s observation space for details.

  • info – Optional additional information as a dictionary.

Returns:

The drone state [x, y, z, vx, vy, vz, ax, ay, az, yaw, rrate, prate, yrate] as a numpy

array.

step_callback(action: NDArray[np.floating], obs: dict[str, NDArray[np.floating]], reward: float, terminated: bool, truncated: bool, info: dict) bool#

Increment the time step counter.

Returns:

True if the controller is finished, False otherwise.

episode_callback()#

Reset the internal state.

render_callback(sim: Sim)#

Visualize the desired trajectory and the current setpoint.

episode_reset()#

Reset the controller’s internal state and models if necessary.

reset()#

Reset internal variables if necessary.