Skip to content

현대·기아 순정내비 vNAVI 감속 및 경로 안내 개선 - #595

Open
ssikssik wants to merge 60 commits into
ajouatom:carrot-wipfrom
ssikssik:carrot-vnavi
Open

ssikssik wants to merge 60 commits into
ajouatom:carrot-wipfrom
ssikssik:carrot-vnavi

Conversation

@ssikssik

@ssikssik ssikssik commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

carrot-wip에 현대·기아 순정내비 vNAVI의 감속 제어와 경로 안내 개선을 통합합니다. EV4에서 실제 주행 경로에 해당하는 안내를 선별해 감속에 반영하고, CarPlay TMAP의 경로 안내 연동을 개선합니다.

주요 변경사항
카메라·구간단속 — 현재 경로의 카메라 거리와 제한속도를 더 정확히 반영합니다. 구간단속 시작 지점을 지나지 않고 중간에 합류하거나 종료 카메라 전에 이탈하면 구간단속 감속을 억제합니다.
램프·커브·방지턱 — 실제 진출이 확인된 경우에 램프 감속을 적용합니다. 램프에서 미리 받은 방지턱 예고는 진출 후 같은 경로로 확인되면 이어서 반영합니다.
경로 안내·NOO — 순정내비의 직진·분기 안내 코드와 CarPlay TMAP의 직진·회전교차로 안내 처리를 개선합니다. 고속도로 우측 분기 사전 차선 변경에 점선·레이더·후측방 경고 확인을 적용하고, 연속 이동은 이전 차선 통과가 확인된 뒤 허용합니다.
Carrot Web 설정 — vNAVI 설정을 한 카드에 모으고 전용 ATC와 하이패스 옵션을 추가합니다. 전용 ATC 설정을 끄면 기존 당근내비 ATC 설정을 따릅니다.

기아 EV4 차량기준으로 정상동작 확인하였으며 타 챠량의 경우 CAN ID값이 달라 정상동작하지 않을 수 있습니다

ssikssik and others added 30 commits December 1, 2026 22:06
…d kind-7 guard

Restores EV4 hybrid section enforcement and school-zone A-CAN 0x380 support that were
dropped during upstream navigation alignment (45ecbe3), while preserving PR ajouatom#589/ajouatom#590/ajouatom#591
(GV80 0x4B5/0x4B8/0x4DE, VehicleNaviSectionAvgControl gate) and EV4 camera counter handling:
- Register CANFD_NAVI_POSITION_363 (0x363) in DBC and CarState for EV4/PV5; honor valid
  POS_RANGE_AVG_SPEED (1..255) while ignoring 0 and boot-invalid 510 (0x1FE)
- Restore _update_ev4_navi_section (0x094 start/end tracking, 0x093 kind=0 end-camera snap,
  0x364 MapSource 2->1 start/end sync, 0x093 slot 1 decode, ev4NextSection queueing,
  0x364 SPEED_LIMIT mismatch fallback, tunnel CalculatedRoute==2 preservation, matching
  0x380 kind=7 cleanup on section end, gated by speedcamSectionAvgControl)
- Block unconfirmed EV4 0x093 kind=7 profiles (e.g. 0000034e t=705.39 during start camera
  approach MapSource=2) so section never latches prematurely and drops at start passage

(cherry picked from commit 40f3a55)
…radius scale, and HUD filter

(cherry picked from commit cdcf7ef)
…d fix ko language match

(cherry picked from commit 42dd5cc)
…navInstructionCarrot

(cherry picked from commit 3867b4d)
…navInstructionCarrot priority, and 0x70

(cherry picked from commit 5a74f22)
… EV4 CAN-FD 0x206 GPS

(cherry picked from commit 837506d)
…h dedicated 50-300% factor

(cherry picked from commit 2441b4b)
Stock-navi 0x2A3 distances are rounded to the nearest display step (100 m
above 300 m, 10 m below), unlike CarPlay TMap's 1 m countdown. Anchoring
dead-reckoning at the displayed value made stock-navi turn distances read
~40 m short above 300 m and jump back up at the 300 m -> 10 m-step switch.

On a genuine step-down of the same maneuver, anchor at the rounding
boundary instead (>=1 km +25 m, 300-999 m 50 m minus 0.6 s latency with a
30 m floor, 10-299 m +4.5 m). CarPlay frames are unchanged.

Replay of EV4 stock-navi routes 00000356/00000357 through CarState:
300-1000 m median abs error 41.7 m -> 5.0 m, 40-299 m 6.6 m -> 3.9 m.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 3412143)
EV4 0x364 MapSource=2 starts a fixed speed_kph * 7.6 m before the physical
camera (60->459, 70->528, 80->611-618, 90->684-689, 100->755-757 m over 16
warnings, 11/17-11/30). The virtual window speed * VehicleSpeedCameraDistanceTime
(6.0 s -> 540 m at 90) plus the 40 m margin never reached the matching 0x093
profile, so real-car logs on every version (incl. f7b6989/4c6bfd7a0) show
speedLimitDistance clamping to 1 m 100-160 m before the actual camera.

Use max(distance time, 7.6 s) for the EV4 warning endpoint. Replay of all
EV4 warnings: exact-profile coverage 0% -> 95-100%, |distance - real| 2-20 m.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 026a974)
CarPlay TMap normally refreshes 0x2A3 about once a second, but across the
EV4 logs it froze on one value three times while the car kept moving:
000003a2 held a right exit (0x93) at 416 m for 28 s / 787 m while the car
took the exit, and 0000038a held a right turn at 667 m for 534 m (it then
resumed at 135 m; dead-reckoning gives 126 m). The raw - step floor kept the
turn distance stuck at 411 m, so ATC stayed in "prepare" past the exit.

Once a CarPlay maneuver has gone more than max(60 m, 2 steps) without a
refresh, drop the floor and keep counting down to 0. Stock navi (no freezes
observed) keeps its bound. Replay of 000003a2: 0 m at 32208 m vs. the real
diverge at 32220 m (was 411 m throughout).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8389694)
Two ramp faults on 0000039c (11/30 21:50-21:56):

1. CarPlay TMap sends 0x48 for a ~180 deg loop connector on an IC ramp.
   It was decoded as a U-turn (xTurnInfo=7, stop speed), so ATC targeted
   1 km/h on the ramp and the car slowed to 7 km/h. On freeway/IC/JC links
   (LinkClass 1-3) treat 0x48 as straight NOO guidance; curve control sets
   the loop speed. City U-turns (LinkClass 0/5) are unchanged, including
   000003a2 where the U-turn point is on the arterial after the ramp.

2. Taking a JC exit reset the stock horizon (0x099 CalculatedRoute=2) and
   cleared every curve, including the armed 0x098 ramp profile that already
   held the loop (60 km/h target 155-225 m ahead). The new path's 0x094 then
   showed the 44 km/h loop only 20-40 m before it. When the reset follows a
   confirmed exit (ramp preview armed and the TBT exit counted down within
   60 m in the last 200 m), keep those ramp curves as the new path's curves
   until passed or off controlled-access roads.

Replay of all EV4 routes: 12 promotions, all followed by the car entering
a ramp/JC link (none on the main road). 0000039c: the loop target is now
shown 123 m ahead (was 41 m), and the ramp U-turn stop is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 85d8eb5)
ssikssik and others added 29 commits December 1, 2026 22:08
The Jetson N16 Nav model takes mapsd's 256x256 route map as an input. On a
failed tile request mapsd discarded the renderer (and its decoded-tile cache)
and published a black map for 30 s. On 0000039c (11/30 21:37-22:05) every
stock-route render failed this way (214/214 invalid windows), so the nav model
drove the whole route on an empty map; across all EV4 logs only 62% of
stock-route windows had a valid map. Replaying 0000039c's GPS and TBT through
the same synthesizer/renderer with working network renders 236/237 frames,
and mapsd is unchanged since, so the failures were tile downloads.

