Python API mode: lane keeping and steering stability metrics (right lane percentage, steering zero crossings)

Open
#746 0 comments 0 reactions 0 assignees View on GitHub

@amateusr is already working on this.

Since Nov 3, 2026.

  • #747 by @amateusr — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

A linked pull request (#747) is already open, so check its changes in utils/controller_carla.py and utils/metrics_carla.py before taking this on. Compare the implementation with the proposed per-tick lane columns and JSON metrics; done means those outputs measure lane keeping and steering zero crossings as described.

Written by the indexing model from the issue text.

Description

Expected behavior
For follow-lane evaluation it is useful to know (1) how much of the time the vehicle drives in its own lane, in the right direction, and (2) how nervous the steering is. The current Python API metrics do not provide either.

Actual behavior
The metrics CSV has no per-tick lane information, and the JSON has no lane-keeping or steering-oscillation metric. lane_invasions counts lane-marking crossings, but not whether the vehicle is in the correct lane, and the suddenness metrics measure command changes, not oscillation around zero.

Proposal

  1. Five new CSV columns per tick, from the CARLA waypoint under the ego vehicle: lane_road_id, lane_id, lane_heading_diff (vehicle yaw minus lane yaw, degrees), on_driving_lane and in_right_lane (on a Driving lane and |heading diff| < 90°; optionally also the rightmost driving lane with BM_RIGHT_LANE_MODE=rightmost).
  2. New JSON metrics: right_lane_percentage, off_driving_lane_percentage, steering_zero_crossings and steering_zero_crossings_per_second (sign changes of the applied steering ignoring |steer| < BM_STEER_DEADBAND, 0.02 by default, divided by the simulated time).

Read together: low crossings + high right-lane % = stable and correct; low + low = stable but biased; high + high = nervous corrections; high + low = unstable.

Example
PilotNet in Town02, synchronous stepping, 109 s: right_lane_percentage 94.3 %, steering_zero_crossings_per_second 0.77 (84 crossings). Another model in asynchronous mode: 53.5 % and 0.30/s, i.e. stable but biased to the left, which matched what we saw in the simulator.

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.

Implementation
Patch ready (utils/controller_carla.py +32 lines, utils/metrics_carla.py +46 lines). It applies cleanly on noetic-devel and on feature/carla-python-api-metrics. I also have a documentation section for the currently empty "Supported tasks and evaluation metrics" page.

Related
While testing I also hit two counting bugs in noetic-devel: the collision impulse and the lane invasion are never reset after being recorded, so every tick after the first event counts again (564 collisions and 2372 of 2372 rows as lane invasions in a 27 s run). Both are already fixed in feature/carla-python-api-metrics, so I did not include them here. See also #742, #744 and #745.

cc 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JdeRobot/BehaviorMetrics

All issues in JdeRobot/BehaviorMetrics

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.