-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
#34331 #34371
Closed
Closed
#34331 #34371
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7505643
Removed numpy_fast and updated dependent files to eliminate dependency
Shaikimram ffb174e
removed numpy_fast and updated the dependent files
Shaikimram 55a45ce
numpy_fast issue
Shaikimram b33c651
patch of pycap
Shaikimram beffe06
float comversion
Shaikimram 8309240
float comversion
Shaikimram 3515151
#34331
Shaikimram 8669b48
34331
Shaikimram 71a0cba
34331
Shaikimram e44719f
34331
Shaikimram 05dacb4
34331
Shaikimram d575896
34331
Shaikimram 14e7cbd
34331
Shaikimram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import math | ||
|
||
from cereal import log | ||
from openpilot.selfdrive.controls.lib.latcontrol import LatControl | ||
from openpilot.common.pid import PIDController | ||
|
||
|
||
class LatControlPID(LatControl): | ||
def __init__(self, CP, CI): | ||
super().__init__(CP, CI) | ||
self.pid = PIDController((CP.lateralTuning.pid.kpBP, CP.lateralTuning.pid.kpV), | ||
(CP.lateralTuning.pid.kiBP, CP.lateralTuning.pid.kiV), | ||
k_f=CP.lateralTuning.pid.kf, pos_limit=self.steer_max, neg_limit=-self.steer_max) | ||
self.get_steer_feedforward = CI.get_steer_feedforward_function() | ||
|
||
def reset(self): | ||
super().reset() | ||
self.pid.reset() | ||
|
||
def update(self, active, CS, VM, params, steer_limited, desired_curvature, calibrated_pose): | ||
pid_log = log.ControlsState.LateralPIDState.new_message() | ||
pid_log.steeringAngleDeg = float(CS.steeringAngleDeg) | ||
pid_log.steeringRateDeg = float(CS.steeringRateDeg) | ||
|
||
angle_steers_des_no_offset = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo, params.roll)) | ||
angle_steers_des = angle_steers_des_no_offset + params.angleOffsetDeg | ||
error = angle_steers_des - CS.steeringAngleDeg | ||
|
||
pid_log.steeringAngleDesiredDeg = angle_steers_des | ||
pid_log.angleError = error | ||
if not active: | ||
output_steer = 0.0 | ||
pid_log.active = False | ||
self.pid.reset() | ||
else: | ||
# offset does not contribute to resistive torque | ||
steer_feedforward = self.get_steer_feedforward(angle_steers_des_no_offset, CS.vEgo) | ||
|
||
output_steer = self.pid.update(error, override=CS.steeringPressed, | ||
feedforward=steer_feedforward, speed=CS.vEgo) | ||
pid_log.active = True | ||
pid_log.p = float(self.pid.p) | ||
pid_log.i = float(self.pid.i) | ||
pid_log.f = float(self.pid.f) | ||
pid_log.output = float(output_steer) | ||
pid_log.saturated = bool(self._check_saturation(self.steer_max - abs(output_steer) < 1e-3, CS, steer_limited)) | ||
|
||
return output_steer, angle_steers_des, pid_log |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import numpy as np | ||
|
||
from openpilot.common.numpy_fast import interp | ||
|
||
|
||
class TestInterp: | ||
def test_correctness_controls(self): | ||
_A_CRUISE_MIN_BP = np.asarray([0., 5., 10., 20., 40.]) | ||
_A_CRUISE_MIN_V = np.asarray([-1.0, -.8, -.67, -.5, -.30]) | ||
v_ego_arr = [-1, -1e-12, 0, 4, 5, 6, 7, 10, 11, 15.2, 20, 21, 39, | ||
39.999999, 40, 41] | ||
def test_correctness_controls(self): | ||
_A_CRUISE_MIN_BP = np.asarray([0., 5., 10., 20., 40.]) | ||
_A_CRUISE_MIN_V = np.asarray([-1.0, -.8, -.67, -.5, -.30]) | ||
v_ego_arr = [-1, -1e-12, 0, 4, 5, 6, 7, 10, 11, 15.2, 20, 21, 39, | ||
39.999999, 40, 41] | ||
|
||
# Use np.interp directly for arrays | ||
expected = np.interp(v_ego_arr, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V) | ||
actual = np.interp(v_ego_arr, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V) | ||
|
||
expected = np.interp(v_ego_arr, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V) | ||
actual = interp(v_ego_arr, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V) | ||
# Assert that the arrays are equal | ||
np.testing.assert_array_equal(actual, expected) | ||
|
||
np.testing.assert_equal(actual, expected) | ||
# Test for individual scalar values | ||
for v_ego in v_ego_arr: | ||
expected = float(np.interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V)) | ||
actual = float(np.interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V)) | ||
np.testing.assert_equal(actual, expected) | ||
|
||
for v_ego in v_ego_arr: | ||
expected = np.interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V) | ||
actual = interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V) | ||
np.testing.assert_equal(actual, expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
if [[ -f .git/hooks/post-commit.d/post-commit ]]; then | ||
.git/hooks/post-commit.d/post-commit | ||
fi | ||
tools/op.sh lint --fast | ||
echo "" | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; } | ||
git lfs post-commit "$@" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import numpy as np | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
from cereal import log | ||
from openpilot.common.numpy_fast import clip | ||
from openpilot.common.realtime import DT_CTRL | ||
|
||
MIN_SPEED = 1.0 | ||
|
@@ -13,19 +13,19 @@ | |
MAX_VEL_ERR = 5.0 | ||
|
||
def clip_curvature(v_ego, prev_curvature, new_curvature): | ||
new_curvature = clip(new_curvature, -MAX_CURVATURE, MAX_CURVATURE) | ||
new_curvature = float(np.clip(new_curvature, -MAX_CURVATURE, MAX_CURVATURE)) | ||
v_ego = max(MIN_SPEED, v_ego) | ||
max_curvature_rate = MAX_LATERAL_JERK / (v_ego**2) # inexact calculation, check https://github.com/commaai/openpilot/pull/24755 | ||
safe_desired_curvature = clip(new_curvature, | ||
safe_desired_curvature = float(np.clip(new_curvature, | ||
prev_curvature - max_curvature_rate * DT_CTRL, | ||
prev_curvature + max_curvature_rate * DT_CTRL) | ||
prev_curvature + max_curvature_rate * DT_CTRL)) | ||
|
||
return safe_desired_curvature | ||
|
||
|
||
def get_speed_error(modelV2: log.ModelDataV2, v_ego: float) -> float: | ||
# ToDo: Try relative error, and absolute speed | ||
if len(modelV2.temporalPose.trans): | ||
vel_err = clip(modelV2.temporalPose.trans[0] - v_ego, -MAX_VEL_ERR, MAX_VEL_ERR) | ||
vel_err = float(np.clip(modelV2.temporalPose.trans[0] - v_ego, -MAX_VEL_ERR, MAX_VEL_ERR)) | ||
return float(vel_err) | ||
return 0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
revert this