feat(perception): lane/path edge detector (Issue #339) #341

Merged
sl-jetson merged 1 commits from sl-perception/issue-339-path-edges into main 2026-03-03 12:41:24 -05:00
Collaborator

Summary

Implements Canny + Hough + bird-eye perspective pipeline for lane/path edge detection from the forward camera.

New files

  • saltybot_scene_msgs/msg/PathEdges.msg — flat float32[] segment arrays + dominant left/right edge fields in both ROI and bird-eye frames
  • saltybot_bringup/_path_edges.py — pure-Python helper: PathEdgeConfig, PathEdgesResult, build_homography, apply_homography, canny_edges, hough_lines, classify_lines, average_line, warp_segments, process_frame
  • saltybot_bringup/path_edges_node.py — ROS2 node subscribing /camera/color/image_raw, publishing /saltybot/path_edges
  • test/test_path_edges.py — 38 tests, 38 passing

Modified files

  • saltybot_scene_msgs/CMakeLists.txt — register PathEdges.msg
  • saltybot_bringup/setup.py — add path_edges console script

Algorithm

  1. Crop bottom roi_frac (default 50%) of frame as ROI
  2. Grayscale → Gaussian blur → Canny edges
  3. Probabilistic Hough transform → line segments in ROI coords
  4. Classify by slope: negative → left edge, positive → right edge, |slope| < 0.3 → discard
  5. Average each class into one dominant edge, extrapolated to full ROI height
  6. Apply bird-eye perspective homography to all segments
  7. Publish PathEdges with all data

Test plan

  • build_homography shape, dtype, known corner mappings
  • apply_homography empty input, single-point roundtrip, batch
  • canny_edges shape, dtype, uniform → no edges, strong edge detected
  • hough_lines empty map → [], returns float tuples
  • classify_lines negative/positive/near-horizontal/vertical/mixed
  • average_line empty → None, single, two parallel, vertical-only
  • warp_segments empty, single, endpoint distinctness, batch count
  • process_frame smoke, roi_top, uniform, H shape, birdseye count, lane detection, segment arrays

Closes #339

🤖 Generated with Claude Code

## Summary Implements Canny + Hough + bird-eye perspective pipeline for lane/path edge detection from the forward camera. ### New files - `saltybot_scene_msgs/msg/PathEdges.msg` — flat `float32[]` segment arrays + dominant left/right edge fields in both ROI and bird-eye frames - `saltybot_bringup/_path_edges.py` — pure-Python helper: `PathEdgeConfig`, `PathEdgesResult`, `build_homography`, `apply_homography`, `canny_edges`, `hough_lines`, `classify_lines`, `average_line`, `warp_segments`, `process_frame` - `saltybot_bringup/path_edges_node.py` — ROS2 node subscribing `/camera/color/image_raw`, publishing `/saltybot/path_edges` - `test/test_path_edges.py` — 38 tests, 38 passing ### Modified files - `saltybot_scene_msgs/CMakeLists.txt` — register `PathEdges.msg` - `saltybot_bringup/setup.py` — add `path_edges` console script ## Algorithm 1. Crop bottom `roi_frac` (default 50%) of frame as ROI 2. Grayscale → Gaussian blur → Canny edges 3. Probabilistic Hough transform → line segments in ROI coords 4. Classify by slope: negative → left edge, positive → right edge, |slope| < 0.3 → discard 5. Average each class into one dominant edge, extrapolated to full ROI height 6. Apply bird-eye perspective homography to all segments 7. Publish `PathEdges` with all data ## Test plan - [x] `build_homography` shape, dtype, known corner mappings - [x] `apply_homography` empty input, single-point roundtrip, batch - [x] `canny_edges` shape, dtype, uniform → no edges, strong edge detected - [x] `hough_lines` empty map → [], returns float tuples - [x] `classify_lines` negative/positive/near-horizontal/vertical/mixed - [x] `average_line` empty → None, single, two parallel, vertical-only - [x] `warp_segments` empty, single, endpoint distinctness, batch count - [x] `process_frame` smoke, roi_top, uniform, H shape, birdseye count, lane detection, segment arrays Closes #339 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sl-perception added 1 commit 2026-03-03 11:33:52 -05:00
Adds Canny+Hough+bird-eye perspective pipeline for detecting left/right
path edges from the forward camera.  Pure-Python helper (_path_edges.py)
is fully tested; ROS2 node publishes PathEdges on /saltybot/path_edges.

- saltybot_scene_msgs/msg/PathEdges.msg — new message
- saltybot_scene_msgs/CMakeLists.txt    — register PathEdges.msg
- saltybot_bringup/_path_edges.py       — PathEdgeConfig, PathEdgesResult,
                                          build/apply_homography, canny_edges,
                                          hough_lines, classify_lines,
                                          average_line, warp_segments,
                                          process_frame
- saltybot_bringup/path_edges_node.py  — ROS2 node (sensor_msgs/Image →
                                          PathEdges, parameters for all
                                          tunable Canny/Hough/birdseye params)
- test/test_path_edges.py              — 38 tests, 38 passing
- setup.py                             — add path_edges console_script

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson merged commit a7d9531537 into main 2026-03-03 12:41:24 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#341
No description provided.