control.controller#

Base class for controller implementations.

Your task is to implement your own controller. This class must be the parent class of your implementation. You have to use the same function signatures as defined by the base class. Apart from that, you are free to add any additional methods, attributes, or classes to your controller.

As an example, you could load the weights of a neural network in the constructor and use it to compute the control commands in the compute_control method. You could also use the step_callback method to update the controller state at runtime.

Note

You can only define one controller class in a single file. Otherwise we will not be able to determine which class to use.

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

Base class for controller implementations.

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

Compute the next desired state of the drone.

Instructions:

Implement this method to return the target state to be sent to the Crazyflie.

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

  • info – Optional additional information as a dictionary.

Returns:

A drone state command [x, y, z, vx, vy, vz, ax, ay, az, yaw, rrate, prate, yrate] in absolute coordinates or an attitude command [thrust, roll, pitch, yaw] 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#

Callback function called once after the control step.

You can use this function to update your controller’s internal state, save training data, update your models, and to terminate the episode.

Instructions:

Use any collected information to learn, adapt, and/or re-plan.

Parameters:
  • action – Latest applied action.

  • obs – Latest environment observation.

  • reward – Latest reward.

  • terminated – Latest terminated flag.

  • truncated – Latest truncated flag.

  • info – Latest information dictionary.

Returns:

A flag to signal if the controller has finished.

episode_callback()#

Callback function called once after each episode.

You can use this function to reset your controller’s internal state, save training data, train your models, compute additional statistics, etc.

Instructions:

Use any collected information to learn, adapt, and/or re-plan.

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.

episode_reset()#

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