Skip to content

Commit

Permalink
Ford: angle violation shouldn't end controls
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam committed Jan 17, 2022
1 parent 6fe4ecd commit f4dfd1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion board/safety/safety_ford.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static int ford_tx_hook(CANPacket_t *to_send) {
// tx = 0;
// }

// No angle control allowed when controls are not allowed
// No steer control allowed when controls are not allowed
if (!controls_allowed && steer_control_enabled) {
tx = 0;
}
Expand Down
15 changes: 4 additions & 11 deletions tests/safety/test_ford.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,37 +139,30 @@ def test_angle_cmd_when_enabled(self):
# Stay within limits
# Don't change
self.assertTrue(self._tx(self._lkas_control_msg(a, 1)))
self.assertTrue(self.safety.get_controls_allowed())

# Up
self.assertTrue(self._tx(self._lkas_control_msg(a + sign(a) * max_delta_up, 1)))
self.assertTrue(self.safety.get_controls_allowed())

# Down
self._set_prev_angle(a)
self.assertTrue(self._tx(self._lkas_control_msg(a - sign(a) * max_delta_down, 1)))
self.assertTrue(self.safety.get_controls_allowed())

# Inject too high rates
# Up
self._set_prev_angle(a)
self.assertFalse(self._tx(self._lkas_control_msg(a + sign(a) * (max_delta_up + 1.1), 1)))
self.assertFalse(self.safety.get_controls_allowed())

# Don't change
self.safety.set_controls_allowed(1)
self._set_prev_angle(a)
self.assertTrue(self.safety.get_controls_allowed())
self.assertEqual(True, self._tx(self._lkas_control_msg(a, 1)))
self.assertTrue(self.safety.get_controls_allowed())

# Down
self.assertEqual(False, self._tx(self._lkas_control_msg(a - sign(a) * (max_delta_down + 1.1), 1)))
self.assertFalse(self.safety.get_controls_allowed())

# Check desired steer should be the same as steer angle when controls are off
self.safety.set_controls_allowed(0)
self.assertEqual(True, self._tx(self._lkas_control_msg(a, 0)))
# TODO: ford safety doesn't check for this yet
# # Check desired steer should be the same as steer angle when controls are off
# self.safety.set_controls_allowed(0)
# self.assertEqual(True, self._tx(self._lkas_control_msg(a, 0)))

def test_steer_when_disabled(self):
self.safety.set_controls_allowed(0)
Expand Down

0 comments on commit f4dfd1f

Please sign in to comment.