Skip to content

Add LiDAR-based wall-following controller - #25

Merged
Aeh961 merged 2 commits into
mainfrom
aeh961/wall-following-controller
Aug 3, 2026
Merged

Add LiDAR-based wall-following controller#25
Aeh961 merged 2 commits into
mainfrom
aeh961/wall-following-controller

Conversation

@Aeh961

@Aeh961 Aeh961 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #6.

Adds a classical PD-style controller that maintains a fixed standoff distance from a configurable wall side using the existing eight-beam LiDAR ring.

No MJCF, sensor, vehicle-physics, or track-geometry changes are included.

How it works

The controller uses two primary signals:

  • distance_error: difference between the measured side distance and the configured target distance
  • wall_skew: difference between the rear-side and front-side beam readings, used to estimate the car's angle relative to the wall

The signals use the same meaning for either wall side. A single directional sign is applied for follow_side="left" or follow_side="right", making the behaviors mirror images.

The controller also:

  • reduces throttle when steering sharply
  • reduces throttle when an obstacle is detected ahead
  • handles invalid, missing, and non-finite LiDAR readings safely
  • clamps steering output
  • supports steering slew-rate limiting
  • exposes reset() for controller state

Changes

  • Added examples/wall_following.py

    • WallFollowingConfig
    • ControlCommand
    • WallFollowingSignals
    • compute_signals()
    • WallFollowingController
  • Updated examples/sensor_logger.py

    • moved reusable LiDAR beam-grouping constants into the module that owns the LiDAR beam order and angles
  • Updated examples/track_centering.py

    • imports the shared beam constants from sensor_logger.py
    • no controller behavior changed
  • Added validation/test_wall_following.py

    • 13 focused tests

Test coverage

The tests cover:

  • left-side and right-side mirror behavior
  • too-close and too-far corrections
  • neutral behavior at the target distance
  • wall-angle correction
  • obstacle-based throttle reduction
  • sharp-steering throttle reduction
  • missing and non-finite reading fallback
  • no-hit LiDAR handling
  • steering clamping
  • slew-rate limiting
  • controller reset
  • one physics integration test using straight_corridor.xml

Validation

  • pytest validation/test_wall_following.py: 13/13 passed
  • pytest validation/: 47/47 passed
  • Ruff check and format check pass on the new files

The full-repository Ruff command continues to report the same pre-existing errors caused by the repository's Ruff version drift. This branch does not introduce additional Ruff violations.

Limitations

  • The default gains are reasonable starting values and may require additional tuning for other tracks or driving speeds.
  • The followed wall side is fixed through configuration and does not automatically switch if the wall disappears.
  • End-to-end physics validation currently covers the straight corridor; curved-track behavior is covered through the controller's pure signal and steering tests.

@Aeh961
Aeh961 merged commit 0e2b80a into main Aug 3, 2026
1 check passed
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.

Write a controller that performs wall following

2 participants