control.attitude_mpc¶
lsy_drone_racing.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.
Classes¶
AttitudeMPC(obs, info, config)
¶
Bases: Controller
Example of a MPC using the collective thrust and attitude interface.
Initialize the attitude 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
|
Additional environment information from the reset. |
required |
config
|
dict
|
The configuration of the environment. |
required |
Source code in lsy_drone_racing/control/attitude_mpc.py
Methods:¶
compute_control(obs, info=None)
¶
Compute the next desired collective thrust and roll/pitch/yaw 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 orientation as roll, pitch, yaw angles, and the collective thrust |
NDArray[floating]
|
[r_des, p_des, y_des, t_des] as a numpy array. |
Source code in lsy_drone_racing/control/attitude_mpc.py
episode_callback()
¶
episode_reset()
¶
render_callback(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.
Source code in lsy_drone_racing/control/controller.py
reset()
¶
step_callback(action, obs, reward, terminated, truncated, info)
¶
Increment the tick counter.
Source code in lsy_drone_racing/control/attitude_mpc.py
Functions:¶
create_acados_model(parameters)
¶
Creates an acados model from a symbolic drone_model.
Source code in lsy_drone_racing/control/attitude_mpc.py
create_ocp_solver(Tf, N, parameters, verbose=False)
¶
Creates an acados Optimal Control Problem and Solver.
Source code in lsy_drone_racing/control/attitude_mpc.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |