Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change dashboard command of GM to use packer #347

Merged
merged 2 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,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
20 changes: 13 additions & 7 deletions selfdrive/car/gm/gmcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,20 @@ 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
def create_acc_dashboard_command(packer, bus, acc_engaged, target_speed_ms, lead_car_in_sight):
target_speed = int(target_speed_ms * 208) & 0xfff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something new, but I'm confused about this unit

Copy link
Author

@vntarasov vntarasov Sep 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a bug, see a second commit. No more magic numbers.

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]

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