这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ccdunder
Copy link
Contributor

@ccdunder ccdunder commented Dec 14, 2024

Checklist

  • added entry to CAR in selfdrive/car/*/values.py and ran selfdrive/car/docs.py to generate new docs
  • test route added to routes.py
  • route with openpilot:
    • HEV: 6c0069dcd5bbb6c1/00000020--6b95507969
    • ICE: 481f55600340bebb/00000095--49fb7431a0
  • route with stock system:
    • HEV: 6c0069dcd5bbb6c1/00000021--e6c25dde2d
    • ICE: f1a99071580b5733/00000007--260128fdab
  • car harness used (if comma doesn't sell it, put N/A):
    • HDA1: Hyundai K
    • HDA2: Hyundai Q

Dependencies:

Changes:

  1. Adds new car KIA_CARNIVAL_HEV_4TH_GEN. This is the first year the Carnival is available as a hybrid.
  2. Adds new car KIA_CARNIVAL_2025. While it's ostensibly "4th gen", it's very different from previous 4th gen Carnivals. In terms of static flags alone, it doesn't have RADAR_SCC, has ccNC, and gets incorrectly dynamically flagged HYBRID.
  3. Adds support for ALT_BUTTONS with HDA2. Otherwise, the following error is logged continuously and can never becomes valid:
    "filename": "opendbc_repo/opendbc/can/parser.cc",
    "funcname": "UpdateValid",
    "levelnum": 40,
    "lineno": ' '230,
    "msg": "0x1CF \'CRUISE_BUTTONS\' NOT SEEN"}',
    
  4. Adds support for cruise resume from standstill with ALT_BUTTONS.
    • This is needed for some other ccNC models as well.
  5. Adds support for lane change detection with ALT_LAMPS.
    • This is needed for some other ccNC models as well.
  6. Adds support for ICE vehicles with all-zero messages on the hybrid accel address. This includes:
    i. Adds a static ICE flag to prevent incorrect dynamic detection as HYBRID.
    Alternative considered: We could check if not 0x100 in fingerprint[CAN.ECAN]. That passed testing on all routes, but explicit configuration is much easier to maintain (case in point).
    ii. Changes safety RX check config to add only the relevant accelerator check (rather than all 3 (GAS, HYBRID, EV)).
  7. Adds support for HDA2 long on ccNC models by populating new requisite messages (MSG_161, MSG_162).
  8. Refactors the safety code and tests in order to support the many combinations of HKG flags. See the commit message for further details and alternatives considered.

TODO (before final review, but there's a lot I'd like to get an initial review on before dotting I's and crossing T's):

  • Shave down changes to hyundaicanfd.py to absolute minimum and not modify existing behavior.
  • Trigger rx check invalid flag (see TODO in the refactor).

Parent PR: commaai/openpilot#34662

@github-actions github-actions bot added car related to opendbc/car/ hyundai labels Dec 14, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to opendbc! In order for us to review your PR as quickly as possible, check the following:

  • Convert your PR to a draft unless it's ready to review
  • Read the contributing docs
  • Before marking as "ready for review", ensure:
    • the goal is clearly stated in the description
    • all the tests are passing
    • include a route or your device' dongle ID if relevant

@sunnyhaibin
Copy link
Contributor

This PR is a duplicate of #1558.

@ccdunder
Copy link
Contributor Author

This PR is a duplicate of #1558.

Sure, the titles are similar but the content is very different. #1558 appears to be a stale draft with fingerprints only. This PR has fixes, routes, and has been verified to work.

@jyoung8607
Copy link
Collaborator

Disclaimer: While I have the ability to merge one of these PRs, I don't set bounty policy or make bounty decisions.

@ccdunder: Welcome to opendbc and openpilot! We like having new contributors. That said, if you're aware there are other potentially duplicate PRs, it's good practice to explicitly mention them and explain why it's necessary to file a separate one. I wouldn't really call that other PR stale, conversations and testing are clearly in progress.

@sunnyhaibin: Haven't reviewed these in depth, but there are definitely differences between these PRs, starting with the existence of Panda changes in this one. Neither of these PRs are ready to merge. To get one of them merge-ready, this would be a great time to onboard and collaborate with a first-time contributor and HKG owner.

@ccdunder ccdunder changed the title Car Port: Kia Carnival 2025 HDA2 (Hybrid & ICE) Car Port: Kia Carnival HEV 2025 (HDA2) Dec 16, 2024
@ccdunder
Copy link
Contributor Author

@sunnyhaibin my sincere apologies for my overly critical reply. I heard what sounded like "we don't want your work" and got confused and defensive. My sincere thanks @jyoung8607 for the warm welcome and cool moderation 🙏 Jason and I are collaborating in discord now.

To avoid duplicating efforts, I'm going to focus this set of PRs on the HEV specifically (i.e. drop the ICE fingerprints). There is an additional issue that only affects the ICE model and I only have an HEV to verify with anyhow.

@ccdunder ccdunder force-pushed the kia-carnival-25 branch 4 times, most recently from 6b73dc8 to 300e557 Compare December 17, 2024 18:08
@ccdunder ccdunder marked this pull request as draft December 19, 2024 21:00
This is necessary in order to support the 2025 Kia Carnival w/ HDA2,
which uses ALT_BUTTONS.

This seems exceedingly unlikely to cause a regression. If any car wasn't
hitting this branch and now does, it means it was already broken (trying
to use BUTTONS when they don't exist).
This is needed for the Kia Caravan '25.
This is needed for the Kia Caravan '25.
@ccdunder ccdunder force-pushed the kia-carnival-25 branch 3 times, most recently from 1523991 to 398e585 Compare February 21, 2025 04:12
@ccdunder ccdunder changed the title Car Port: Kia Carnival HEV 2025 (HDA2) Car Port: Kia Carnival 2025 Feb 21, 2025
@ccdunder ccdunder changed the title Car Port: Kia Carnival 2025 Car Port: Kia Carnival 2025 {HEV,ICE} {HDA1,HDA2} Feb 21, 2025
TODO: Minimize changes to create_adrv_messages and make the rest
conditional.

Credit to royjr@ for MSG_161 & MSG_162 signal mapping.
As a newish contributor to this codebase, I should make clear up front that I
haven't taken up this refactoring lightly or without good reason. I would love to avoid it but it seems necessary and less bad than all the other options.  If there is another way to accomplish these goals I'm all ears.

Root problem: HKG flags combine to produce combinatoric configurations.
Supporting this requires tradeoffs between maintainability, convention,
and quality.

Alternatives considered:
1. Continue making RX & TX allowlists overly permissive.
   This seems antithetical to the whole point of safety flags.
2. Continue Copy-pasting nested branches with 1-line differences.
   It seems like this has already been done to the limit of
   reasonable maintainability (3-4 conditions deep).
   Also, to support the new conditions here would mean duplicating the code 8x.

Callout: MISRA
I am not a MISRA expert but AFAIU this conforms. Happy to discuss and iterate if this is incorrect. There are other options that trade readability for reduced dynamism. But at a certain point making everything static for the sake of MISRA seems to miss the forest for the trees.

LMK what you think. I'd love to hear if there's a better way to solve this.
This was removed when safety was moved from panda to opendbc.
This is needed in order for memcpy to be available for safety tests as it is
in production.
@ccdunder
Copy link
Contributor Author

Plan is to land this as part of #1625

Copy link
Contributor

@adeebshihadeh adeebshihadeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite big. Can we break this up at all into smaller self-contained PRs? At least break out the two different car models

Comment on lines +227 to +234
left_blinker_sig, right_blinker_sig = (
("LEFT_LAMP_ALT", "RIGHT_LAMP_ALT")
if cp.vl['BLINKERS']['USE_ALT_LAMP']
else ("LEFT_LAMP", "RIGHT_LAMP")
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the old way this was written is more readable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad merge?

if candidate == CAR.KIA_OPTIMA_G4_FL:
ret.steerActuatorDelay = 0.2
elif candidate == CAR.KIA_CARNIVAL_HEV_4TH_GEN:
ret.steerActuatorDelay = 0.35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incredibly high. are you sure? how'd you determine this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanna split this out? we can just merge this to reduce the diff a bit

Comment on lines +15 to +24
printf("i %d seen %d lagging %d valid checksum %d wrong counters %d valid quality flag %d\n",
i, addr.status.msg_seen, addr.status.lagging, addr.status.valid_checksum, addr.status.wrong_counters, addr.status.valid_quality_flag);
for (int j = 0; j < MAX_ADDR_CHECK_MSGS; j++) {
const CanMsgCheck msg = addr.msg[j];
if (msg.addr == 0) {
break;
}
printf("i %d j %d bus %d addr 0x%x len %d\n",
i, j, msg.bus, msg.addr, msg.len);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you split this out and put it behind an environment variable (like LOGPRINT=debug), we can merge this

@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2025

This PR has had no activity for 60 days. It will be automatically closed in 7 days if there is no activity.

@github-actions github-actions bot added the stale label Jun 3, 2025
@github-actions
Copy link
Contributor

This PR has been automatically closed due to inactivity. Feel free to re-open once activity resumes.

@github-actions github-actions bot closed this Jun 10, 2025
@adeebshihadeh adeebshihadeh reopened this Jun 10, 2025
@github-actions github-actions bot removed the stale label Jun 11, 2025
@github-actions
Copy link
Contributor

This PR has had no activity for 60 days. It will be automatically closed in 7 days if there is no activity.

@github-actions github-actions bot added the stale label Sep 22, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2025

This PR has been automatically closed due to inactivity. Feel free to re-open once activity resumes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

car safety vehicle-specific safety code car related to opendbc/car/ DBC signals hyundai stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants