mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 05:53:35 +08:00
autolaunch: added param for delay
This commit is contained in:
@@ -51,7 +51,8 @@ CatapultLaunchMethod::CatapultLaunchMethod(SuperBlock *parent) :
|
|||||||
integrator(0.0f),
|
integrator(0.0f),
|
||||||
launchDetected(false),
|
launchDetected(false),
|
||||||
threshold_accel(this, "A"),
|
threshold_accel(this, "A"),
|
||||||
threshold_time(this, "T")
|
threshold_time(this, "T"),
|
||||||
|
delay(this, "DELAY")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -78,21 +79,33 @@ void CatapultLaunchMethod::update(float accel_x)
|
|||||||
// (double)integrator, (double)threshold_accel.get(), (double)threshold_time.get(), (double)accel_x, (double)dt);
|
// (double)integrator, (double)threshold_accel.get(), (double)threshold_time.get(), (double)accel_x, (double)dt);
|
||||||
/* reset integrator */
|
/* reset integrator */
|
||||||
integrator = 0.0f;
|
integrator = 0.0f;
|
||||||
launchDetected = false;
|
}
|
||||||
|
|
||||||
|
if (launchDetected) {
|
||||||
|
delayCounter += dt;
|
||||||
|
if (delayCounter > delay.get()) {
|
||||||
|
delayPassed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CatapultLaunchMethod::getLaunchDetected()
|
bool CatapultLaunchMethod::getLaunchDetected()
|
||||||
{
|
{
|
||||||
return launchDetected;
|
if (delay.get() > 0.0f) {
|
||||||
|
return delayPassed;
|
||||||
|
} else {
|
||||||
|
return launchDetected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CatapultLaunchMethod::reset()
|
void CatapultLaunchMethod::reset()
|
||||||
{
|
{
|
||||||
integrator = 0.0f;
|
integrator = 0.0f;
|
||||||
|
delayCounter = 0.0f;
|
||||||
launchDetected = false;
|
launchDetected = false;
|
||||||
|
delayPassed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,10 +63,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
hrt_abstime last_timestamp;
|
hrt_abstime last_timestamp;
|
||||||
float integrator;
|
float integrator;
|
||||||
|
float delayCounter;
|
||||||
|
|
||||||
bool launchDetected;
|
bool launchDetected;
|
||||||
|
bool delayPassed;
|
||||||
|
|
||||||
control::BlockParamFloat threshold_accel;
|
control::BlockParamFloat threshold_accel;
|
||||||
control::BlockParamFloat threshold_time;
|
control::BlockParamFloat threshold_time;
|
||||||
|
control::BlockParamFloat delay;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,15 @@ PARAM_DEFINE_FLOAT(LAUN_CAT_A, 30.0f);
|
|||||||
*/
|
*/
|
||||||
PARAM_DEFINE_FLOAT(LAUN_CAT_T, 0.05f);
|
PARAM_DEFINE_FLOAT(LAUN_CAT_T, 0.05f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Catapult delay
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @min 0
|
||||||
|
* @group Launch detection
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_FLOAT(LAUN_CAT_DELAY, 0.0f);
|
||||||
/**
|
/**
|
||||||
* Throttle setting while detecting launch.
|
* Throttle setting while detecting launch.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user