Skip to content

fix: ensure all spawned actors are destroyed on shutdown (closes #698)#764

Open
redddddyyyyy wants to merge 1 commit into
carla-simulator:masterfrom
redddddyyyyy:fix/698-incomplete-actor-cleanup
Open

fix: ensure all spawned actors are destroyed on shutdown (closes #698)#764
redddddyyyyy wants to merge 1 commit into
carla-simulator:masterfrom
redddddyyyyy:fix/698-incomplete-actor-cleanup

Conversation

@redddddyyyyy

@redddddyyyyy redddddyyyyy commented Apr 16, 2026

Copy link
Copy Markdown

Problem

Fixes #698

When pressing Ctrl+C, the ROS node exits but spawned CARLA actors (vehicles, sensors) remain alive in the simulator. The root cause is that the destroy loops in carla_spawn_objects.py wrap all actors in a single try-except — any one exception exits the entire loop, leaving remaining actors alive. The same pattern exists in bridge.py and actor_factory.py with no exception handling at all.

Fix

Wrap each individual actor destruction call in its own try-except block across three files:

  • carla_spawn_objects/src/carla_spawn_objects/carla_spawn_objects.py: per-actor try-except in destroy()
  • carla_ros_bridge/src/carla_ros_bridge/bridge.py: per-actor try-except in destroy()
  • carla_ros_bridge/src/carla_ros_bridge/actor_factory.py: per-actor try-except in clear()

Failed destructions are logged as warnings but do not abort cleanup of remaining actors. Lists are copied before iteration to prevent mutation issues during teardown.

Testing

The fix has been verified by code review. The change is mechanical — moving exception handling from wrapping entire loops to wrapping individual iterations — and the logic is straightforward to confirm by reading.


This change is Reviewable

…lator#698)

Wrap each actor destruction call in its own try-except block so a
single failure does not abort cleanup of remaining actors. Failures
are logged as warnings. Lists are copied before iteration to prevent
mutation issues during teardown.
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.

Shutting down node using Ctrl+C, doesnt completely destroy all the spawned objects

1 participant