tudelft / crazyflie-suite

Flight and data analysis framework for Crazyflies.
6 stars 2 forks source link

Setting Parameters seems to break with newer cfclient/cflib versions #2

Open SUPfeiffer opened 2 years ago

SUPfeiffer commented 2 years ago

With the newest versions of cfclient (2022.5) and cflib (0.1.19) setting parameters on the crazyflie does not work anymore. Downgrading to cfclient 2021.6.1 and cflib 0.1.16 fixes the issue. The following code can be added to verify that parameters are properly set when the kalman filter is reset (log_flight.py:166):

    def param_cb(self, name, value):
        print("Parameter " + name + " changed to " + value)

    def reset_estimator(self):
        self._cf.param.add_update_callback(group="kalman", name="resetEstimation", cb=self.param_cb)
        # Kalman
        if self.args["estimator"] == "kalman":
            self._cf.param.set_value("kalman.resetEstimation", "1")
            time.sleep(1)
            self._cf.param.set_value("kalman.resetEstimation", "0")
        # Complementary (needs changes to firmware)
        if self.args["estimator"] == "complementary":
            try:
                self._cf.param.set_value("complementaryFilter.reset", "1")
                time.sleep(1)
                self._cf.param.set_value("complementaryFilter.reset", "0")
            except:
                pass
SUPfeiffer commented 2 years ago

As a temporary hack, it is possible to manually turn the parameter framework to initialized by calling the following function before setting a parameter for the first time: self._cf.param._initialized.set()