mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 12:23:23 +08:00
[fix] add some ref and set_integral function to PID lib
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
Decawave DW1000 modules (http://www.decawave.com/products/dwm1000-module) are Ultra-Wide-Band devices that can be used for communication and ranging.
|
Decawave DW1000 modules (http://www.decawave.com/products/dwm1000-module) are Ultra-Wide-Band devices that can be used for communication and ranging.
|
||||||
Especially, using 3 modules as anchors can provide data for a localization system based on trilateration.
|
Especially, using 3 modules as anchors can provide data for a localization system based on trilateration.
|
||||||
The DW1000 is using a SPI connection, but an arduino-compatible board can be used with the library https://github.com/thotro/arduino-dw1000 to hyde the low level drivers and provide direct ranging informations.
|
The DW1000 is using a SPI connection, but an arduino-compatible board can be used with the library https://github.com/thotro/arduino-dw1000 to hyde the low level drivers and provide direct ranging informations.
|
||||||
|
|
||||||
|
See https://hal-enac.archives-ouvertes.fr/hal-01936955 for more information on the EKF filtering.
|
||||||
</description>
|
</description>
|
||||||
<configure name="DW1000_ARDUINO_UART" value="UARTX" description="UART on which arduino and its DW1000 module is connected"/>
|
<configure name="DW1000_ARDUINO_UART" value="UARTX" description="UART on which arduino and its DW1000 module is connected"/>
|
||||||
<configure name="DW1000_ARDUINO_BAUD" value="B115200" description="UART Baudrate, default to 115200"/>
|
<configure name="DW1000_ARDUINO_BAUD" value="B115200" description="UART Baudrate, default to 115200"/>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
with precision or in a net.
|
with precision or in a net.
|
||||||
|
|
||||||
Data are coming from POSITION_ESTIMATE ABI message.
|
Data are coming from POSITION_ESTIMATE ABI message.
|
||||||
|
|
||||||
|
See https://hal-enac.archives-ouvertes.fr/hal-01936955 for more information on UAV landing in a net.
|
||||||
</description>
|
</description>
|
||||||
<section name="SHIFT_TRACKING" prefix="SHIFT_TRACKING_">
|
<section name="SHIFT_TRACKING" prefix="SHIFT_TRACKING_">
|
||||||
<define name="ID" value="ABI_BROADCAST" description="ABI binding ID"/>
|
<define name="ID" value="ABI_BROADCAST" description="ABI binding ID"/>
|
||||||
|
|||||||
@@ -117,6 +117,27 @@ static inline void set_gains_pid_f(struct PID_f *pid, float Kp, float Kd, float
|
|||||||
pid->g[2] = Ki;
|
pid->g[2] = Ki;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set integral part, can be used to reset.
|
||||||
|
* The new sum of errors is calculated from current gains and bounds.
|
||||||
|
*
|
||||||
|
* @param pid pointer to PID structure
|
||||||
|
* @param value integral part of the PID control, 0. will reset it
|
||||||
|
*/
|
||||||
|
static inline void set_integral_pid_f(struct PID_f *pid, float value)
|
||||||
|
{
|
||||||
|
float integral = value;
|
||||||
|
if (integral < -pid->max_sum) {
|
||||||
|
integral = -pid->max_sum;
|
||||||
|
} else if (integral > pid->max_sum) {
|
||||||
|
integral = pid->max_sum;
|
||||||
|
}
|
||||||
|
if (fabsf(pid->g[2]) < 1e-6) {
|
||||||
|
pid->sum = 0.f; // integral gain is too low, prevent division by zero, just reset sum
|
||||||
|
} else {
|
||||||
|
pid->sum = integral / pid->g[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Distcrete time PID structure.
|
/** Distcrete time PID structure.
|
||||||
|
|||||||
Reference in New Issue
Block a user