diff --git a/README.md b/README.md index 318302164c1051..8cafabb7989f0f 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ Community WIP Cars - [Classic Tesla Model S (pre-AP)](https://github.com/commaai/openpilot/pull/145) +- [Toyota Camry Hybrid 2018](https://github.com/commaai/openpilot/pull/195) + Directory structure ------ diff --git a/common/fingerprints.py b/common/fingerprints.py index ee10abd0383b52..da869b1b7926e7 100644 --- a/common/fingerprints.py +++ b/common/fingerprints.py @@ -13,6 +13,7 @@ class TOYOTA: RAV4 = "TOYOTA RAV4 2017" COROLLA = "TOYOTA COROLLA 2017" LEXUS_RXH = "LEXUS RX HYBRID 2017" + CAMRYH = "TOYOTA CAMRY 2018 HYBRID" _DEBUG_ADDRESS = {1880: 8} # reserved for debug purposes @@ -68,6 +69,9 @@ class TOYOTA: TOYOTA.LEXUS_RXH: [{ 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 5, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 800: 8, 810: 2, 812: 3, 814: 8, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 6, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1071: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1595: 8, 1777: 8, 1779: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1840: 8, 1848: 8, 1904: 8, 1912: 8, 1940: 8, 1941: 8, 1948: 8, 1949: 8, 1952: 8, 1956: 8, 1960: 8, 1964: 8, 1986: 8, 1990: 8, 1994: 8, 1998: 8, 2004: 8, 2012: 8 }], + TOYOTA.CAMRYH: [{ + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 983: 8, 984: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }], } # support additional internal only fingerprints diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index 78aaa36973c6fa..66d2b2b83529ae 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -162,6 +162,10 @@ static void toyota_init(int16_t param) { } static int toyota_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { + if (bus_num == 0 || bus_num == 2) { + int addr = to_fwd->RIR>>21; + return addr != 0x2E4 && addr != 0x412 ? (uint8_t)(~bus_num & 0x2) : -1; + } return -1; } diff --git a/selfdrive/car/__init__.py b/selfdrive/car/__init__.py index 3a17192b25697c..62a1486e00cf18 100644 --- a/selfdrive/car/__init__.py +++ b/selfdrive/car/__init__.py @@ -35,6 +35,7 @@ TOYOTA.RAV4H: ToyotaInterface, TOYOTA.COROLLA: ToyotaInterface, TOYOTA.LEXUS_RXH: ToyotaInterface, + TOYOTA.CAMRYH: ToyotaInterface, "simulator2": Sim2Interface, "mock": MockInterface diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 06df6e67a81e14..04f159fc3d34ed 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -8,7 +8,7 @@ def parse_gear_shifter(can_gear, car_fingerprint): # TODO: Use values from DBC to parse this field - if car_fingerprint == CAR.PRIUS: + if car_fingerprint in [CAR.PRIUS, CAR.CAMRYH]: if can_gear == 0x0: return "park" elif can_gear == 0x1: @@ -47,6 +47,8 @@ def get_can_parser(CP): dbc_f = 'toyota_corolla_2017_pt_generated.dbc' elif CP.carFingerprint == CAR.LEXUS_RXH: dbc_f = 'lexus_rx_hybrid_2017_pt_generated.dbc' + elif CP.carFingerprint == CAR.CAMRYH: + dbc_f = 'toyota_camry_hybrid_2018_pt_generated.dbc' signals = [ # sig_name, sig_address, default diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 55874788cc1619..79dd56802fa962 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -109,6 +109,14 @@ def get_params(candidate, fingerprint): ret.steerKpV, ret.steerKiV = [[0.6], [0.1]] ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 ret.steerRateCost = .8 + elif candidate == CAR.CAMRYH: + ret.safetyParam = 100 # see conversion factor for STEER_TORQUE_EPS in dbc file + ret.wheelbase = 2.82 + ret.steerRatio = 13.7 # official specs say 13.7 (L, LE) 13.8 (SE, XLE, XSE) + ret.mass = 3579./2.205 + std_cargo # using heaviest trim + ret.steerKp, ret.steerKi = 0.6, 0.1 + ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 + ret.steerRateCost = .8 ret.centerToFront = ret.wheelbase * 0.44 @@ -117,7 +125,7 @@ def get_params(candidate, fingerprint): # min speed to enable ACC. if car can do stop and go, then set enabling speed # to a negative value, so it won't matter. - if candidate in [CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH]: # rav4 hybrid can do stop and go + if candidate in [CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.CAMRYH]: # rav4 hybrid can do stop and go ret.minEnableSpeed = -1. elif candidate in [CAR.RAV4, CAR.COROLLA]: # TODO: hack ICE to do stop and go ret.minEnableSpeed = 19. * CV.MPH_TO_MS