本文整理汇总了C++中PID::resetIntegral方法的典型用法代码示例。如果您正苦于以下问题:C++ PID::resetIntegral方法的具体用法?C++ PID::resetIntegral怎么用?C++ PID::resetIntegral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PID
的用法示例。
在下文中一共展示了PID::resetIntegral方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
void loop(void)
{
static uint32_t rcTime = 0;
static uint32_t loopTime;
static uint32_t calibratedAccTime;
static bool accCalibrated;
static bool armed;
static uint16_t calibratingA;
static uint32_t currentTime;
static uint32_t disarmTime = 0;
if (check_and_update_timed_task(&rcTime, CONFIG_RC_LOOPTIME_USEC, currentTime)) {
// update RC channels
rc.update();
// when landed, reset integral component of PID
if (rc.throttleIsDown())
pid.resetIntegral();
if (rc.changed()) {
if (armed) { // actions during armed
// Disarm on throttle down + yaw
if (rc.sticks == THR_LO + YAW_LO + PIT_CE + ROL_CE) {
if (armed) {
armed = false;
// Reset disarm time so that it works next time we arm the board.
if (disarmTime != 0)
disarmTime = 0;
}
}
} else { // actions during not armed
// GYRO calibration
if (rc.sticks == THR_LO + YAW_LO + PIT_LO + ROL_CE) {
calibratingG = CONFIG_CALIBRATING_GYRO_CYCLES;
}
// Arm via YAW
if ((rc.sticks == THR_LO + YAW_HI + PIT_CE + ROL_CE)) {
if (calibratingG == 0 && accCalibrated) {
if (!armed) { // arm now!
armed = true;
}
} else if (!armed) {
blinkLED(2, 255, 1);
}
}
// Calibrating Acc
else if (rc.sticks == THR_HI + YAW_LO + PIT_LO + ROL_CE)
calibratingA = CONFIG_CALIBRATING_ACC_CYCLES;
} // not armed
} // rc.changed()
} else { // not in rc loop
static int taskOrder; // never call all functions in the same loop, to avoid high delay spikes
switch (taskOrder) {
case 0:
taskOrder++;
//sensorsGetBaro();
case 1:
taskOrder++;
//sensorsGetSonar();
case 2:
taskOrder++;
case 3:
taskOrder++;
case 4:
taskOrder = 0;
break;
}
}
currentTime = board.getMicros();
if (check_and_update_timed_task(&loopTime, CONFIG_IMU_LOOPTIME_USEC, currentTime)) {
imu.update(armed, calibratingA, calibratingG);
haveSmallAngle = abs(imu.angle[0]) < CONFIG_SMALL_ANGLE && abs(imu.angle[1]) < CONFIG_SMALL_ANGLE;
// measure loop rate just afer reading the sensors
currentTime = board.getMicros();
previousTime = currentTime;
// compute exponential RC commands
rc.computeExpo();
// use LEDs to indicate calibration status
if (calibratingA > 0 || calibratingG > 0) {
board.ledGreenToggle();
} else {
if (accCalibrated)
//.........这里部分代码省略.........