Python API mode: AsyncMode False does not give deterministic synchronous stepping
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- autonomous-driving
Research direction
Start by tracing synchronous-mode handling and world ticking in utils/traffic.py, pilot_carla.py, and utils/carla_world_generator.py, then inspect how CarlaApiCamera receives and returns frames. Reproduce with AsyncMode: False and compare time_stamp and frame in the metrics CSV. Done means each brain decision advances one fixed step and receives that tick's camera image; the issue asks for design agreement before a PR.
Written by the indexing model from the issue text.
Description
Expected behavior
With AsyncMode: False, the simulation should advance exactly one fixed step per brain decision (e.g. fixed_delta_seconds = 0.05), and the brain should receive the camera image of that same tick. This is how models are usually evaluated with the CARLA Python API, and it makes runs repeatable.
Actual behavior
utils/traffic.pyenablessynchronous_modebut never setsfixed_delta_seconds, so the simulated time per tick is variable.- Two processes tick the world:
pilot_carla.pyafter eachexecute(), andutils/carla_world_generator.pyin its own 60 Hz loop. The simulation advances several ticks per decision. CarlaApiCamerakeeps only the last image received by callback, so the brain may see an older frame.
Steps to reproduce
Run a config with AsyncMode: False and inspect the metrics CSV: time_stamp steps and frame increments are not constant per brain decision.
Environment
Kubuntu 26.04.1 (Ubuntu base, X11 session), kernel 7.0, Intel i9-12900K, 32 GB RAM, NVIDIA RTX 5070 12 GB (driver 580.178.04), Python 3.10, CARLA 0.9.15 in Docker, Behavior Metrics noetic-devel (dec1502), Python API mode.
Possible cause
See the three points above. PR #719 addressed asynchrony issues but not these. The branch feature/carla-python-api-metrics changes pilot_carla.py and carla_world_generator.py but keeps the generator ticking, and its brain assumes SimHz: 20 without enforcing it.
Possible solution
A FixedDelta key in the YAML applied with synchronous_mode; only the pilot ticks (the world generator stops ticking in synchronous mode); and the camera returns the image of the current frame (queue keyed by frame number).
I validated this approach inside a brain: with it, every row of the metrics CSV advances exactly 0.05 s and one frame, and a PilotNet model behaves as in a standalone synchronous driver (428 m driven in Town02 before failing at a sharp curve, versus crashing almost immediately in asynchronous mode).
Before writing the PR I would like to agree on the design, and on whether to base it on noetic-devel or on feature/carla-python-api-metrics.
Related: #742 (external CARLA server), #744 (weather from YAML).
cc @canveo (author of #719) Daniel Guerrero (author of feature/carla-python-api-metrics)
- Dominant language
- Python
- Stars
- 65
- Forks
- 53
- Avg merge
- 7m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JdeRobot/BehaviorMetrics
-
Python API mode: lane keeping and steering stability metrics (right lane percentage, steering zero crossings)Possibly taken @amateusr claimed this 20 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
JdeRobot/BehaviorMetrics#746 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
JdeRobot/BehaviorMetrics#744 ·
-
Python API mode: allow using an external CARLA server (e.g. Docker) without killing itPossibly taken @amateusr claimed this 20 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 30/100
JdeRobot/BehaviorMetrics#741 ·
-
Broken links in Quick start CARLA on BehaviorMetrics websitePossibly taken @canveo claimed this 293 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
JdeRobot/BehaviorMetrics#724 · 2 comments ·
-
Add reward-based metric for policy evaluation in CARLAMay be free again @Satyamgupta2365 claimed this 284 days ago, and no pull request is open. Open
Difficulty 5/5 Over a week Newbie friendliness 30/100
JdeRobot/BehaviorMetrics#723 · 4 comments ·
All issues in JdeRobot/BehaviorMetrics
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[Maintainer] task area:visualizer
Difficulty 1/5 Under an hour Newbie friendliness 78/100
RailtownAI/railtracks#1824 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
apache/datafusion#27688 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
mloda-ai/mloda-registry#1664 ·
Maintainers usually reply within 1 day