-
Notifications
You must be signed in to change notification settings - Fork 772
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
Toyota: 2021+ RAV4 Prime #2042
Toyota: 2021+ RAV4 Prime #2042
Conversation
4c023d1
to
688c4e4
Compare
board/safety/safety_toyota.h
Outdated
@@ -203,6 +226,19 @@ static bool toyota_tx_hook(const CANPacket_t *to_send) { | |||
} | |||
} | |||
|
|||
// SecOC cars block any form of LTA actuation for now | |||
if (toyota_secoc && (addr == 0x131)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would now label these three blocks with message names (ideally we make a struct that we can use instead of addresses soon)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean trailing comments, like // STEERING_LTA_2.STEER_REQUEST
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments, I'm assuming that's what you were looking for if we're deferring an overall refactor of the entire safety to use message naming macros.
tests/safety/test_toyota.py
Outdated
def _lta_msg(self, req, req2, angle_cmd, torque_wind_down=100): | ||
values = {"STEER_REQUEST": req, "STEER_REQUEST_2": req2, "STEER_ANGLE_CMD": angle_cmd} | ||
return self.packer.make_can_msg_panda("STEERING_LTA_2", 0, values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we still use STEERING_LTA
, do we no longer test that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do send both. Both are present on the car, not sure why. Your point is correct. Reverted to Draft, I'll fix up the tests in the AM to verify no-actuation on both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we ever check what the stock system uses? We were able to send LKA on some 2023 RAV4 but because the stock system used LTA for lane keeping (not just centering) we chose to switch off the unused API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly the stock system uses the LTA for lane keep steering, but the torque message works fine too. So it's like most TSS2 cars in this regard.
They split up the LTA message into two parts, the old one which contains a bunch of values and flags (with no space for a MAC), and a new one that contains just the actual requested steering angle + a SecOC MAC. They did something similar for longitudinal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now testing both messages, thanks for spotting that!
Verified by breaking the 0x191 check offline:
bool steer_control_enabled = lta_request; //|| lta_request2;
Which was properly picked up by both normal and SecOC tests:
FAILED test_toyota.py::TestToyotaSecOcSafety::test_lta_steer_cmd - AssertionError: False != True : req=0 req2=1 angle=0.0 torque_wind_down=0
FAILED test_toyota.py::TestToyotaStockLongitudinalTorque::test_lta_steer_cmd - AssertionError: False != True : req=0 req2=1 angle=0.0 torque_wind_down=0
FAILED test_toyota.py::TestToyotaSafetyTorque::test_lta_steer_cmd - AssertionError: False != True : req=0 req2=1 angle=0.0 torque_wind_down=0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adeebshihadeh do you want to merge this with LKA when we specifically didn't want to merge LKA for the new RAV4s which don't use it but could? commaai/openpilot#29978 for reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably possible to switch to LTA, the SecOC part should just carry over. However, it will take multiple round-trips with test owners to plot how the stock camera drives the two LTA messages in tandem and then replicate, test, and validate safety for that behavior.
I don't have a preference on whether to make the switch, the comma openpilot team knows more depth and breadth of Toyota history than I do. If we do want to make the switch, my preference is to ship what we have and create an issue to track migrating to LTA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly the stock system uses the LTA for lane keep steering, but the torque message works fine too. So it's like most TSS2 cars in this regard.
Sorry, forgot lane keep is what you should call the safety nudges to put you back in the lane, not lane centering. I did not check what the stock system uses for LKA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
board/safety/safety_toyota.h
Outdated
int lta_angle_msb = GET_BYTE(to_send, 2); // STEERING_LTA_2.STEER_ANGLE_CMD (MSB) | ||
int lta_angle_lsb = GET_BYTE(to_send, 3); // STEERING_LTA_2.STEER_ANGLE_CMD (LSB) | ||
|
||
bool actuation = lta_request || lta_request2 || (lta_angle_msb != 0) || (lta_angle_lsb != 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note for review: I originally wrote this to build lta_angle
, like the other LTA message. Unfortunately the mutation test doesn't like it. We never have actuation via this path, so the angle is never valid while non-zero, so the mutation test sees it can introduce faults in the bit-shift operation without consequence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much cleaner!
Co-authored-by: Shane Smiskol <shane@smiskol.com>
Supersedes #1841.
Message naming struct cleanup, similar to ChryslerlaterAdd unit tests for new flagsflags consolidatedEnsure blocking 0x131 from camera doesn't affect any existing Toyotas (or just put behind flag)put behind flag