@@ -186,23 +186,23 @@ static const pbio_observer_model_t model_ev3_l = {
186186};
187187
188188static const pbio_observer_model_t model_ev3_m = {
189- .d_angle_d_speed = 90029 ,
190- .d_speed_d_speed = 959 ,
191- .d_current_d_speed = -185122 ,
192- .d_angle_d_current = 2377978 ,
193- .d_speed_d_current = 21415 ,
194- .d_current_d_current = -4432336 ,
195- .d_angle_d_voltage = 1996477 ,
196- .d_speed_d_voltage = 8917 ,
197- .d_current_d_voltage = 202362 ,
198- .d_angle_d_torque = -401501 ,
199- .d_speed_d_torque = -2047 ,
200- .d_current_d_torque = 467397 ,
201- .d_voltage_d_torque = 47722 ,
202- .d_torque_d_voltage = 8051 ,
189+ .d_angle_d_speed = 89465 ,
190+ .d_speed_d_speed = 950 ,
191+ .d_current_d_speed = -197440 ,
192+ .d_angle_d_current = 1568301 ,
193+ .d_speed_d_current = 12886 ,
194+ .d_current_d_current = -5095199 ,
195+ .d_angle_d_voltage = 2220112 ,
196+ .d_speed_d_voltage = 9410 ,
197+ .d_current_d_voltage = 209263 ,
198+ .d_angle_d_torque = -399652 ,
199+ .d_speed_d_torque = -2034 ,
200+ .d_current_d_torque = 546357 ,
201+ .d_voltage_d_torque = 49219 ,
202+ .d_torque_d_voltage = 7806 ,
203203 .d_torque_d_speed = 7365 ,
204204 .d_torque_d_acceleration = 9355 ,
205- .torque_friction = 18317 ,
205+ .torque_friction = 24593 ,
206206};
207207
208208static const pbio_observer_model_t model_nxt = {
@@ -241,17 +241,17 @@ static const pbio_servo_settings_reduced_t servo_settings_reduced[] = {
241241 .id = LEGO_DEVICE_TYPE_ID_EV3_LARGE_MOTOR ,
242242 .model = & model_ev3_l ,
243243 .rated_max_speed = 800 ,
244- .feedback_gain_low = 45 ,
244+ .feedback_gain_low = 30 ,
245245 .precision_profile = 10 ,
246- .pid_kp_low_speed_threshold = 0 ,
246+ .pid_kp_low_speed_threshold = 100 ,
247247 },
248248 {
249249 .id = LEGO_DEVICE_TYPE_ID_NXT_MOTOR ,
250250 .model = & model_nxt ,
251251 .rated_max_speed = 800 ,
252252 .feedback_gain_low = 90 ,
253253 .precision_profile = 5 ,
254- .pid_kp_low_speed_threshold = 0 ,
254+ .pid_kp_low_speed_threshold = 100 ,
255255 },
256256 #endif // PBIO_CONFIG_SERVO_EV3_NXT
257257 #if PBIO_CONFIG_SERVO_PUP_MOVE_HUB
@@ -356,4 +356,29 @@ const pbio_servo_settings_reduced_t *pbio_servo_get_reduced_settings(lego_device
356356 return NULL ;
357357}
358358
359+ /**
360+ * Overrides device specific settings.
361+ *
362+ * The reduced settings work well enough for a range of devices, simplifing
363+ * tuning and reducing code size. This function provides a hook for devices
364+ * that still need some specific tuning.
365+ *
366+ * @param [in] settings Base settings, unpacked from minimal settings.
367+ * @param [in] id Type identifier for which to look up the settings.
368+ */
369+
370+ void pbio_servo_override_settings (pbio_control_settings_t * settings , lego_device_type_id_t id ) {
371+ #if PBIO_CONFIG_SERVO_EV3_NXT
372+ if (id == LEGO_DEVICE_TYPE_ID_EV3_MEDIUM_MOTOR ) {
373+ settings -> pid_kp /= 3 ;
374+ settings -> pid_ki /= 2 ;
375+ settings -> pid_kd /= 10 ;
376+ } else if (id == LEGO_DEVICE_TYPE_ID_EV3_LARGE_MOTOR || id == LEGO_DEVICE_TYPE_ID_NXT_MOTOR ) {
377+ settings -> pid_kp = settings -> pid_kp * 2 / 3 ;
378+ settings -> pid_ki = settings -> pid_ki * 2 / 3 ;
379+ settings -> pid_kd /= 6 ;
380+ }
381+ #endif
382+ }
383+
359384#endif // PBIO_CONFIG_SERVO
0 commit comments