Right turns support the link: with a blank map the driver had to help on
27/38 Jetson turns (median 25% of the turn), vs 4/8 with a valid map and
2/5 on the internal model (median 8%).

On a network error (OSError) keep the renderer and cache, retry after 2, 4,
8, 16 s and rebuild only after 5 consecutive failures or for non-network
errors. Log the exception so the cause is visible next time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 581b153)
mapsd renders the Jetson N16 Nav model's route map on the comma from Mapbox
tiles; a failed download on a patchy hotspot left the model with a blank map
(0000039c: every stock-route render failed). Keep downloaded tiles on disk at
/data/media/0/carrot/map_tiles (device only; CARROT_MAP_TILE_CACHE overrides,
empty disables) and serve them without a request while younger than 30 days.
Expired tiles are deleted, never served. The store is capped at 500 MB,
dropping the oldest downloads first, checked at start and every 200 writes.
Files are keyed by zoom/x/y only and written atomically.

Replaying 0000039c seg 8-9 through mapsd's synthesizer/renderer with all
downloads failing: 236/237 valid maps with the cache (3 tiles, 56 KB) vs 0
without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0e49f75)
Suppress a new short maneuver when its frame reuses the previous icon's distance. Accept a new distance immediately or wait for a later frame to confirm an unchanged distance.

Replayed 53 recorded transitions across 49 EV4 segments. Stale turn outputs and ramp admission are suppressed, and all 52 decodable corrected distances publish on arrival.

(cherry picked from commit ad0abf4)
Recognize the right bypass, left exit, and traversal hints on 0x2A3 without arming automatic turns or ramp braking. Keep the NOO road trace on the approach until the next maneuver.

Replay six guidance intervals and all 53 recorded maneuver transitions on both target branches.

(cherry picked from commit eeeab16)
Log deduplicated announcements, link and camera-warning transitions, advisory alerts, and control activation. Keep section admission and camera outputs identical across 209689 replayed CAN cycles.

(cherry picked from commit 4ad5b37)
Require a ramp link for blinker-only admission. Bridge confirmed exits across the preview timeout and allow their transferred curves during a route reset.

(cherry picked from commit d59c675)
With no fixed highway ATC speed set, a fork targeted the posted limit, which
on an IC/JC ramp is the ramp's 40 km/h sign. EV4 logs show forks on
controlled-access roads cutting 68-79 km/h to 40-50 km/h even where the road
after the fork was nearly straight (00000380 s30, 0000039c s11, 000003a2 s8:
max lateral accel 0.3-1.2 m/s^2), and turns on freeways used the 25 km/h city
turn speed.

On freeways and, for stock navi, their IC/JC ramps (LinkClass 1-3), forks and
turns now target max(posted limit, 80% of the approach speed, 50 km/h). The
approach speed is tracked until 400 m before the maneuver and frozen inside
it so the target does not follow the car's own braking. Geometry after the
fork stays with the curve sources (vNAVI 0x094/0x098 curve and ramp speeds,
vision vturn), which use the real radius. A fixed highway ATC speed still
takes precedence. Stock/CarPlay 0x47 bear-left turns use at least 40 km/h
(capped at the posted limit) instead of the 90-degree turn speed; city
90-degree turns, U-turns, tollgates and arrival are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit fbf8782)
The adaptive fork/turn speed applies to every controlled-access road
(LinkClass 1 covers both expressways and motorway-only roads), but its
50 km/h floor did not distinguish them. Latch the main road's posted limit
until 400 m before the maneuver, like the approach speed (the limit switches
to the ramp's sign once the car exits), and use max(50, 0.6 x that limit) as
the floor: 110 -> 66, 100 -> 60, 90 -> 54, motorway-only roads <= 83 -> 50.
Target = max(posted limit, 80% of approach speed, floor), so an expressway
at 100 km/h takes a ramp fork at 80 and a motorway-only road at 80 at 64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 66ef4c4)
Some exits carry neither a 0x094 lane zone nor a 0x09A stub, so the TBT
exit was never matched and the 0x098 ramp profile was never armed or
carried over the exit's horizon reset. On 0000039c (11/30) the dropped
profile already held the JC loop (60 km/h, 155-225 m ahead) and the new
path only showed it ~20 m before the loop.

