Skip to content

Commit

Permalink
Auto-distance at surface street speeds
Browse files Browse the repository at this point in the history
Override short distance setting when slow

Override distance when slow

Override distance if slow

Override distance when slow

Override distance when slow

Increase follow distance when below 60 kph

Lead car and rel. velocity to distance override

Override distance bars

revert

Override and restore dist based on speed and accel

Step up distance when < 40 km/h and restore

Revert

When using 1 bar distance:  Slow the car down earlier and more aggressively  (#18)

* Change one bar braking profile to 3 bars

* Update planner.py

* Update planner.py

* Update planner.py

* Update planner.py

* Update planner.py

* Update planner.py

* Update planner.py

* Update planner.py

* fake lead car vars

* fake lead vars

* Auto Distance Bar Working - tuning values

* Logging to log.txt

* Override hysteresis for one bar follow

* Only set override when decelerating

* syntax error fix for override flag

* Switch to 1.8s for softer braking

* Revert "Switch to 1.8s for softer braking"

This reverts commit d53623062ef814509db925fe4e624c3ae8aff1f1.

* Disable OTA update for safety
  • Loading branch information
kegman committed Dec 13, 2018
1 parent eb6926f commit 6cea358
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
11 changes: 6 additions & 5 deletions launch_chffrplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ fi

function launch {
# apply update
if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then
git reset --hard @{u} &&
git clean -xdf &&
exec "${BASH_SOURCE[0]}"
fi
#if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then
# git reset --hard @{u} &&
# git clean -xdf &&
# exec "${BASH_SOURCE[0]}"
#fi

# no cpu rationing for now
echo 0-3 > /dev/cpuset/background/cpus
Expand All @@ -24,6 +24,7 @@ function launch {
# start manager
cd selfdrive
./manager.py
#./manager.py > log.txt

# if broken, keep on screen error
while true; do sleep 1; done
Expand Down
3 changes: 2 additions & 1 deletion selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,17 @@ def update(self, cp, cp_cam):
self.pcm_acc_status = cp.vl["POWERTRAIN_DATA"]['ACC_STATUS']
self.hud_lead = cp.vl["ACC_HUD"]['HUD_LEAD']

# when user presses distance button on steering wheel
if self.cruise_setting == 3:
if cp.vl["SCM_BUTTONS"]["CRUISE_SETTING"] == 0:
self.trMode = (self.trMode + 1 ) % 3
self.prev_cruise_setting = self.cruise_setting
self.cruise_setting = cp.vl["SCM_BUTTONS"]['CRUISE_SETTING']
self.read_distance_lines = self.trMode + 1

if self.read_distance_lines <> self.read_distance_lines_prev:
self.read_distance_lines_prev = self.read_distance_lines


# carstate standalone tester
if __name__ == '__main__':
import zmq
Expand Down
20 changes: 15 additions & 5 deletions selfdrive/controls/lib/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def __init__(self, mpc_id, live_longitudinal_mpc):
self.prev_lead_x = 0.0
self.new_lead = False

self.override = False # for one bar distance at low speeds - introduce early braking and hysteresis for resume follow
self.lastTR = 2
self.last_cloudlog_t = 0.0

Expand Down Expand Up @@ -192,7 +193,8 @@ def update(self, CS, lead, v_cruise_setpoint):
self.cur_state[0].x_ego = 0.0

if lead is not None and lead.status:
x_lead = lead.dRel
#x_lead = lead.dRel
x_lead = max(0, lead.dRel - 1) # increase stopping distance to car by 1m
v_lead = max(0.0, lead.vLead)
a_lead = lead.aLeadK

Expand All @@ -214,16 +216,24 @@ def update(self, CS, lead, v_cruise_setpoint):
else:
self.prev_lead_status = False
# Fake a fast lead car, so mpc keeps running
self.cur_state[0].x_l = 50.0
self.cur_state[0].x_l = 150.0
self.cur_state[0].v_l = CS.vEgo + 10.0
a_lead = 0.0
v_lead = CS.vEgo + 10.0
x_lead = 150.0
self.a_lead_tau = _LEAD_ACCEL_TAU

# Calculate mpc
t = sec_since_boot()

if CS.vEgo < 11.4:
TR=1.8 # under 41km/hr use a TR of 1.8 seconds
# Override with 3 bar distance profile if using one bar distance - hysteresis for safety
if self.override and CS.aEgo >= 0:
self.override = False # When car starts accelerating, resume one bar distance profile

if self.override or (CS.readdistancelines == 1 and CS.vEgo < 18.06 and (v_lead - CS.vEgo) < -3 and x_lead < 100):
if CS.aEgo < -0.5:
self.override = True # If we start braking, then keep 3 bar distance profile until car starts to accelerate
TR=2.7
#if self.lastTR > 0:
#self.libmpc.init(MPC_COST_LONG.TTC, 0.1, PC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
#self.lastTR = 0
Expand Down Expand Up @@ -251,7 +261,7 @@ def update(self, CS, lead, v_cruise_setpoint):
self.lastTR = CS.readdistancelines
else:
TR=1.8 # if readdistancelines = 0
#print TR


n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, TR)
duration = int((sec_since_boot() - t) * 1e9)
Expand Down

0 comments on commit 6cea358

Please sign in to comment.