PR2 / pr2_ethercat_drivers

Drivers for the ethercat system and the peripherals on the PR2.
14 stars 13 forks source link

Motor model compute max current error incorrectly (ros ticket #3840) #11

Closed ahendrix closed 11 years ago

ahendrix commented 11 years ago

ethercat_hardware/src/motor_model.cpp

{{{ else if (currenterror.filter() > current_error_limit) { //complain and shut down rv = false; reason = "Current loop error too large (MCB failing to hit desired current)"; } }}}

Problems

Diagnostics: {{{ filtermutex.lock(); { motor_voltage_error = motor_voltageerror.filter(); motor_voltage_error_max = motor_voltageerror.filter_max(); abs_motor_voltage_error = abs_motor_voltageerror.filter(); abs_motor_voltage_error_max = abs_motor_voltageerror.filter_max(); current_error = currenterror.filter();
current_error_max = currenterror.filter_max(); abs_current_error = abs_currenterror.filter(); abs_current_error_max = abs_currenterror.filter_max(); est_motor_resistance = motorresistance.filter(); } filtermutex.unlock();

d.addf("Motor Voltage Error %", "%f", 100.0 * motor_voltage_error); d.addf("Max Motor Voltage Error %", "%f", 100.0 * motor_voltage_error_max); d.addf("Filtered Voltage Error %", "%f", 100.0 * abs_motor_voltage_error); d.addf("Max Filtered Voltage Error %", "%f", 100.0 * abs_motor_voltage_error_max);

d.addf("Current Error", "%f", current_error); d.addf("Max Current Error", "%f", current_error_max); d.addf("Filtered Current Error", "%f", abs_current_error); d.addf("Max Filtered Current Error", "%f", abs_current_error_max); }}}

The voltage and current error names are incorrect. They are ALL filtered, and some of them are abs(). It looks like some of these names should be removed.

We need to debug the intent of the motor model changes to see what the desired result is.

trac data:

ahendrix commented 11 years ago

[dking] The check on the current value is wrong, it should be using the value from the absolute filter.
{{{ else if (currenterror.filter() > current_error_limit) }}}

{{{ else if (abs_currenterror.filter() > current_error_limit) }}}

Dynamics of the motor controller are not being modeled, so a step input on commanded current will usually cause an error spike on both the modeled voltage and current.
A single error spike will not cause the filtered error value increase by much, and won't caused the motors to halt.

If a controller is unstable or creates a high frequency control, there will be large positive error values, followed by large negative error values. If only the absolute value of the error is filtered, these error spikes will accumulated and may cause the motors to halt.

By first filtering the error and then filtering the absolute value from the first filter, I'm hoping to cancel large positive error spikes followed closely by large negative error spikes. All the non-absolute error are very lightly filtered.

The diagnostics names are somewhat historical, they don't exactly match up to the code any more. However, the value used for "Filtered Current Error" has much more filtering than the value used for the "Current Error"