formatting

This commit is contained in:
Jason Wen
2024-07-01 11:18:47 -04:00
parent 1051580e63
commit 6098dd300a
3 changed files with 28 additions and 28 deletions
+1
View File
@@ -209,6 +209,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"UpdaterTargetBranch", CLEAR_ON_MANAGER_START},
{"UpdaterLastFetchTime", PERSISTENT},
{"Version", PERSISTENT},
{"AccelProfile", PERSISTENT | BACKUP},
{"AccMadsCombo", PERSISTENT | BACKUP},
{"AmapKey1", PERSISTENT | BACKUP},
@@ -19,8 +19,8 @@ from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import T_IDX
from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, CONTROL_N, get_speed_error
from openpilot.selfdrive.controls.lib.vision_turn_controller import VisionTurnController
from openpilot.selfdrive.controls.lib.turn_speed_controller import TurnSpeedController
from openpilot.selfdrive.controls.lib.sunnypilot.dynamic_experimental_controller import DynamicExperimentalController
from openpilot.selfdrive.controls.lib.sunnypilot.accel_controller import AccelController
from openpilot.selfdrive.controls.lib.sunnypilot.dynamic_experimental_controller import DynamicExperimentalController
from openpilot.selfdrive.controls.lib.events import Events
from openpilot.common.swaglog import cloudlog
@@ -21,7 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Last update: June 5, 2024
# Last updated: June 5, 2024
from openpilot.common.numpy_fast import interp
@@ -43,34 +43,33 @@ _DP_CRUISE_MAX_BP = [0., 1., 6., 8., 11., 15., 20., 25., 30., 55.
class AccelController:
def __init__(self):
# self._params = Params()
self._profile = DP_ACCEL_STOCK
def __init__(self):
# self._params = Params()
self._profile = DP_ACCEL_STOCK
def set_profile(self, profile):
try:
self._profile = int(profile) if int(profile) in [DP_ACCEL_STOCK, DP_ACCEL_ECO, DP_ACCEL_NORMAL, DP_ACCEL_SPORT] else DP_ACCEL_STOCK
except:
self._profile = DP_ACCEL_STOCK
def set_profile(self, profile):
try:
self._profile = int(profile) if int(profile) in [DP_ACCEL_STOCK, DP_ACCEL_ECO, DP_ACCEL_NORMAL, DP_ACCEL_SPORT] else DP_ACCEL_STOCK
except:
self._profile = DP_ACCEL_STOCK
def _dp_calc_cruise_accel_limits(self, v_ego):
if self._profile == DP_ACCEL_ECO:
min_v = _DP_CRUISE_MIN_V_ECO
max_v = _DP_CRUISE_MAX_V_ECO
elif self._profile == DP_ACCEL_SPORT:
min_v = _DP_CRUISE_MIN_V_SPORT
max_v = _DP_CRUISE_MAX_V_SPORT
else:
min_v = _DP_CRUISE_MIN_V
max_v = _DP_CRUISE_MAX_V
def _dp_calc_cruise_accel_limits(self, v_ego):
if self._profile == DP_ACCEL_ECO:
min_v = _DP_CRUISE_MIN_V_ECO
max_v = _DP_CRUISE_MAX_V_ECO
elif self._profile == DP_ACCEL_SPORT:
min_v = _DP_CRUISE_MIN_V_SPORT
max_v = _DP_CRUISE_MAX_V_SPORT
else:
min_v = _DP_CRUISE_MIN_V
max_v = _DP_CRUISE_MAX_V
a_cruise_min = interp(v_ego, _DP_CRUISE_MIN_BP, min_v)
a_cruise_max = interp(v_ego, _DP_CRUISE_MAX_BP, max_v)
return a_cruise_min, a_cruise_max
a_cruise_min = interp(v_ego, _DP_CRUISE_MIN_BP, min_v)
a_cruise_max = interp(v_ego, _DP_CRUISE_MAX_BP, max_v)
return a_cruise_min, a_cruise_max
def get_accel_limits(self, v_ego, accel_limits):
return accel_limits if self._profile == DP_ACCEL_STOCK else self._dp_calc_cruise_accel_limits(v_ego)
def get_accel_limits(self, v_ego, accel_limits):
return accel_limits if self._profile == DP_ACCEL_STOCK else self._dp_calc_cruise_accel_limits(v_ego)
def is_enabled(self):
return self._profile != DP_ACCEL_STOCK
def is_enabled(self):
return self._profile != DP_ACCEL_STOCK