Skip to content

Commit

Permalink
Merge pull request #2 from commaai/devel
Browse files Browse the repository at this point in the history
New stuff
  • Loading branch information
CryptoKylan authored Sep 5, 2018
2 parents d1a54bb + 012727e commit f91c8ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def update(self, sendcan, enabled, CS, frame, actuators, \

# 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)
Expand Down
23 changes: 15 additions & 8 deletions selfdrive/car/gm/gmcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ def apply(self, c, perception_state=log.Live20Data.new_message()):
"chimeRepeated": (CM.LOW_CHIME, -1),
"chimeContinuous": (CM.LOW_CHIME, -1)}[str(c.hudControl.audibleAlert)]

self.CC.update(self.sendcan, c.enabled, self.CS, self.frame, \
# For Openpilot, "enabled" includes pre-enable.
# In GM, PCM faults out if ACC command overlaps user gas.
enabled = c.enabled and not self.CS.user_gas_pressed

self.CC.update(self.sendcan, enabled, self.CS, self.frame, \
c.actuators,
hud_v_cruise, c.hudControl.lanesVisible, \
c.hudControl.leadVisible, \
Expand Down

0 comments on commit f91c8ff

Please sign in to comment.