Skip to content
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

Ford safety for LCA vehicles #812

Closed
wants to merge 15 commits into from

Conversation

incognitojam
Copy link
Contributor

@incognitojam incognitojam commented Dec 21, 2021

Implementing Ford safety for new(-er) cars with LCA option.

The structure of the code is based upon the VW safety code, and the Tesla/Nissan code (other angle based cars). I used the steering angle rate limit values from the Tesla. These values might need changing, but I would appreciate guidance on where to start with that.

Related PRs

@jyoung8607
Copy link
Collaborator

Glad to see someone working on Ford!

Code passes tests but I have yet to do thorough injection testing myself.

If you wrote Ford-specific tests, they don't seem to be in this PR. In fact, even the old Ford safety doesn't seem to have tests, which is why you didn't see any change in test outcomes from your changes. To get yourself started, look at panda/tests/safety/test_[brand].py for the brands that inspired your safety.

I see your DBC changes haven't been accepted just yet. In order to have your new message and signal structures available for the tests to run, you'll need to do your local test development with your Panda code checked out inside a fully-built openpilot environment that also has your opendbc changes.

board/safety/safety_ford.h Outdated Show resolved Hide resolved
board/safety/safety_ford.h Outdated Show resolved Hide resolved
board/safety/safety_ford.h Outdated Show resolved Hide resolved
board/safety/safety_ford.h Outdated Show resolved Hide resolved
board/safety/safety_ford.h Outdated Show resolved Hide resolved
@incognitojam
Copy link
Contributor Author

I've created the unit tests file, working on adding more tests! Copied some from Tesla for now. Something to consider is that the brake signal and PCM signal are both in the same CAN message. For now, I've done this:

def _brake_msg(self, brake):
  values = {
    "BpedDrvAppl_D_Actl": 2 if brake else 1,
    "CcStat_D_Actl": 5 if self.safety.get_controls_allowed() else 0,
  }
  return self.packer.make_can_msg_panda("EngBrakeData", 0, values)

# when controls are allowed, angle cmd rate limit is enforced
speeds = [0., 1., 5., 10., 15., 50.]
# angles = [-300, -100, -10, 0, 10, 100, 300]
angles = [-23, -10, 0, 10, 23]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The DBC specifies that the range of angles we can command is only [-0.5, 0.5] radians... so this test needs to be updated for that. I also want to verify whether this is correct because 23.6 degrees isn't a huge range.

@incognitojam incognitojam force-pushed the ford-port branch 2 times, most recently from 6534af2 to bf62d80 Compare April 14, 2022 00:31
@incognitojam incognitojam force-pushed the ford-port branch 2 times, most recently from 8979461 to ec90842 Compare April 21, 2022 13:00
@incognitojam incognitojam force-pushed the ford-port branch 2 times, most recently from beac36e to 89c5a5b Compare April 29, 2022 19:03
@incognitojam
Copy link
Contributor Author

Replaced by #966

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants