control.attitude_controller#

This module implements an AttitudeController for quadrotor control.

It utilizes the collective thrust interface for drone control to compute control commands based on current state observations and desired waypoints. The attitude control is handled by computing a PID control law for position tracking, incorporating gravity compensation in thrust calculations.

The waypoints are generated using cubic spline interpolation from a set of predefined waypoints. Note that the trajectory uses pre-defined waypoints instead of dynamically generating a good path.

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

Example of a controller using the collective thrust and attitude interface.

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

Compute the next desired collective thrust and roll/pitch/yaw 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 orientation as roll, pitch, yaw angles, and the collective thrust [r_des, p_des, y_des, t_des] 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 tick counter.

Returns:

True if the controller is finished, False otherwise.

episode_callback()#

Reset the internal state.

episode_reset()#

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

render_callback(sim: Sim)#

Callback function called before the environment’s rendering.

You can use this function to render additional information on the screen, such as the planned trajectory, the drone’s target state, etc.

reset()#

Reset internal variables if necessary.