Skip to content

pandad: close relay when openpilot goes offroad #35739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 17, 2025

Conversation

sshane
Copy link
Contributor

@sshane sshane commented Jul 17, 2025

Closes #35709.

Previously, the only user-facing way you could make openpilot go offroad was turning off the car ignition. pandad handled this by resetting the safety mode to NO_OUTPUT.

Then we added onroad cycling via toggles, but pandad only checked the ignition for resetting the safety mode. This kept the relay open and faulted the car, until openpilot set it to ELM327 for fingerprinting starting back up.

This bug also faulted the car if the device went offroad from device_temp_good going false.


Flipping the enable op toggle now:

      safetyModel = toyota,
      safetyModel = toyota,
      safetyModel = toyota,
      safetyModel = toyota,
      safetyModel = toyota,
      safetyModel = toyota,
      safetyModel = toyota,
      safetyModel = toyota,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = noOutput,
      safetyModel = elm327,
      safetyModel = elm327,
      safetyModel = elm327,
      safetyModel = elm327,
      safetyModel = elm327,
      safetyModel = elm327,

@sshane sshane changed the title pandad: reset safety mode when openpilot goes offroad pandad: close relay when openpilot goes offroad Jul 17, 2025
@sshane sshane added the bugfix label Jul 17, 2025
@sshane sshane requested a review from Copilot July 17, 2025 06:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where pandad didn't properly close the relay when openpilot went offroad through user toggles or device temperature issues, only handling ignition-based transitions. The change ensures the relay is closed whenever the system goes offroad, preventing car faults.

  • Modified pandad to check both ignition state and onroad status when deciding whether to close the relay
  • Updated the safety mode configuration to consider onroad state in addition to ignition
  • Moved onroad state checking to the main loop for consistent tracking

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
selfdrive/pandad/pandad.h Updated configureSafetyMode method signature to accept is_onroad parameter
selfdrive/pandad/pandad.cc Added onroad state tracking and updated relay closing logic to consider both ignition and onroad status
selfdrive/pandad/panda_safety.cc Removed local onroad parameter reading, now accepts it as method parameter

@sshane sshane merged commit ddb0d7c into master Jul 17, 2025
19 checks passed
@sshane sshane deleted the fix-fault-when-op-goes-offroad branch July 17, 2025 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pandad doesn't close relay when going offroad
1 participant