mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-17 13:25:27 +03:00
Update navigation_fixedwing.c
This commit is contained in:
parent
1b3013b570
commit
235e4d90c3
1 changed files with 22 additions and 23 deletions
|
@ -396,18 +396,18 @@ static void updatePositionHeadingController_FW(timeUs_t currentTimeUs, timeDelta
|
|||
|
||||
/* If waypoint tracking enabled quickly force craft toward waypoint course line and closely track along it */
|
||||
if (navConfig()->fw.wp_tracking_accuracy && isWaypointNavTrackingActive() && !needToCalculateCircularLoiter) {
|
||||
// apply course tracking correction if target bearing error < 90 degs or when close to waypoint (within 10m)
|
||||
if (ABS(wrap_18000(virtualTargetBearing - posControl.actualState.yaw)) < 9000 || posControl.wpDistance < 1000.0f) {
|
||||
// courseVirtualCorrection initially used to determine current position relative to course line for later use
|
||||
int32_t courseVirtualCorrection = wrap_18000(posControl.activeWaypoint.yaw - virtualTargetBearing);
|
||||
float distToCourseLine = ABS(posControl.wpDistance * sin_approx(CENTIDEGREES_TO_RADIANS(courseVirtualCorrection)));
|
||||
|
||||
// tracking only active when target bearing error < 90 degs, close to waypoint (within 10m) and > 2m from course line
|
||||
if ((ABS(wrap_18000(virtualTargetBearing - posControl.actualState.yaw)) < 9000 || posControl.wpDistance < 1000.0f) && distToCourseLine > 200) {
|
||||
int32_t courseHeadingError = wrap_18000(posControl.activeWaypoint.yaw - posControl.actualState.yaw);
|
||||
|
||||
// only apply tracking correction when > 2m from waypoint course line
|
||||
if (distToCourseLine > 200) {
|
||||
// captureFactor adjusts distance/heading sensitivity balance when approaching course line.
|
||||
// approach distance threashold based on speed and an assumed 1 second response time.
|
||||
// Approach distance threashold based on speed and an assumed 1 second response time.
|
||||
float captureFactor = distToCourseLine < posControl.actualState.velXY ? constrainf(2.0f - ABS(courseHeadingError) / 500.0f, 0.0f, 2.0f) : 1.0f;
|
||||
|
||||
// bias between reducing distance to course line and aligning with course heading adjusted by waypoint_tracking_accuracy
|
||||
// initial courseCorrectionFactor based on distance to course line
|
||||
float courseCorrectionFactor = constrainf(captureFactor * distToCourseLine / (1000.0f * navConfig()->fw.wp_tracking_accuracy), 0.0f, 1.0f);
|
||||
|
@ -420,12 +420,11 @@ static void updatePositionHeadingController_FW(timeUs_t currentTimeUs, timeDelta
|
|||
// final courseCorrectionFactor combining distance and heading factors
|
||||
courseCorrectionFactor = constrainf(courseCorrectionFactor - courseHeadingFactor, -1.0f, 1.0f);
|
||||
|
||||
// final courseVirtualCorrection using max 80 deg heading adjustment toward course line
|
||||
// final courseVirtualCorrection value
|
||||
courseVirtualCorrection = DEGREES_TO_CENTIDEGREES(navConfig()->fw.wp_tracking_max_angle) * courseCorrectionFactor;
|
||||
virtualTargetBearing = wrap_36000(posControl.activeWaypoint.yaw - courseVirtualCorrection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate NAV heading error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue