bitcraze / crazyflie-clients-python

Host applications and library for Crazyflie written in Python.
Other
310 stars 475 forks source link

Addition of persistent parameter saving, loading to file and clearing #706

Closed gemenerik closed 8 months ago

gemenerik commented 8 months ago

Note that this pull request depends on https://github.com/bitcraze/crazyflie-lib-python/pull/443

This pull request primarily focuses on the addition of parameter file loading and saving capabilities. These new features allow users to store and retrieve persistent parameter configurations to/from file, improving usability and efficiency. Furthermore, it adds a clear

Key changes include:

  1. Parameter File Loading: The _load_param_button_clicked method has been added, which allows users to load persistent parameters from a YAML file. The method reads the file using ParamFileManager.read and sets the parameter values accordingly.

  2. Parameter File Saving: The _dump_param_button_clicked method has been added, which allows users to save the current parameters to a YAML file. The method retrieves the current parameters and their values and writes them to the file using ParamFileManager.write.

  3. Persistent Parameter Clearing: The _clear_persistent_parameter method has been added, which allows users to clear a specific persistent parameter. The method sends a clear request for the given parameter to the Crazyflie using self.cf.param.persistent_clear. It uses a callback function is_stored_cleared to handle the result of the clearing operation and an Event object wait_for_callback_event to wait for the operation to complete. If the operation is successful, a message indicating the cleared parameter is printed. If the operation fails, a failure message is printed.

  4. Parameter IO GUI: The parameter tab has been updated to include buttons for loading and saving parameter files, and for clearing the stored persistent parameters. These buttons are enabled or disabled based on the connection state.

  5. Error Handling: If setting a parameter value or storing a parameter persistently from a loaded file fails, a warning message is displayed to the user.

tobbeanton commented 8 months ago

The code looks good but I have some comments on the UI: