Generic callback registered for all the groups
(self, name, value)
| 97 | print('The connected Crazyflie has {}kb of flash'.format(value)) |
| 98 | |
| 99 | def _param_callback(self, name, value): |
| 100 | """Generic callback registered for all the groups""" |
| 101 | print('{0}: {1}'.format(name, value)) |
| 102 | |
| 103 | # Remove each parameter from the list and close the link when |
| 104 | # all are fetched |
| 105 | self._param_check_list.remove(name) |
| 106 | if len(self._param_check_list) == 0: |
| 107 | print('Have fetched all parameter values.') |
| 108 | |
| 109 | # First remove all the group callbacks |
| 110 | for g in self._param_groups: |
| 111 | self._cf.param.remove_update_callback(group=g, |
| 112 | cb=self._param_callback) |
| 113 | |
| 114 | # Create a new random value [0.00,1.00] for pid_attitude.pitch_kd |
| 115 | # and set it |
| 116 | pkd = random.random() |
| 117 | print('') |
| 118 | print('Write: pid_attitude.pitch_kd={:.2f}'.format(pkd)) |
| 119 | self._cf.param.add_update_callback(group='pid_attitude', |
| 120 | name='pitch_kd', |
| 121 | cb=self._a_pitch_kd_callback) |
| 122 | # When setting a value the parameter is automatically read back |
| 123 | # and the registered callbacks will get the updated value |
| 124 | self._cf.param.set_value('pid_attitude.pitch_kd', |
| 125 | '{:.2f}'.format(pkd)) |
| 126 | |
| 127 | def _a_pitch_kd_callback(self, name, value): |
| 128 | """Callback for pid_attitude.pitch_kd""" |
nothing calls this directly
no test coverage detected