Skip to content

Edit#2

Closed
anviren wants to merge 2 commits intomasterfrom
edit
Closed

Edit#2
anviren wants to merge 2 commits intomasterfrom
edit

Conversation

@anviren
Copy link
Owner

@anviren anviren commented Jan 7, 2026

Reference issue

What does this implement/fix?

Additional information

CheckList

  • Did you add an unittest for your new example or defect fix?
  • Did you add documents for your new example?
  • All CIs are green? (You can check it after submitting)

Added caching for matrices and integration results, improved initial state computation with recursive functions, and enhanced convergence conditions with adaptive weight updates.
Enhanced obstacle navigation with adaptive heuristic optimization and added experimental path optimization features.
@revieko-architecture-drift-radar
Copy link

revieko-architecture-drift-radar bot commented Jan 7, 2026

Revieko — PR review

  • Status: High risk
  • Structural risk: 83.35 / 100
  • Hotspots: 15
  • CI status: Warn
  • Control risk: Low
  • Analysis: partial

Analysis coverage: 32/100 diff hunks (partial). Some hotspots may be missing.

Analysis details
  • hunks_analyzed=32, max_hunks=100
  • lines_analyzed=1356, max_diff_lines=10000
  • hunks_skipped_token_limit=0
  • parse_fallback_segments=21

Legend: Structural risk is a 0–100 score (higher = riskier). Signal kinds are explained in the HTML full report (Glossary).

Per-file structural risk:

  • AerialNavigation/rocket_powered_landing/rocket_powered_landing.py83.35 (Require)
  • ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py74.45 (Require)
Risk policy (how to interpret 0–100)
  • 70–100: Require refactoring / split PR before merge
  • 40–69: Discuss in review (justify complexity, add tests/docs)
  • 0–39: Acceptable (monitor)

These are guidelines. Always consider change context and PR scope.

Top hotspots:

  • ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py:381-381struct_pattern_break (score=2.0060)
  • ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py:268-268struct_pattern_break (score=1.9458)
  • ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py:372-372depth_spike (score=1.9458)

Full report: HTML · Markdown · JSON
— Generated by Revieko · Install GitHub App · Documentation

Link details
  • Expires at UTC: 2026-02-02 13:43:42Z
  • Remaining: 168h from now

@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 24, 2026
@anviren anviren reopened this Jan 24, 2026
@anviren anviren closed this Jan 25, 2026
@anviren anviren reopened this Jan 25, 2026
@anviren anviren closed this Jan 25, 2026
@anviren anviren reopened this Jan 25, 2026
@anviren anviren closed this Jan 25, 2026
@anviren anviren reopened this Jan 25, 2026
@anviren anviren closed this Jan 26, 2026
@anviren anviren reopened this Jan 26, 2026
@anviren anviren closed this Feb 12, 2026
@anviren anviren reopened this Feb 12, 2026
delta_norm < 1e-3 and
sigma_norm < 1e-3 and
nu_norm < 1e-7 and
(it > 5 or (delta_norm < 5e-3 and all(m.delta_norm < 1e-2 for m in metrics_history[-3:])))

Check warning

Code scanning / CodeQL

Redundant comparison Warning

Test is always true, because of
this condition
.

Copilot Autofix

AI 23 days ago

In general, to fix this kind of problem, you should remove or refactor any comparison whose truth value is fully determined by earlier conditions in the same logical expression. If two inequalities on the same value appear in a conjunction, keep the strongest one (tightest bound) unless you truly need a different quantity (e.g., a past value or a different metric).

Here, the first part of convergence_condition is:

convergence_condition = (
    delta_norm < 1e-3 and 
    sigma_norm < 1e-3 and 
    nu_norm < 1e-7 and
    (it > 5 or (delta_norm < 5e-3 and all(m.delta_norm < 1e-2 for m in metrics_history[-3:])))
)

Inside this block, delta_norm < 5e-3 is redundant because delta_norm < 1e-3 is already required. The cleanest fix that preserves semantics is to drop the weaker redundant comparison and keep the history-based check, i.e. change the inner or group from:

(it > 5 or (delta_norm < 5e-3 and all(m.delta_norm < 1e-2 for m in metrics_history[-3:])))

to:

(it > 5 or all(m.delta_norm < 1e-2 for m in metrics_history[-3:]))

This keeps the idea “either we’re past 5 iterations, or the last few iterations’ delta_norm are small,” without duplicating a constraint that is already enforced. No additional imports or definitions are needed; the only edit is to the line containing delta_norm < 5e-3 in AerialNavigation/rocket_powered_landing/rocket_powered_landing.py.

Suggested changeset 1
AerialNavigation/rocket_powered_landing/rocket_powered_landing.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/AerialNavigation/rocket_powered_landing/rocket_powered_landing.py b/AerialNavigation/rocket_powered_landing/rocket_powered_landing.py
--- a/AerialNavigation/rocket_powered_landing/rocket_powered_landing.py
+++ b/AerialNavigation/rocket_powered_landing/rocket_powered_landing.py
@@ -942,7 +942,7 @@
             delta_norm < 1e-3 and 
             sigma_norm < 1e-3 and 
             nu_norm < 1e-7 and
-            (it > 5 or (delta_norm < 5e-3 and all(m.delta_norm < 1e-2 for m in metrics_history[-3:])))
+            (it > 5 or all(m.delta_norm < 1e-2 for m in metrics_history[-3:]))
         ) or (
             it > 15 and 
             np.std([m.delta_norm for m in metrics_history[-5:]]) < 1e-4 and
EOF
@@ -942,7 +942,7 @@
delta_norm < 1e-3 and
sigma_norm < 1e-3 and
nu_norm < 1e-7 and
(it > 5 or (delta_norm < 5e-3 and all(m.delta_norm < 1e-2 for m in metrics_history[-3:])))
(it > 5 or all(m.delta_norm < 1e-2 for m in metrics_history[-3:]))
) or (
it > 15 and
np.std([m.delta_norm for m in metrics_history[-5:]]) < 1e-4 and
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +175 to +176
dist_to_center = sqrt((point[0]/M*4 - obstacle[0])**2 +
(point[1]/M*4 - obstacle[1])**2)

Check warning

Code scanning / CodeQL

Pythagorean calculation with sub-optimal numerics Warning

Pythagorean calculation with sub-optimal numerics.

Copilot Autofix

AI 23 days ago

In general, to fix this class of problem, replace manual distance computations of the form sqrt(dx*dx + dy*dy) or sqrt(dx**2 + dy**2) with math.hypot(dx, dy), which is implemented to avoid unnecessary overflow and precision loss.

For this file, the best fix is:

  1. Import hypot from math alongside the existing sqrt import at the top of ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py.

  2. In generate_start_goal_with_constraints.is_valid_point.check_obstacles_recursive, replace:

    dist_to_center = sqrt((point[0]/M*4 - obstacle[0])**2 + 
                          (point[1]/M*4 - obstacle[1])**2)

    with:

    dx = point[0] / M * 4 - obstacle[0]
    dy = point[1] / M * 4 - obstacle[1]
    dist_to_center = hypot(dx, dy)

    or a one‑liner dist_to_center = hypot(point[0]/M*4 - obstacle[0], point[1]/M*4 - obstacle[1]). Both avoid the explicit squaring and directly leverage hypot. This preserves the functional behavior while improving numerical robustness.

No other parts of the file need to change.

Suggested changeset 1
ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
--- a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
+++ b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
@@ -4,7 +4,7 @@
 Author: Daniel Ingram (daniel-s-ingram)
 Modified: Added experimental path optimization features
 """
-from math import pi, sqrt, cos, sin
+from math import pi, sqrt, cos, sin, hypot
 import numpy as np
 import matplotlib.pyplot as plt
 from matplotlib.colors import from_levels_and_colors
@@ -172,8 +172,8 @@
             
             # Упрощенная проверка (не настоящая коллизия, для примера)
             obstacle = obstacles[obs_idx]
-            dist_to_center = sqrt((point[0]/M*4 - obstacle[0])**2 + 
-                                 (point[1]/M*4 - obstacle[1])**2)
+            dist_to_center = hypot(point[0]/M*4 - obstacle[0],
+                                   point[1]/M*4 - obstacle[1])
             if dist_to_center < obstacle[2] * 1.5 and avoid_obstacles:
                 return False
             return check_obstacles_recursive(obs_idx + 1)
EOF
@@ -4,7 +4,7 @@
Author: Daniel Ingram (daniel-s-ingram)
Modified: Added experimental path optimization features
"""
from math import pi, sqrt, cos, sin
from math import pi, sqrt, cos, sin, hypot
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import from_levels_and_colors
@@ -172,8 +172,8 @@

# Упрощенная проверка (не настоящая коллизия, для примера)
obstacle = obstacles[obs_idx]
dist_to_center = sqrt((point[0]/M*4 - obstacle[0])**2 +
(point[1]/M*4 - obstacle[1])**2)
dist_to_center = hypot(point[0]/M*4 - obstacle[0],
point[1]/M*4 - obstacle[1])
if dist_to_center < obstacle[2] * 1.5 and avoid_obstacles:
return False
return check_obstacles_recursive(obs_idx + 1)
Copilot is powered by AI and may make mistakes. Always verify output.
print('='*60)

# Временно меняем глобальные настройки
global _cache_enabled

Check warning

Code scanning / CodeQL

Use of 'global' at module level Warning

Declaring '_cache_enabled' as global at module-level is redundant.

Copilot Autofix

AI 23 days ago

In general, to fix “Use of 'global' at module level” issues, you remove global declarations that occur outside of any function or method body, because at module level the local scope is already the global scope. The assignments will continue to target the module namespace without the global keyword.

For this specific case in ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py, the best fix is to delete the global _cache_enabled line inside the if __name__ == '__main__': block, leaving the subsequent assignment _cache_enabled = (mode != PathOptimizationMode.NONE) unchanged. No imports or other code changes are needed; this preserves all existing functionality because _cache_enabled is still bound in the module’s global namespace when assigned there. Only the redundant declaration is removed.

Concretely:

  • Edit ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py.
  • Locate the if __name__ == '__main__': block at the bottom.
  • Remove line 775: global _cache_enabled.
  • Leave lines 769–777 and the rest of the file unchanged.
Suggested changeset 1
ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
--- a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
+++ b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
@@ -772,7 +772,6 @@
         print('='*60)
         
         # Временно меняем глобальные настройки
-        global _cache_enabled
         _cache_enabled = (mode != PathOptimizationMode.NONE)
         
         # Запускаем main с текущим режимом
EOF
@@ -772,7 +772,6 @@
print('='*60)

# Временно меняем глобальные настройки
global _cache_enabled
_cache_enabled = (mode != PathOptimizationMode.NONE)

# Запускаем main с текущим режимом
Copilot is powered by AI and may make mistakes. Always verify output.
from scipy.integrate import odeint, solve_ivp
import cvxpy
import matplotlib.pyplot as plt
from functools import lru_cache, wraps

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'lru_cache' is not used.

Copilot Autofix

AI 23 days ago

To fix an unused import, the general solution is to remove the specific name from the import statement (or remove the entire import if none of its names are used). This eliminates unnecessary dependencies and slightly reduces module load time and cognitive overhead.

In this file, the problematic line is:

from functools import lru_cache, wraps

Since only lru_cache is reported as unused and there is no indication that wraps is unused, the safest and minimal-change fix is to remove lru_cache from that line while leaving wraps intact. Concretely, in AerialNavigation/rocket_powered_landing/rocket_powered_landing.py around line 20, update the import so it becomes:

from functools import wraps

No new methods, definitions, or additional imports are required; we are only simplifying the existing import.

Suggested changeset 1
AerialNavigation/rocket_powered_landing/rocket_powered_landing.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/AerialNavigation/rocket_powered_landing/rocket_powered_landing.py b/AerialNavigation/rocket_powered_landing/rocket_powered_landing.py
--- a/AerialNavigation/rocket_powered_landing/rocket_powered_landing.py
+++ b/AerialNavigation/rocket_powered_landing/rocket_powered_landing.py
@@ -17,7 +17,7 @@
 from scipy.integrate import odeint, solve_ivp
 import cvxpy
 import matplotlib.pyplot as plt
-from functools import lru_cache, wraps
+from functools import wraps
 from dataclasses import dataclass
 from typing import Optional, Dict, Any, Callable, List, Tuple
 from enum import Enum
EOF
@@ -17,7 +17,7 @@
from scipy.integrate import odeint, solve_ivp
import cvxpy
import matplotlib.pyplot as plt
from functools import lru_cache, wraps
from functools import wraps
from dataclasses import dataclass
from typing import Optional, Dict, Any, Callable, List, Tuple
from enum import Enum
Copilot is powered by AI and may make mistakes. Always verify output.
Modified: Added experimental path optimization features
"""
from math import pi
from math import pi, sqrt, cos, sin

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'cos' is not used.
Import of 'sin' is not used.

Copilot Autofix

AI 23 days ago

In general, unused-import issues are fixed by either (1) removing the unused names from the import statement, or (2) starting to use them if they were mistakenly left unused. To avoid changing functionality, the safest fix here is to keep only the actually used names from the math import and drop cos and sin.

In ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py, adjust the import on line 7 so that it only imports pi and sqrt. Do not change other imports or code, since there is no indication that cos or sin are needed. No additional methods, imports, or definitions are required.

Suggested changeset 1
ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
--- a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
+++ b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
@@ -4,7 +4,7 @@
 Author: Daniel Ingram (daniel-s-ingram)
 Modified: Added experimental path optimization features
 """
-from math import pi, sqrt, cos, sin
+from math import pi, sqrt
 import numpy as np
 import matplotlib.pyplot as plt
 from matplotlib.colors import from_levels_and_colors
EOF
@@ -4,7 +4,7 @@
Author: Daniel Ingram (daniel-s-ingram)
Modified: Added experimental path optimization features
"""
from math import pi, sqrt, cos, sin
from math import pi, sqrt
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import from_levels_and_colors
Copilot is powered by AI and may make mistakes. Always verify output.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import from_levels_and_colors
from functools import lru_cache, wraps

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'lru_cache' is not used.

Copilot Autofix

AI 23 days ago

In general, unused-import issues are fixed by removing the unused symbol from the import, or removing the entire import line if nothing from it is used. This reduces unnecessary dependencies and slightly improves readability and startup time.

Here, wraps is used in the timing_decorator definition (@wraps(func)), but lru_cache is never referenced. The minimal, behavior-preserving fix is to remove lru_cache from the functools import while leaving wraps intact.

Concretely, in ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py, at line 11, change:

from functools import lru_cache, wraps

to:

from functools import wraps

No additional methods, imports, or definitions are required.

Suggested changeset 1
ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
--- a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
+++ b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
@@ -8,7 +8,7 @@
 import numpy as np
 import matplotlib.pyplot as plt
 from matplotlib.colors import from_levels_and_colors
-from functools import lru_cache, wraps
+from functools import wraps
 from dataclasses import dataclass
 from typing import List, Tuple, Optional, Dict, Any, Callable
 from enum import Enum
EOF
@@ -8,7 +8,7 @@
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import from_levels_and_colors
from functools import lru_cache, wraps
from functools import wraps
from dataclasses import dataclass
from typing import List, Tuple, Optional, Dict, Any, Callable
from enum import Enum
Copilot is powered by AI and may make mistakes. Always verify output.
from matplotlib.colors import from_levels_and_colors
from functools import lru_cache, wraps
from dataclasses import dataclass
from typing import List, Tuple, Optional, Dict, Any, Callable

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'List' is not used.
Import of 'Optional' is not used.
Import of 'Any' is not used.

Copilot Autofix

AI 23 days ago

To fix the problem, remove the unused types (List, Optional, Any) from the typing import while preserving the used ones (Tuple, Dict, Callable). This eliminates the unnecessary imported names without affecting functionality or type checking.

Concretely, in ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py, at the top of the file where typing is imported, change:

from typing import List, Tuple, Optional, Dict, Any, Callable

to:

from typing import Tuple, Dict, Callable

No other code changes or new definitions are required.

Suggested changeset 1
ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
--- a/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
+++ b/ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py
@@ -10,7 +10,7 @@
 from matplotlib.colors import from_levels_and_colors
 from functools import lru_cache, wraps
 from dataclasses import dataclass
-from typing import List, Tuple, Optional, Dict, Any, Callable
+from typing import Tuple, Dict, Callable
 from enum import Enum
 import random
 from time import perf_counter_ns
EOF
@@ -10,7 +10,7 @@
from matplotlib.colors import from_levels_and_colors
from functools import lru_cache, wraps
from dataclasses import dataclass
from typing import List, Tuple, Optional, Dict, Any, Callable
from typing import Tuple, Dict, Callable
from enum import Enum
import random
from time import perf_counter_ns
Copilot is powered by AI and may make mistakes. Always verify output.
@anviren anviren closed this Feb 12, 2026
@anviren anviren reopened this Feb 12, 2026
@anviren anviren closed this Feb 12, 2026
@anviren anviren reopened this Feb 12, 2026
@anviren anviren closed this Feb 12, 2026
@anviren anviren reopened this Feb 12, 2026
@anviren anviren closed this Feb 12, 2026
@anviren anviren reopened this Feb 12, 2026
@anviren anviren closed this Feb 12, 2026
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.

1 participant