drive: use signed v in lane-align velocity term to match GIGAFLOW paper#457
Merged
Merged
Conversation
R_l-align's velocity-weighted term in the paper is α_vel-align * min(cos(θ_f) * v, 0)
with signed longitudinal velocity v. The implementation was using the unsigned
sim_speed, which flips behavior in the two reverse-motion cases:
- Facing forward, reversing (world motion against lane): paper penalizes
proportional to speed; code was returning 0.
- Facing backward, reversing (world motion along lane): paper says no penalty;
code was adding one.
Forward driving is unaffected since cos*v and cos*|v| agree when v>0.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Single-character fix in compute_rewards that swaps agent->sim_speed for agent->sim_speed_signed in the GIGAFLOW R_l-align velocity-weighted term so the sign of longitudinal velocity is preserved, matching the paper's formula and correctly handling reverse motion.
Changes:
- Replace unsigned
sim_speedwithsim_speed_signedin thevel_aligned_penaltycomputation. - Reformat the assignment across two lines.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vcharraut
approved these changes
May 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One-line fix in `compute_rewards` for `R_l-align`. The GIGAFLOW paper defines the velocity-weighted term as
with signed longitudinal velocity `v`. The implementation in `drive.h:4247` was using the unsigned `sim_speed`, which inverts the sign of the product for reverse motion and so flips the four cases that come out of the (heading × motion) truth table: