control.attitude_mpc#
This module implements an example MPC using attitude control for a quadrotor.
It utilizes the collective thrust interface for drone control to compute control commands based on current state observations and desired waypoints.
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.
- create_acados_model(parameters: dict) acados_template.AcadosModel#
Creates an acados model from a symbolic drone_model.
- create_ocp_solver(Tf: float, N: int, parameters: dict, verbose: bool = False) tuple[acados_template.AcadosOcpSolver, acados_template.AcadosOcp]#
Creates an acados Optimal Control Problem and Solver.
- class AttitudeMPC(obs: dict[str, NDArray[np.floating]], info: dict, config: dict)#
Example of a MPC 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.
- episode_callback()#
Reset the integral error.
- 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.