Aggressive acceleration when following a lead
Added toggle to make the acceleration more aggressive when following a lead.
This commit is contained in:
@@ -211,6 +211,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||||||
// FrogPilot parameters
|
// FrogPilot parameters
|
||||||
{"AccelerationPath", PERSISTENT},
|
{"AccelerationPath", PERSISTENT},
|
||||||
{"AccelerationProfile", PERSISTENT},
|
{"AccelerationProfile", PERSISTENT},
|
||||||
|
{"AggressiveAcceleration", PERSISTENT},
|
||||||
{"ApiCache_DriveStats", PERSISTENT},
|
{"ApiCache_DriveStats", PERSISTENT},
|
||||||
{"CustomAlerts", PERSISTENT},
|
{"CustomAlerts", PERSISTENT},
|
||||||
{"CustomUI", PERSISTENT},
|
{"CustomUI", PERSISTENT},
|
||||||
|
|||||||
@@ -222,6 +222,7 @@ def gen_long_ocp():
|
|||||||
class LongitudinalMpc:
|
class LongitudinalMpc:
|
||||||
def __init__(self, mode='acc'):
|
def __init__(self, mode='acc'):
|
||||||
# FrogPilot variables
|
# FrogPilot variables
|
||||||
|
self.acceleration_offset = 1
|
||||||
|
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.solver = AcadosOcpSolverCython(MODEL_NAME, ACADOS_SOLVER_TYPE, N)
|
self.solver = AcadosOcpSolverCython(MODEL_NAME, ACADOS_SOLVER_TYPE, N)
|
||||||
@@ -275,6 +276,8 @@ class LongitudinalMpc:
|
|||||||
|
|
||||||
def set_weights(self, prev_accel_constraint=True, personality=log.LongitudinalPersonality.standard):
|
def set_weights(self, prev_accel_constraint=True, personality=log.LongitudinalPersonality.standard):
|
||||||
jerk_factor = get_jerk_factor(personality)
|
jerk_factor = get_jerk_factor(personality)
|
||||||
|
jerk_factor /= np.mean(self.acceleration_offset)
|
||||||
|
|
||||||
if self.mode == 'acc':
|
if self.mode == 'acc':
|
||||||
a_change_cost = A_CHANGE_COST if prev_accel_constraint else 0
|
a_change_cost = A_CHANGE_COST if prev_accel_constraint else 0
|
||||||
cost_weights = [X_EGO_OBSTACLE_COST, X_EGO_COST, V_EGO_COST, A_EGO_COST, jerk_factor * a_change_cost, jerk_factor * J_EGO_COST]
|
cost_weights = [X_EGO_OBSTACLE_COST, X_EGO_COST, V_EGO_COST, A_EGO_COST, jerk_factor * a_change_cost, jerk_factor * J_EGO_COST]
|
||||||
@@ -340,6 +343,15 @@ class LongitudinalMpc:
|
|||||||
lead_xv_0 = self.process_lead(radarstate.leadOne)
|
lead_xv_0 = self.process_lead(radarstate.leadOne)
|
||||||
lead_xv_1 = self.process_lead(radarstate.leadTwo)
|
lead_xv_1 = self.process_lead(radarstate.leadTwo)
|
||||||
|
|
||||||
|
# Offset by FrogAi for FrogPilot for a more natural takeoff with a lead
|
||||||
|
if frogpilot_planner.aggressive_acceleration:
|
||||||
|
distance_factor = np.maximum(1, lead_xv_0[:,0] - (lead_xv_0[:,1] * t_follow))
|
||||||
|
standstill_offset = max(STOP_DISTANCE - (v_ego**COMFORT_BRAKE), 0)
|
||||||
|
self.acceleration_offset = np.clip((lead_xv_0[:,1] - v_ego) + standstill_offset - COMFORT_BRAKE, 1, distance_factor)
|
||||||
|
t_follow = t_follow / self.acceleration_offset
|
||||||
|
else:
|
||||||
|
self.acceleration_offset = 1
|
||||||
|
|
||||||
# To estimate a safe distance from a moving lead, we calculate how much stopping
|
# To estimate a safe distance from a moving lead, we calculate how much stopping
|
||||||
# distance that lead needs as a minimum. We can add that to the current distance
|
# distance that lead needs as a minimum. We can add that to the current distance
|
||||||
# and then treat that as a stopped car/obstacle at this new distance.
|
# and then treat that as a stopped car/obstacle at this new distance.
|
||||||
|
|||||||
@@ -75,3 +75,4 @@ class FrogPilotPlanner:
|
|||||||
longitudinal_tune = params.get_bool("LongitudinalTune")
|
longitudinal_tune = params.get_bool("LongitudinalTune")
|
||||||
self.acceleration_profile = params.get_int("AccelerationProfile") if longitudinal_tune else 0
|
self.acceleration_profile = params.get_int("AccelerationProfile") if longitudinal_tune else 0
|
||||||
self.deceleration_profile = params.get_int("DecelerationProfile") if longitudinal_tune else 0
|
self.deceleration_profile = params.get_int("DecelerationProfile") if longitudinal_tune else 0
|
||||||
|
self.aggressive_acceleration = longitudinal_tune and params.get_bool("AggressiveAcceleration")
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
|
|||||||
{"LongitudinalTune", "Longitudinal Tuning", "Modify openpilot's acceleration and braking behavior.", "../frogpilot/assets/toggle_icons/icon_longitudinal_tune.png"},
|
{"LongitudinalTune", "Longitudinal Tuning", "Modify openpilot's acceleration and braking behavior.", "../frogpilot/assets/toggle_icons/icon_longitudinal_tune.png"},
|
||||||
{"AccelerationProfile", "Acceleration Profile", "Change the acceleration rate to be either sporty or eco-friendly.", ""},
|
{"AccelerationProfile", "Acceleration Profile", "Change the acceleration rate to be either sporty or eco-friendly.", ""},
|
||||||
{"DecelerationProfile", "Deceleration Profile", "Change the deceleration rate to be either sporty or eco-friendly.", ""},
|
{"DecelerationProfile", "Deceleration Profile", "Change the deceleration rate to be either sporty or eco-friendly.", ""},
|
||||||
|
{"AggressiveAcceleration", "Aggressive Acceleration With Lead", "Increase acceleration aggressiveness when following a lead vehicle from a stop.", ""},
|
||||||
|
|
||||||
{"QOLControls", "Quality of Life", "Miscellaneous quality of life changes to improve your overall openpilot experience.", "../frogpilot/assets/toggle_icons/quality_of_life.png"},
|
{"QOLControls", "Quality of Life", "Miscellaneous quality of life changes to improve your overall openpilot experience.", "../frogpilot/assets/toggle_icons/quality_of_life.png"},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ private:
|
|||||||
std::set<QString> fireTheBabysitterKeys = {};
|
std::set<QString> fireTheBabysitterKeys = {};
|
||||||
std::set<QString> laneChangeKeys = {};
|
std::set<QString> laneChangeKeys = {};
|
||||||
std::set<QString> lateralTuneKeys = {};
|
std::set<QString> lateralTuneKeys = {};
|
||||||
std::set<QString> longitudinalTuneKeys = {"AccelerationProfile", "DecelerationProfile"};
|
std::set<QString> longitudinalTuneKeys = {"AccelerationProfile", "DecelerationProfile", "AggressiveAcceleration"};
|
||||||
std::set<QString> mtscKeys = {};
|
std::set<QString> mtscKeys = {};
|
||||||
std::set<QString> qolKeys = {};
|
std::set<QString> qolKeys = {};
|
||||||
std::set<QString> speedLimitControllerKeys = {};
|
std::set<QString> speedLimitControllerKeys = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user