On the MPP horizon (route state 0) path 9 is the other branch at the next
diverge. When no exit is otherwise known within 600 m, a TBT exit within
300 m, Frwinfo active and a ramp profile starting -100..+250 m around the
TBT point now count as a matched exit. With a destination route active
path 8 already follows the exit and the rule does not apply.

Closed-loop simulation of 37 EV4 exits/entries (CarState + CarrotServ with
the device settings): only 0000039c s17 changes (ramp entry 99 -> 77 km/h);
no other ramp's speed or lateral acceleration moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2465642)
Preserve upstream Waze and Mapbox route arbitration and limit adaptive highway ATC to stock guidance. Retain the upstream CarState field ordinals, keep the new CAN definitions reproducible, and align the section-control settings and documentation.
Section-average enforcement is measured between the start and end cameras,
so a route that exits mid-section is never averaged. When the route's next
maneuver from 0x2A3 leaves the road (turn, fork/exit, U-turn or arrival)
at least 200 m before a known EV4 section end, the section cap is not
applied from the start. It reuses the existing section-ignored path, so the
start and end cameras keep their spot-speed deceleration and the section
itself stays tracked. Straight guidance and tollgates keep the cap, and a
missed exit re-applies it once the navigation reroutes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ATC lane changes only armed once the car was already in the last lane on
the fork side and then waited for a newly appearing exit lane, so a car in a
middle lane stayed in preLaneChange (EV4 logs: right-side ATC started on
10/16 stock-navi and 32/52 Carrot-app attempts). Left forks never changed
lanes without the driver's blinker.

New setting AtcPreLaneChange (default on): on freeways/motorway-only roads,
within 2 km of an ATC fork/exit (left or right, including the "prepare"
window) and not yet in the last lane on that side, request ordinary one-lane
changes toward it. Chained moves need no torque but keep the lane-change
delay and every existing safety gate (dashed line, blind spot, side
objects, minimum speed). In the last lane the previous exit-lane behavior
applies. On those roads left forks also change lanes automatically.

Also brings the wiki settings count tests up to the catalog (286).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With AtcPreLaneChange on, left ATC lane changes (fork left / atc left, e.g.
into a left-turn pocket) no longer need the driver's blinker on any road;
they use the same automatic gate as right ones (last lane, appearing lane,
dashed line, blind spot, side objects, minimum speed). The 2 km pre-lane
move stays limited to freeways and motorway-only roads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oad graph

Stock navi reports every city maneuver as a turn, so near-straight forks were
slowed to the fixed 25 km/h like 90 degree corners. mapsd now measures the
sharpest branch on the turn side near the reported junction (also when no
nav-map consumer is attached) and publishes it to /dev/shm; carrot_serv keeps
25 km/h at >=70 deg, eases to 40 km/h at 30 deg and keeps ~80% of the approach
speed below 15 deg. No measurement keeps the configured speed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ght exit

Fix two stock-navi issues observed on EV4 route 000003a6--d4dd61abbe:
1. 0x099/0x4B9 ADASIS SEGMENT streams future horizon segments up to ~2 km ahead;
   writing segment.functional_road_class directly to vehicleNaviRoadClass caused a
   distant FRC=1 expressway segment (1248-1991 m ahead) to mark the current FRC=5
   surface road as controlled-access and purge upcoming speed bumps 305 m early.
   Track 0x099/0x4B9 road class in a distance-indexed horizon and sync
   vehicleNaviRoadClass from the current position.
