mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-01 03:22:07 +08:00
Change dashboard command of GM to use packer (#347)
* Change dashboard command of GM to use packer
Also, separate "follow distance" from "engaged".
* Fix dashboard setSpeed scaling
old-commit-hash: 012727ef60
This commit is contained in:
@@ -137,7 +137,7 @@ class CarController(object):
|
||||
|
||||
# Send dashboard UI commands (ACC status), 25hz
|
||||
if (frame % 4) == 0:
|
||||
can_sends.append(gmcan.create_acc_dashboard_command(canbus.powertrain, enabled, hud_v_cruise / CV.MS_TO_KPH, hud_show_car))
|
||||
can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, canbus.powertrain, enabled, hud_v_cruise * CV.MS_TO_KPH, hud_show_car))
|
||||
|
||||
# Radar needs to know current speed and yaw rate (50hz),
|
||||
# and that ADAS is alive (10hz)
|
||||
|
||||
@@ -84,14 +84,21 @@ def create_friction_brake_command(packer, bus, apply_brake, idx, near_stop, at_f
|
||||
|
||||
return packer.make_can_msg("EBCMFrictionBrakeCmd", bus, values)
|
||||
|
||||
def create_acc_dashboard_command(bus, acc_engaged, target_speed_ms, lead_car_in_sight):
|
||||
engaged = 0x90 if acc_engaged else 0
|
||||
lead_car = 0x10 if lead_car_in_sight else 0
|
||||
target_speed = int(target_speed_ms * 208) & 0xfff
|
||||
speed_high = target_speed >> 8
|
||||
speed_low = target_speed & 0xff
|
||||
dat = [0x01, 0x00, engaged | speed_high, speed_low, 0x01, lead_car]
|
||||
return [0x370, 0, "".join(map(chr, dat)), bus]
|
||||
def create_acc_dashboard_command(packer, bus, acc_engaged, target_speed_kph, lead_car_in_sight):
|
||||
# Not a bit shift, dash can round up based on low 4 bits.
|
||||
target_speed = int(target_speed_kph * 16) & 0xfff
|
||||
|
||||
values = {
|
||||
"ACCAlwaysOne" : 1,
|
||||
"ACCResumeButton" : 0,
|
||||
"ACCSpeedSetpoint" : target_speed,
|
||||
"ACCGapLevel" : 3 * acc_engaged, # 3 "far", 0 "inactive"
|
||||
"ACCCmdActive" : acc_engaged,
|
||||
"ACCAlwaysOne2" : 1,
|
||||
"ACCLeadCar" : lead_car_in_sight
|
||||
}
|
||||
|
||||
return packer.make_can_msg("ASCMActiveCruiseControlStatus", bus, values)
|
||||
|
||||
def create_adas_time_status(bus, tt, idx):
|
||||
dat = [(tt >> 20) & 0xff, (tt >> 12) & 0xff, (tt >> 4) & 0xff,
|
||||
|
||||
Reference in New Issue
Block a user