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

safety: add longitudinal pre-enable state for brake at a standstill #1123

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
95a5148
disallow longitudinal at a stop with brake held
sshane Oct 28, 2022
8563b63
comment
sshane Oct 28, 2022
b4b89dc
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Nov 29, 2022
f66a28f
stash what we got so far
sshane Nov 29, 2022
a905664
so far
sshane Nov 29, 2022
c1df489
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Nov 30, 2022
85235a7
stash
sshane Dec 1, 2022
1bc58d6
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Dec 1, 2022
a0d1286
clean up
sshane Dec 1, 2022
5daf884
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Dec 3, 2022
fc5c43f
lateral allowed
sshane Dec 3, 2022
7824cb0
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Dec 15, 2022
7afb897
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Oct 4, 2023
42c0c27
don't change lat
sshane Oct 4, 2023
e689d51
rename
sshane Oct 4, 2023
97f403c
this should work
sshane Oct 4, 2023
813750e
draft
sshane Oct 4, 2023
3c22fdb
need to do this for tesla to know where 0 accel point is
sshane Oct 4, 2023
8065c64
this is cleaner
sshane Oct 4, 2023
65aa62b
oh wait it does
sshane Oct 4, 2023
b5eaf9f
use _generic_limit_safety_check in ford
sshane Oct 4, 2023
a880f46
tests
sshane Oct 4, 2023
2e0e7a9
Revert "use _generic_limit_safety_check in ford"
sshane Oct 4, 2023
4fe2baa
all good
sshane Oct 4, 2023
60d5052
ford
sshane Oct 4, 2023
4c59318
messy
sshane Oct 4, 2023
c48473d
clean up
sshane Oct 4, 2023
40dcb1b
Merge remote-tracking branch 'upstream/master' into brake-preenable
sshane Nov 11, 2023
1c1c6c1
cando this, but this seems more confusing now
sshane Nov 11, 2023
423fe3e
or...
sshane Nov 11, 2023
55681c1
better
sshane Nov 11, 2023
57122bb
comments
sshane Nov 11, 2023
024663a
winning
sshane Nov 11, 2023
26a45ca
remove get_decel_allowed
sshane Nov 11, 2023
7ce2100
space up here
sshane Nov 11, 2023
2965bca
overkill
sshane Nov 11, 2023
31955d8
tests
sshane Nov 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into brake-preenable
  • Loading branch information
sshane committed Dec 3, 2022
commit 5daf884d2060ab8a5a70f4ee29fac285c8086867
27 changes: 2 additions & 25 deletions board/safety/safety_nissan.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,31 +117,8 @@ static int nissan_tx_hook(CANPacket_t *to_send) {
// offeset 1310 * NISSAN_STEERING_LIMITS.angle_deg_to_can
desired_angle = desired_angle - 131000;

if (get_lateral_allowed() && lka_active) {
// add 1 to not false trigger the violation
float delta_angle_float;
delta_angle_float = (interpolate(NISSAN_LOOKUP_ANGLE_RATE_UP, vehicle_speed) * NISSAN_DEG_TO_CAN) + 1.;
int delta_angle_up = (int)(delta_angle_float);
delta_angle_float = (interpolate(NISSAN_LOOKUP_ANGLE_RATE_DOWN, vehicle_speed) * NISSAN_DEG_TO_CAN) + 1.;
int delta_angle_down = (int)(delta_angle_float);
int highest_desired_angle = desired_angle_last + ((desired_angle_last > 0) ? delta_angle_up : delta_angle_down);
int lowest_desired_angle = desired_angle_last - ((desired_angle_last >= 0) ? delta_angle_down : delta_angle_up);

// check for violation;
violation |= max_limit_check(desired_angle, highest_desired_angle, lowest_desired_angle);
}
desired_angle_last = desired_angle;

// desired steer angle should be the same as steer angle measured when controls are off
if ((!get_lateral_allowed()) &&
((desired_angle < (angle_meas.min - 1)) ||
(desired_angle > (angle_meas.max + 1)))) {
violation = 1;
}

// no lka_enabled bit if controls not allowed
if (!get_lateral_allowed() && lka_active) {
violation = 1;
if (steer_angle_cmd_checks(desired_angle, lka_active, NISSAN_STEERING_LIMITS)) {
violation = true;
}
}

Expand Down
24 changes: 1 addition & 23 deletions board/safety/safety_tesla.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,7 @@ static int tesla_tx_hook(CANPacket_t *to_send) {
bool steer_control_enabled = (steer_control_type != 0) && // NONE
(steer_control_type != 3); // DISABLED

// Rate limit while steering
if(get_lateral_allowed() && steer_control_enabled) {
// Add 1 to not false trigger the violation
float delta_angle_float;
delta_angle_float = (interpolate(TESLA_LOOKUP_ANGLE_RATE_UP, vehicle_speed) * TESLA_DEG_TO_CAN);
int delta_angle_up = (int)(delta_angle_float) + 1;
delta_angle_float = (interpolate(TESLA_LOOKUP_ANGLE_RATE_DOWN, vehicle_speed) * TESLA_DEG_TO_CAN);
int delta_angle_down = (int)(delta_angle_float) + 1;
int highest_desired_angle = desired_angle_last + ((desired_angle_last > 0) ? delta_angle_up : delta_angle_down);
int lowest_desired_angle = desired_angle_last - ((desired_angle_last >= 0) ? delta_angle_down : delta_angle_up);

// Check for violation;
violation |= max_limit_check(desired_angle, highest_desired_angle, lowest_desired_angle);
}
desired_angle_last = desired_angle;

// Angle should be the same as current angle while not steering
if(!get_lateral_allowed() && ((desired_angle < (angle_meas.min - 1)) || (desired_angle > (angle_meas.max + 1)))) {
violation = true;
}

// No angle control allowed when controls are not allowed
if(!get_lateral_allowed() && steer_control_enabled) {
if (steer_angle_cmd_checks(desired_angle, steer_control_enabled, TESLA_STEERING_LIMITS)) {
violation = true;
}
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.