mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 17:38:32 -04:00
GCS_MAVLink: fixed bug setting parameters to default values
in copter if you try to set RATE_RLL_D to 0 when you haven't prevviously changed it then it would set it, but would revert on the next reboot. This is because of the special case handling of a set to the "default" value. That default value is unaware of the PID constructors this fixes that behaviour by forcing a save if the parameter changes value
This commit is contained in:
parent
cb8356a290
commit
347c436394
@ -556,13 +556,27 @@ void GCS_MAVLINK::handle_param_set(mavlink_message_t *msg, DataFlash_Class *Data
|
|||||||
strncpy(key, (char *)packet.param_id, AP_MAX_NAME_SIZE);
|
strncpy(key, (char *)packet.param_id, AP_MAX_NAME_SIZE);
|
||||||
key[AP_MAX_NAME_SIZE] = 0;
|
key[AP_MAX_NAME_SIZE] = 0;
|
||||||
|
|
||||||
vp = AP_Param::set_param_by_name(key, packet.param_value, &var_type);
|
// find existing param so we can get the old value
|
||||||
|
vp = AP_Param::find(key, &var_type);
|
||||||
if (vp == NULL) {
|
if (vp == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
float old_value = vp->cast_to_float(var_type);
|
||||||
|
|
||||||
|
// set the value
|
||||||
|
vp->set_float(packet.param_value, var_type);
|
||||||
|
|
||||||
|
/*
|
||||||
|
we force the save if the value is not equal to the old
|
||||||
|
value. This copes with the use of override values in
|
||||||
|
constructors, such as PID elements. Otherwise a set to the
|
||||||
|
default value which differs from the constructor value doesn't
|
||||||
|
save the change
|
||||||
|
*/
|
||||||
|
bool force_save = !is_equal(packet.param_value, old_value);
|
||||||
|
|
||||||
// save the change
|
// save the change
|
||||||
vp->save();
|
vp->save(force_save);
|
||||||
|
|
||||||
// Report back the new value if we accepted the change
|
// Report back the new value if we accepted the change
|
||||||
// we send the value we actually set, which could be
|
// we send the value we actually set, which could be
|
||||||
|
Loading…
Reference in New Issue
Block a user