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

Development on CR-V #94

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions selfdrive/boardd/boardd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import struct
import zmq
import logging

import selfdrive.messaging as messaging
from common.realtime import Ratekeeper
Expand All @@ -22,10 +23,9 @@ def can_list_to_can_capnp(can_msgs, msgtype='can'):
dat = messaging.new_message()
dat.init(msgtype, len(can_msgs))
for i, can_msg in enumerate(can_msgs):

if msgtype == 'sendcan':
cc = dat.sendcan[i]
else:
cc = dat.can[i]
cc.address = can_msg[0]
cc.busTime = can_msg[1]
cc.dat = can_msg[2]
Expand Down
80 changes: 78 additions & 2 deletions selfdrive/car/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,84 @@
0xe4: 5, 0x1fa: 8, 0x200: 3, 0x30c: 8, 0x33d: 4,
},
"HONDA CIVIC 2016 TOURING": {
1024L: 5, 513L: 5, 1027L: 5, 1029L: 8, 777L: 8, 1036L: 8, 1039L: 8, 1424L: 5, 401L: 8, 148L: 8, 662L: 4, 985L: 3, 795L: 8, 773L: 7, 800L: 8, 545L: 6, 420L: 8, 806L: 8, 808L: 8, 1322L: 5, 427L: 3, 428L: 8, 304L: 8, 432L: 7, 57L: 3, 450L: 8, 929L: 8, 330L: 8, 1302L: 8, 464L: 8, 1361L: 5, 1108L: 8, 597L: 8, 470L: 2, 344L: 8, 804L: 8, 399L: 7, 476L: 7, 1633L: 8, 487L: 4, 892L: 8, 490L: 8, 493L: 5, 884L: 8, 891L: 8, 380L: 8, 1365L: 5,
57L: 3,
148L: 8,
199L: 4,
231L: 5,
304L: 8,
330L: 8,
344L: 8,
380L: 8,
401L: 8,
420L: 8,
423L: 2,
427L: 3,
428L: 8,
432L: 7,
441L: 5,
446L: 3,
450L: 8,
464L: 8,
467L: 2,
469L: 3,
470L: 2,
474L: 8,
476L: 7,
477L: 8,
479L: 8,
490L: 8,
493L: 5,
495L: 8,
507L: 1,
545L: 6,
597L: 8,
661L: 4,
662L: 4,
773L: 7,
777L: 8,
795L: 8,
800L: 8,
804L: 8,
806L: 8,
808L: 8,
814L: 4,
815L: 8,
817L: 4,
825L: 4,
881L: 8,
882L: 4,
884L: 8,
888L: 8,
891L: 8,
918L: 7,
929L: 8,
983L: 8,
985L: 3,
1024L: 5,
1027L: 5,
1029L: 8,
1036L: 8,
1039L: 8,
1064L: 7,
1108L: 8,
1092L: 1,
1115L: 4,
1125L: 8,
1127L: 2,
1296L: 8,
1302L: 8,
1322L: 5,
1361L: 5,
1365L: 5,
1424L: 5,
1618L: 5,
1633L: 8,
1670L: 8,
# sent messages
0xe4: 5, 0x1fa: 8, 0x200: 3, 0x30c: 8, 0x33d: 5, 0x35e: 8, 0x39f: 8,
0xe4: 5,
0x30c: 8,
0x33d: 5,
0x35e: 8,
0x39f: 8,
}
}
1 change: 0 additions & 1 deletion selfdrive/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,4 @@ def update(self, sendcan, enabled, CS, frame, final_gas, final_brake, final_stee
idx = (frame/radar_send_step) % 4
can_sends.extend(hondacan.create_radar_commands(CS.v_ego, CS.civic, idx))

sendcan.send(can_list_to_can_capnp(can_sends, msgtype='sendcan').to_bytes())

3 changes: 2 additions & 1 deletion selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def fingerprint(logcan):
break
elif len(possible_cars) == 0:
print finger
raise Exception("car doesn't match any fingerprints")

raise Exception("car doesn't match any fingerprints " + str(adr) + ' ' + str(f))

print "fingerprinted", possible_cars[0]
return brake_only, possible_cars[0]
Expand Down
50 changes: 7 additions & 43 deletions selfdrive/car/honda/hondacan.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,62 +27,26 @@ def make_can_msg(addr, dat, idx, alt):

def create_brake_command(apply_brake, pcm_override, pcm_cancel_cmd, chime, idx):
"""Creates a CAN message for the Honda DBC BRAKE_COMMAND."""
pump_on = apply_brake > 0
brakelights = apply_brake > 0
brake_rq = apply_brake > 0

pcm_fault_cmd = False
amount = struct.pack("!H", (apply_brake << 6) + pump_on)
msg = amount + struct.pack("BBB", (pcm_override << 4) |
(pcm_fault_cmd << 2) |
(pcm_cancel_cmd << 1) | brake_rq, 0x80,
brakelights << 7) + chr(chime) + "\x00"
return make_can_msg(0x1fa, msg, idx, 0)
return []

def create_gas_command(gas_amount, idx):
"""Creates a CAN message for the Honda DBC GAS_COMMAND."""
msg = struct.pack("!H", gas_amount)
return make_can_msg(0x200, msg, idx, 0)
return []

def create_steering_control(apply_steer, idx):
"""Creates a CAN message for the Honda DBC STEERING_CONTROL."""
msg = struct.pack("!h", apply_steer) + ("\x80\x00" if apply_steer != 0 else "\x00\x00")
return make_can_msg(0xe4, msg, idx, 0)
# msg = struct.pack("!h", apply_steer) + ("\x80\x00" if apply_steer != 0 else "\x00\x00")
# return make_can_msg(0xe4, msg, idx, 0)

def create_ui_commands(pcm_speed, hud, civic, idx):
"""Creates an iterable of CAN messages for the UIs."""
commands = []
pcm_speed_real = np.clip(int(round(pcm_speed / 0.002763889)), 0,
64000) # conversion factor from dbc file
msg_0x30c = struct.pack("!HBBBBB", pcm_speed_real, hud.pcm_accel,
hud.v_cruise, hud.X2, hud.car, hud.X4)
commands.append(make_can_msg(0x30c, msg_0x30c, idx, 0))

msg_0x33d = chr(hud.X5) + chr(hud.lanes) + chr(hud.beep) + chr(hud.X8)
commands.append(make_can_msg(0x33d, msg_0x33d, idx, 0))
if civic: # 2 more msgs
msg_0x35e = chr(0) * 7
commands.append(make_can_msg(0x35e, msg_0x35e, idx, 0))
msg_0x39f = (
chr(0) * 2 + chr(hud.acc_alert) + chr(0) + chr(0xff) + chr(0x7f) + chr(0)
)
commands.append(make_can_msg(0x39f, msg_0x39f, idx, 0))
# if civic: # 2 more msgs
# msg_0x35e = chr(0) * 7
# commands.append(make_can_msg(0x35e, msg_0x35e, idx, 0))
return commands

def create_radar_commands(v_ego, civic, idx):
"""Creates an iterable of CAN messages for the radar system."""
commands = []
v_ego_kph = np.clip(int(round(v_ego * CV.MS_TO_KPH)), 0, 255)
speed = struct.pack('!B', v_ego_kph)
msg_0x300 = ("\xf9" + speed + "\x8a\xd0" +\
("\x20" if idx == 0 or idx == 3 else "\x00") +\
"\x00\x00")
if civic:
msg_0x301 = "\x02\x38\x44\x32\x4f\x00\x00"
# add 8 on idx.
commands.append(make_can_msg(0x300, msg_0x300, idx + 8, 1))
else:
msg_0x301 = "\x0f\x18\x51\x02\x5a\x00\x00"
commands.append(make_can_msg(0x300, msg_0x300, idx, 1))
commands.append(make_can_msg(0x301, msg_0x301, idx, 1))
return commands
18 changes: 9 additions & 9 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ def controlsd_thread(gctx, rate=100): #rate in Hz
# reset awareness on any user action
awareness_status = 1.0

# button presses for rear view
if b.type == "leftBlinker" or b.type == "rightBlinker":
if b.pressed:
rear_view_toggle = True
else:
rear_view_toggle = False

if b.type == "altButton1" and b.pressed:
rear_view_toggle = not rear_view_toggle
# button presses for rear view
# if b.type == "leftBlinker" or b.type == "rightBlinker":
# if b.pressed:
# rear_view_toggle = True
# else:
# rear_view_toggle = False

# if b.type == "altButton1" and b.pressed:
# rear_view_toggle = not rear_view_toggle

if not VP.brake_only and enabled and not b.pressed:
if b.type == "accelCruise":
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
managed_processes = {
"uploader": "selfdrive.loggerd.uploader",
"controlsd": "selfdrive.controls.controlsd",
"radard": "selfdrive.controls.radard",
# "radard": "selfdrive.controls.radard",
"calibrationd": "selfdrive.calibrationd.calibrationd",
"loggerd": "selfdrive.loggerd.loggerd",
"logmessaged": "selfdrive.logmessaged",
Expand Down
Binary file modified selfdrive/visiond/visiond
Binary file not shown.