Skip to content

refactor(autoware_traffic_light_visualization): introduce Bulb struct and tidy internal naming#12553

Open
takam5f2 wants to merge 16 commits intoautowarefoundation:mainfrom
takam5f2:refactor/traffic-light-map-visualizer-introduce-bulb-domain
Open

refactor(autoware_traffic_light_visualization): introduce Bulb struct and tidy internal naming#12553
takam5f2 wants to merge 16 commits intoautowarefoundation:mainfrom
takam5f2:refactor/traffic-light-map-visualizer-introduce-bulb-domain

Conversation

@takam5f2
Copy link
Copy Markdown
Contributor

@takam5f2 takam5f2 commented May 7, 2026

Description

Decouple TrafficLightVisualizer from lanelet types by introducing a small ROS-friendly Bulb { id, position, color } struct, and tidy internal naming. This is the second of a planned series of incremental PRs; #12511 was the first.

Changes:

  • Introduce Bulb and BulbsByGroupId types, and extract extract_bulbs(map_traffic_lights) → BulbsByGroupId as a free function. TrafficLightVisualizer now receives a prebuilt BulbsByGroupId and no longer holds lanelet::ConstPoint3d. Lanelet API knowledge is confined to the conversion layer (extract_bulbs).
  • Extract parse_bulb_color helper to flatten the red/green/yellow lookup.
  • Tidy helper signatures (pass Time by value, hoist using to namespace scope).
  • Internal renames for clarity: viz_lanelet_maplanelet_map, regulatory_elementtraffic_light, traffic_lightsmap_traffic_lights, current_timestamp, plus subscription/publisher member name updates.
  • Scope TrafficLightGroupArray / LaneletMapBin using-declarations to the node class private section so they are not leaked at namespace scope.
  • Drop the noisy "Map is loaded\n" debug log.
  • Update copyright year to 2020-2026.

Behavior is preserved end-to-end; the characterization test from #12487 acts as the safety net.

Related links

Parent Issue:

How was this PR tested?

colcon build --packages-select autoware_traffic_light_visualization \
  --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
colcon test --packages-select autoware_traffic_light_visualization \
  --event-handlers console_direct+

All 5 characterization test cases pass.

Notes for reviewers

This PR is the second of a planned sequence to incrementally refactor traffic_light_map_visualizer:

The plugin name (autoware::traffic_light::TrafficLightMapVisualizerNode) and executable name are preserved.

Interface changes

None.

Effects on system behavior

None.

takam5f2 and others added 13 commits May 7, 2026 15:37
Hoist TrafficLightElement using-declaration to the anonymous namespace
scope and pass the small Time stamp by value in helper functions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ion from marker generation

Introduce a Bulb domain struct and extract_bulbs free function that
walk lanelet primitives once. TrafficLightVisualizer now receives a
prebuilt BulbsByGroupId map and is independent of lanelet attribute
schema, isolating map-format knowledge to a single seam.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…aded" debug log

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…p to lanelet_map

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ment to traffic_light

The variable holds AutowareTrafficLightConstPtr produced by
autowareTrafficLights query, so name it for what it is rather than its
abstract base concept in lanelet2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… to map_traffic_lights in extract_bulbs

Disambiguate from detected_traffic_lights used on the perception side.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… and shorten message types

Add namespace-scope using-aliases for TrafficLightGroupArray and
LaneletMapBin in the internal node header so member declarations and
definitions stay readable, and rename the callback parameter to
detected_traffic_lights to mirror the map_traffic_lights naming on
the lanelet side.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ublisher members for specificity

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…o stamp for consistency

Match the parameter name used by generate_markers().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… 2020-2026

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…color_attribute

Match the codebase convention of expanding abbreviations
(regulatory_element, traffic_light, etc.).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…iases inside the node class

Move the TrafficLightGroupArray and LaneletMapBin using-declarations
from the autoware::traffic_light namespace into the private section of
TrafficLightMapVisualizerNode. The aliases are an internal convenience
for the node's callback signatures and members; exposing them at
namespace scope leaks them to every translation unit including this
header.
@github-actions github-actions Bot added the component:perception Advanced sensor data processing and environment understanding. (auto-assigned) label May 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@takam5f2 takam5f2 changed the title refactor(autoware_traffic_light_visualization): introduce Bulb DTO and tidy internal naming refactor(autoware_traffic_light_visualization): introduce Bulb struct and tidy internal naming May 7, 2026
@takam5f2 takam5f2 added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label May 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 44.68085% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.58%. Comparing base (989ef89) to head (a21529f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
..._light_map_visualizer/traffic_light_visualizer.cpp 52.94% 3 Missing and 13 partials ⚠️
...t_map_visualizer/traffic_light_visualizer_node.cpp 23.07% 0 Missing and 10 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #12553       +/-   ##
===========================================
- Coverage   18.64%   18.58%    -0.06%     
===========================================
  Files        1918        7     -1911     
  Lines      131362      269   -131093     
  Branches    44504       42    -44462     
===========================================
- Hits        24493       50    -24443     
+ Misses      86754      187    -86567     
+ Partials    20115       32    -20083     
Flag Coverage Δ
full-suite 18.58% <44.68%> (-0.06%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

takam5f2 added 2 commits May 7, 2026 19:10
…tate callback and subscriber names

Rename traffic_lights_callback to detected_traffic_lights_callback and
traffic_light_state_sub_ to detected_traffic_lights_sub_ so the
callback, its parameter, and the subscription member all share the
detected_traffic_lights vocabulary. This mirrors the map side
(map_traffic_lights) and the visualizer interface
(generate_markers's detected_traffic_lights argument).
…ck to lanelet_map_callback

Rename bin_map_callback to lanelet_map_callback and its parameter to
lanelet_map_msg so the callback name aligns with the subscriber member
(lanelet_map_sub_) and the local variable (lanelet_map). The "bin"
adjective referred to binary encoding, a transport-level detail that
does not belong in the callback's identifier.
@takam5f2 takam5f2 requested a review from YoshiRi May 7, 2026 10:18
@takam5f2 takam5f2 self-assigned this May 7, 2026
@takam5f2
Copy link
Copy Markdown
Contributor Author

takam5f2 commented May 7, 2026

@YoshiRi @a-maumau

Sorry to bother you, but could you please review this PR when you have a chance?

This PR moves the lanelet-specific extraction behind a free function extract_bulbs so that TrafficLightVisualizer only depends on the Bulb struct (id, position, color); the marker-generation logic no longer touches the lanelet API.

This is part of a planned series following #12511 (merged); follow-ups will cover the test layer. Behavior is preserved across all PRs and is anchored by the characterization test introduced in #12487.

@takam5f2 takam5f2 marked this pull request as ready for review May 7, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:perception Advanced sensor data processing and environment understanding. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

1 participant