Skip to content

Comments

Fixes #20716#32262

Open
shashwatvoa wants to merge 1 commit intoArduPilot:masterfrom
shashwatvoa:fix/smartrtl-circle-mode-buffer-full
Open

Fixes #20716#32262
shashwatvoa wants to merge 1 commit intoArduPilot:masterfrom
shashwatvoa:fix/smartrtl-circle-mode-buffer-full

Conversation

@shashwatvoa
Copy link

@shashwatvoa shashwatvoa commented Feb 22, 2026

Problem:

In Circle mode, SmartRTL deactivates because the path buffer fills faster than pruning can remove circular loops.

Changes:

Removed invalid SMARTRTL_SIMPLIFY_EPSILON macro and replaced it with _accuracy * 0.5f directly in detect_simplifications()

Proactively remove detected loops in routine_cleanup() when buffer space is low

Reset path_points_completed in restart_pruning() to rescan the full path for new loops

Testing:

Verified in SITL: Loiter → Arm → Takeoff → Circle → sim_speedup 100
SmartRTL stays active during circular flight.

Fixes #20716

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should re-enable SMART_RTL_Repeat

const uint16_t points_to_simplify = (path_points_count > _simplify.path_points_completed) ? (path_points_count - _simplify.path_points_completed) : 0 ;
const bool low_on_space = (_path_points_max - path_points_count) <= SMARTRTL_CLEANUP_START_MARGIN;

if(_prune.loops_count > 0 && low_on_space){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(_prune.loops_count > 0 && low_on_space){
if(_prune.loops_count > 0 && low_on_space) {

// To avoid this annoying math, a good-enough overestimate is ceil(SMARTRTL_POINTS_MAX*2.0f/3.0f)
#define SMARTRTL_SIMPLIFY_TIME_US 200 // maximum time (in microseconds) the simplification algorithm will run before returning
#define SMARTRTL_PRUNING_DELTA (_accuracy * 0.99) // How many meters apart must two points be, such that we can assume that there is no obstacle between them. must be smaller than _ACCURACY parameter
#define SMARTRTL_PRUNING_DELTA (SMARTRTL_ACCURACY_DEFAULT * 0.5) // How many meters apart must two points be, such that we can assume that there is no obstacle between them. must be smaller than _ACCURACY parameter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? You're decoupling the pruning delta from the parameter which doesn't seem right.

_prune.i = (path_points_count > 0) ? path_points_count - 1 : 0;
_prune.j = 0;
_prune.path_points_count = path_points_count;
_prune.path_points_completed = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this important?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AP_SmartRTL algorithm breaks on Circle mode

2 participants