2. Stock-navi overpass right side-road exits emit 0x2A3 TBT_DISPLAY_TYPE=0x51
   down to 100 m and transition to 0x2C with TBT_DIRECTION=0x0C from 90 m to 0 m
   (whereas straight overpass entry 0x58 transitions to 0x2C with TBT_DIRECTION=0x24).
   Decode 0x51 and 0x2C (dir=0x0C) as right exit (turn_info=4 on controlled-access,
   2 on surface roads), keep 0x2C with other directions as straight (9), and apply
   the 40 km/h slight-turn ATC floor and right-exit label/maneuver.
…s 1 or 3

On EV4 route 000003a6 seg43, a freeway left fork (0x47) transitioned to close-range
0x0D with TBT_DIRECTION=0x2D (-22.5 deg, slight left) and TBT_BAR_GRAPH_LEVEL=3.
The previous 'direction == 0x03 or bar_level in (1, 3)' check treated bar_level=3
as a right fork (xTurnInfo=4), triggering an immediate pre-lane change to the right
at 105 km/h.

Decode 0x0D strictly from TBT_DIRECTION (0x00 -> left fork, 0x20..0x2F -> left
branch 3/1 matching 0x47, 0x03 -> right fork 4, else straight 9), drop the bogus
bar_level heuristic, and apply the slight-left speed floor/label to surface 0x0D.
…av model

Mapbox/stock-navi straight and tollgate notices ('notification') were mapped
to Valhalla enum 28 (kFerryEnter), and maneuver distances were divided by 100
without an upper bound. On long highway segments (10-56 km), feeding enum 28
and/or huge distance/100 values (100-567) while nav_map is valid pushed the
Jetson N16 Nav RL model strongly left (-0.35 to -0.98 m) in laneless mode.

Treat 'notification' as no-maneuver (None, like 'merge') so subsequent real
maneuvers are not masked, and only populate the navigation command vector when
the remaining maneuver distance is within 3000 m.
…63 turn, and straight route caching

Fix four issues observed in EV4 real-drive logs (000003a8):
1. vNAVI curve buffer eviction (carstate.py): 0x094 ADASIS PROSHORT streams
   straight/ultra-gentle samples (R >= 800 m, ref >= 150 km/h) that filled
   63/64 buffer slots and immediately evicted the Dunnae IC loop ramp
   (R=49 m, 36.6 km/h) transmitted 1.7 km ahead. Skip >= 150 km/h samples,
   increase VEHICLE_NAVI_MAX_CURVES to 128, and evict the gentlest (highest
   reference speed) entry instead of dropping farthest curves.
2. Off-ramp adaptive ATC (carrot_serv.py): on controlled-access stock-navi
   off-ramp exits (0xA4, 0x11, 0x51, 0x93, 0x95, close-range 0x2C), do not
   raise the adaptive target back up to the mainline posted limit via
   max(road_speed, adaptive), while keeping mainline forks unchanged.
3. Stock-navi TBT 0x63 (carstate.py): decode compound right-then-left city
   turn code 0x63 as turn_info=2 (verified on 000003a8 seg 7).
4. Stock-navi mapsd synthesis caching (vehicle_navi_route.py): cache the
   synthesized straight/approach route (up to 340 m trace, rebuilt when
   remaining ahead < 195 m, heading deviates > 35 deg, or entering
   TURN_LOOKAHEAD_M) to avoid rebuilding _LocalRoadGraph on every frame.
…oundabout approaches

CarPlay TMap emits roundabout guidance (turn_info=10) hundreds of meters to
kilometers ahead. Only disable straight-route caching once inside the
roundabout clipping window (mdist <= STRAIGHT_TRACE_M + JUNCTION_EARLY_WINDOW_M)
so distant roundabout approaches reuse the cached straight route while
close-range clipping remains unchanged.
Group stock navigation and shared camera, speed bump, and ATC options under Driving. Preserve parameter definitions and the existing detail panels.
Restore shared settings to their prior menus. Place the existing vNAVI ATC override at the top and add an opt-in stock-specific pre-lane move setting.
Keep previews on the confirmed route while on a motorway or ramp. Restore them only on a verified surface-road approach before the next maneuver, and discard them when the route changes.
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.

1 participant