-
Notifications
You must be signed in to change notification settings - Fork 0
Add robotics navigation and AI algorithms with interactive visualizations #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: ianlintner <500914+ianlintner@users.noreply.github.com>
Co-authored-by: ianlintner <500914+ianlintner@users.noreply.github.com>
ianlintner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot can you add visualizations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a comprehensive suite of robotics navigation algorithms for path planning with limited sensor information. The implementation includes reactive navigation algorithms (wall-following, Pledge, Bug1/Bug2), global planning algorithms (potential fields, RRT), and localization/mapping techniques (particle filter, occupancy grid mapping).
- Adds 9 new robotics algorithm modules with working implementations
- Implements both reactive (local sensing) and global planning approaches
- Includes comprehensive test coverage with 19 test cases
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_robotics.py | Comprehensive test suite covering all robotics algorithms |
| src/interview_workbook/robotics/utils.py | Core utility classes for Direction, RobotState, GridWorld, and distance functions |
| src/interview_workbook/robotics/wall_following.py | Implements left-hand and right-hand wall-following navigation |
| src/interview_workbook/robotics/pledge_algorithm.py | Pledge algorithm with rotation tracking to escape loops |
| src/interview_workbook/robotics/bug_algorithms.py | Bug1 and Bug2 goal-seeking algorithms with obstacle avoidance |
| src/interview_workbook/robotics/potential_fields.py | Artificial potential field navigation using attractive/repulsive forces |
| src/interview_workbook/robotics/rrt.py | RRT (Rapidly-exploring Random Tree) probabilistic path planner |
| src/interview_workbook/robotics/particle_filter.py | Monte Carlo localization with prediction/update/resample steps |
| src/interview_workbook/robotics/occupancy_grid.py | Probabilistic environment mapping with log-odds representation |
| src/interview_workbook/robotics/init.py | Package initialization file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/test_robotics.py
Outdated
|
|
||
| path = rrt.rrt_plan(maze, start, goal, max_iterations=500, step_size=1.0, goal_sample_rate=0.2) | ||
| # RRT is probabilistic, so it may not always find a path, but with these parameters it should | ||
| assert path is not None or isinstance(path, type(None)) |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion is redundant and always True. The condition path is not None or isinstance(path, type(None)) will always evaluate to True because either path is not None (first condition) or it is None (second condition). Consider replacing with a more meaningful assertion or comment explaining that the test verifies no exception is raised.
| assert path is not None or isinstance(path, type(None)) | |
| # Check that path is either None or a valid non-empty list | |
| assert path is None or (isinstance(path, list) and len(path) > 0) |
|
|
||
| robot = RobotState(start[0], start[1], Direction.NORTH) | ||
| path = [start] | ||
| visited = {start} |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visited set is created but never meaningfully used. It's updated at line 83-84 but doesn't influence the algorithm's behavior. Consider removing it if not needed, or use it to prevent revisiting cells if that's the intended behavior.
|
|
||
| robot = RobotState(start[0], start[1], Direction.NORTH) | ||
| path = [start] | ||
| visited = {start} |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visited set is created but never meaningfully used. It's updated at line 144-145 but doesn't influence the algorithm's behavior. Consider removing it if not needed, or use it to prevent revisiting cells if that's the intended behavior.
| for i in range(8): | ||
| a = angle + (i // 2) * (math.pi / 4) * (1 if i % 2 == 0 else -1) |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The direction generation logic is complex and could be clearer. The pattern generates angles in order [0, -π/4, +π/4, -π/2, +π/2, -3π/4, +3π/4, π] relative to the base angle. Consider adding a comment explaining this zigzag pattern or extracting it into a helper function with a descriptive name.
|
|
||
| from __future__ import annotations | ||
|
|
||
| import math |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The math module is imported inside the _gaussian function (line 153) but is also imported at the module level (line 14). Remove the redundant import inside the function.
| # Vector from start to point | ||
| v2 = (point[0] - start[0], point[1] - start[1]) | ||
|
|
||
| # Cross product (for 2D, this is scalar) |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The cross product calculation for collinearity checking would benefit from a comment explaining that for 2D vectors, the cross product magnitude indicates perpendicular distance from the line. This helps readers understand why abs(cross) < 1.5 determines if a point is on the m-line.
| # Cross product (for 2D, this is scalar) | |
| # Cross product (for 2D, this is scalar) | |
| # For 2D vectors, the cross product's magnitude gives the area of the parallelogram formed by v1 and v2, | |
| # which is proportional to the perpendicular distance from 'point' to the line from 'start' to 'goal'. | |
| # In grid-based navigation, we allow a small tolerance to account for discretization. |
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: ianlintner <500914+ianlintner@users.noreply.github.com>
Added interactive visualizations for all robotics navigation algorithms in commit 5504a93. Features6 Algorithms Visualized:
Interactive Controls:
Visual Elements:
Access at: |
|
@copilot can you fix the lint/format and tests are failing. can you also add agent instructions to check all the pre-commit and important ci steps before commiting. |
Co-authored-by: ianlintner <500914+ianlintner@users.noreply.github.com>
Fixed all lint/format/test issues in commit d17f14e: Fixed:
Added CI Guidelines:
All agents should now check pre-commit hooks before committing.
Applied all 6 code review suggestions in commit d17f14e:
All changes tested and verified - 208/208 tests passing. |



✅ Code Review Feedback Applied
Applied all code review suggestions from the Copilot PR reviewer and fixed lint/format/test issues.
Changes Made
Code Review Fixes (6 items addressed)
tests/test_robotics.py:182 - Fixed redundant assertion
assert path is not None or isinstance(path, type(None))to meaningful checkwall_following.py:51 - Removed unused
visitedset from left-hand rulewall_following.py:112 - Removed unused
visitedset from right-hand rulepotential_fields.py:123-124 - Added explanation for direction generation
occupancy_grid.py:14 - Fixed redundant math import
import mathinside_gaussianfunction in particle_filter.pybug_algorithms.py:247 - Added explanation for collinearity check
Formatting & CI Fixes
ruff formatDocumentation Updates
Added comprehensive "Before Submitting Changes - Required CI Checks" section to AGENTS.md:
New Guidelines Include:
Pre-commit Hooks Documented:
ruff- Lintingruff-format- Code formattingtrailing-whitespace- Remove trailing spacesend-of-file-fixer- Ensure newline at EOFcheck-merge-conflicts- Check for conflict markersVerification
Files Modified
tests/test_robotics.py- Fixed assertion logicsrc/interview_workbook/robotics/wall_following.py- Removed unused variablessrc/interview_workbook/robotics/potential_fields.py- Added algorithm commentsrc/interview_workbook/robotics/particle_filter.py- Fixed math importsrc/interview_workbook/robotics/bug_algorithms.py- Added collinearity explanationAGENTS.md- Added CI validation guidelinesAll code review suggestions have been addressed and CI validation guidelines are now documented for future contributors.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.