Skip to content
Merged
8 changes: 8 additions & 0 deletions controller/src/controller/scene_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,14 @@ def handleMovingObjectMessage(self, client, userdata, message):
log.error("UNKNOWN SENDER", sender_id)
return
scene = sender

# If no detection types in the message, add empty arrays for all tracked types
# This must be done BEFORE processCameraData so the tracker processes them
if not detection_types:
detection_types = list(scene.tracker.trackers.keys())
for dtype in detection_types:
Comment on lines +411 to +412
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable detection_types is reassigned from an empty list to a populated list, but this reassignment only affects the local scope. If detection_types is used elsewhere in the function after this block, the reassignment could lead to unexpected behavior. Consider using a different variable name (e.g., tracked_types) for the list of tracker keys to avoid confusion and maintain clarity about which detection types are being referenced.

Suggested change
detection_types = list(scene.tracker.trackers.keys())
for dtype in detection_types:
tracked_types = list(scene.tracker.trackers.keys())
for dtype in tracked_types:

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing it this way would be confusing. detection_types can be (line 400) a reference to the dictionary keys, not a copy. Modifying jdata (referenced keys) will also modify detection_types because it's a dictionary view.

The explicit reassignment makes this side effect visible without requiring readers to understand dictionary view semantics.

jdata['objects'][dtype] = []

success = scene.processCameraData(jdata, when=msg_when)

if not success:
Expand Down
Loading