Adds support for 2016 Honda CR-V Touring

pull/102/head
Ted Slesinski 8 years ago
parent 7fe46f1e1d
commit 7b5ee81d2d
  1. 8
      common/fingerprints.py
  2. 312
      dbcs/honda_crv_touring_2016_can.dbc
  3. 18
      selfdrive/car/honda/carcontroller.py
  4. 71
      selfdrive/car/honda/carstate.py
  5. 24
      selfdrive/car/honda/hondacan.py
  6. 4
      selfdrive/car/honda/interface.py

@ -12,6 +12,11 @@ _FINGERPRINTS = {
}, },
"HONDA ACCORD 2016 TOURING": { "HONDA ACCORD 2016 TOURING": {
1024L: 5, 929L: 8, 1027L: 5, 773L: 7, 1601L: 8, 777L: 8, 1036L: 8, 398L: 3, 1039L: 8, 401L: 8, 145L: 8, 1424L: 5, 660L: 8, 661L: 4, 918L: 7, 985L: 3, 923L: 2, 542L: 7, 927L: 8, 800L: 8, 545L: 4, 420L: 8, 422L: 8, 808L: 8, 426L: 8, 1029L: 8, 432L: 7, 57L: 3, 316L: 8, 829L: 5, 1600L: 5, 1089L: 8, 1057L: 5, 780L: 8, 1088L: 8, 464L: 8, 1108L: 8, 597L: 8, 342L: 6, 983L: 8, 344L: 8, 804L: 8, 476L: 4, 1296L: 3, 891L: 8, 1125L: 8, 487L: 4, 892L: 8, 490L: 8, 871L: 8, 1064L: 7, 882L: 2, 884L: 8, 506L: 8, 507L: 1, 380L: 8, 1365L: 5 1024L: 5, 929L: 8, 1027L: 5, 773L: 7, 1601L: 8, 777L: 8, 1036L: 8, 398L: 3, 1039L: 8, 401L: 8, 145L: 8, 1424L: 5, 660L: 8, 661L: 4, 918L: 7, 985L: 3, 923L: 2, 542L: 7, 927L: 8, 800L: 8, 545L: 4, 420L: 8, 422L: 8, 808L: 8, 426L: 8, 1029L: 8, 432L: 7, 57L: 3, 316L: 8, 829L: 5, 1600L: 5, 1089L: 8, 1057L: 5, 780L: 8, 1088L: 8, 464L: 8, 1108L: 8, 597L: 8, 342L: 6, 983L: 8, 344L: 8, 804L: 8, 476L: 4, 1296L: 3, 891L: 8, 1125L: 8, 487L: 4, 892L: 8, 490L: 8, 871L: 8, 1064L: 7, 882L: 2, 884L: 8, 506L: 8, 507L: 1, 380L: 8, 1365L: 5
},
"HONDA CR-V 2016 TOURING": {
57L: 3, 145L: 8, 316L: 8, 340L: 8, 342L: 6, 344L: 8, 380L: 8, 398L: 3, 399L: 6, 401L: 8, 420L: 8, 422L: 8, 426L: 8, 432L: 7, 464L: 8, 474L: 5, 476L: 4, 487L: 4, 490L: 8, 493L: 3, 507L: 1, 542L: 7, 545L: 4, 597L: 8, 660L: 8, 661L: 4, 773L: 7, 777L: 8, 800L: 8, 804L: 8, 808L: 8, 882L: 2, 884L: 7, 888L: 8, 891L: 8, 892L: 8, 923L: 2, 929L: 8, 983L: 8, 985L: 3, 1024L: 5, 1027L: 5, 1029L: 8, 1033L: 5, 1036L: 8, 1039L: 8, 1057L: 5, 1064L: 7, 1108L: 8, 1125L: 8, 1296L: 8, 1365L: 5, 1424L: 5, 1600L: 5, 1601L: 8,
# sent messages
0x194: 4, 0x1fa: 8, 0x30c: 8, 0x33d: 5,
} }
} }
@ -121,8 +126,9 @@ def fingerprint(logcan):
ret.steerKp, ret.steerKi = 12.0, 1.0 ret.steerKp, ret.steerKi = 12.0, 1.0
elif candidate_cars[0] == "HONDA ACCORD 2016 TOURING": elif candidate_cars[0] == "HONDA ACCORD 2016 TOURING":
ret.steerKp, ret.steerKi = 12.0, 1.0 ret.steerKp, ret.steerKi = 12.0, 1.0
elif candidate_cars[0] == "HONDA CR-V 2016 TOURING":
ret.steerKp, ret.steerKi = 12.0, 1.0
else: else:
raise ValueError("unsupported car %s" % candidate_cars[0]) raise ValueError("unsupported car %s" % candidate_cars[0])
return ret return ret

@ -0,0 +1,312 @@
VERSION ""
NS_ :
NS_DESC_
CM_
BA_DEF_
BA_
VAL_
CAT_DEF_
CAT_
FILTER
BA_DEF_DEF_
EV_DATA_
ENVVAR_DATA_
SGTYPE_
SGTYPE_VAL_
BA_DEF_SGTYPE_
BA_SGTYPE_
SIG_TYPE_REF_
VAL_TABLE_
SIG_GROUP_
SIG_VALTYPE_
SIGTYPE_VALTYPE_
BO_TX_BU_
BA_DEF_REL_
BA_REL_
BA_DEF_DEF_REL_
BU_SG_REL_
BU_EV_REL_
BU_BO_REL_
SG_MUL_VAL_
BS_:
BU_: INTERCEPTOR EBCM NEO CAM PCM EPS VSA SCM BDY XXX EPB
BO_ 57 XXX_1: 3 XXX
BO_ 145 XXX_2: 8 XXX
BO_ 316 XXX_3: 8 PCM
BO_ 340 XXX_4: 8 PCM
BO_ 342 STEERING_SENSORS: 6 EPS
SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" NEO
SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" NEO
SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" NEO
BO_ 344 POWERTRAIN_DATA: 8 PCM
SG_ XMISSION_SPEED : 7|16@0+ (0.002759506,0) [0|70] "m/s" NEO
SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" NEO
SG_ XMISSION_SPEED2 : 39|16@0+ (0.002759506,0) [0|70] "m/s" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 380 POWERTRAIN_DATA2: 8 PCM
SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" NEO
SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" NEO
SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" NEO
SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" NEO
SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" NEO
SG_ BRAKE_LIGHTS_ON : 32|1@0+ (1,0) [0|1] "rpm" NEO
SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" NEO
SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" NEO
SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 398 XXX_5: 3 PCM
BO_ 399 STEER_STATUS: 6 EPS
SG_ STEER_TORQUE_SENSOR : 7|12@0- (1,0) [-2047.5|2047.5] "tbd" NEO
SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" NEO
SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" NEO
SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" NEO
SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" NEO
BO_ 401 GEARBOX: 8 PCM
SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" NEO
SG_ GEAR : 35|4@0+ (1,0) [0|15] "" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 404 STEERING_CONTROL: 4 NEO
SG_ STEER_TORQUE : 7|16@0- (1,0) [-2047.5|2047.5] "" EPS
SG_ SET_ME_X00 : 11|4@0+ (1,0) [0|15] "" EPS
SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS
SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS
SG_ CHECKSUM : 29|2@0+ (1,0) [0|3] "" EPS
SG_ COUNTER : 27|4@0+ (1,0) [0|15] "" EPS
BO_ 420 VSA_STATUS: 8 VSA
SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" NEO
SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 422 SCM_BUTTONS: 8 SCM
SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" NEO
SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" NEO
SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" NEO
SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 426 XXX_6: 8 VSA
BO_ 432 STANDSTILL: 7 VSA
SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" NEO
SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" NEO
SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" NEO
SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" NEO
BO_ 464 WHEEL_SPEEDS: 8 VSA
SG_ WHEEL_SPEED_FL : 7|15@0+ (0.002759506,0) [0|70] "m/s" NEO
SG_ WHEEL_SPEED_FR : 8|15@0+ (0.002759506,0) [0|70] "m/s" NEO
SG_ WHEEL_SPEED_RL : 25|15@0+ (0.002759506,0) [0|70] "m/s" NEO
SG_ WHEEL_SPEED_RR : 42|15@0+ (0.002759506,0) [0|70] "m/s" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 474 XXX_7: 5 VSA
BO_ 476 XXX_8: 5 XXX
BO_ 487 XXX_9: 4 VSA
SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" NEO
SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" NEO
SG_ CHECKSUM : 29|2@0+ (1,0) [0|3] "" NEO
SG_ COUNTER : 27|4@0+ (1,0) [0|15] "" NEO
BO_ 490 VEHICLE_DYNAMICS: 8 VSA
SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 493 XXX_10: 3 VSA
BO_ 506 BRAKE_COMMAND: 8 NEO
SG_ COMPUTER_BRAKE : 7|10@0+ (0.003906248,0) [0|1] "" EBCM
SG_ ZEROS_BOH : 13|5@0+ (1,0) [0|1] "" EBCM
SG_ COMPUTER_BRAKE_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM
SG_ CRUISE_BOH2 : 23|3@0+ (1,0) [0|1] "" EBCM
SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM
SG_ CRUISE_BOH3 : 19|1@0+ (1,0) [0|1] "" EBCM
SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM
SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM
SG_ COMPUTER_BRAKE_REQUEST_2 : 16|1@0+ (1,0) [0|1] "" EBCM
SG_ SET_ME_0X80 : 31|8@0+ (1,0) [0|1] "" EBCM
SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM
SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM
SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM
SG_ ZEROS_BOH6 : 44|1@0+ (1,0) [0|1] "" EBCM
SG_ FCW : 43|1@0+ (1,0) [0|3] "" EBCM
SG_ ZEROS_BOH3 : 42|2@0+ (1,0) [0|0] "" EBCM
SG_ FCW2 : 40|1@0+ (1,0) [0|0] "" EBCM
SG_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|0] "" EBCM
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM
BO_ 507 XXX_11: 1 NEO
BO_ 542 XXX_12: 7 XXX
BO_ 545 XXX_13: 4 XXX
BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA
SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" NEO
SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" NEO
SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" NEO
SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" NEO
SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" NEO
SG_ SET_TO_X55 : 47|8@0+ (1,0) [0|255] "" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 660 SCM_COMMANDS: 8 SCM
SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" NEO
SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" NEO
SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 661 XXX_14: 4 XXX
BO_ 773 SEATBELT_STATUS: 7 BDY
SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" NEO
SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" NEO
SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" NEO
BO_ 777 XXX_15: 8 XXX
BO_ 780 ACC_HUD: 8 CAM
SG_ PCM_SPEED : 7|16@0+ (0.002759506,0) [0|100] "m/s" BDY
SG_ PCM_GAS : 23|7@0+ (1,0) [0|127] "" BDY
SG_ ZEROS_BOH : 16|1@0+ (1,0) [0|255] "" BDY
SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY
SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY
SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY
SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY
BO_ 800 XXX_16: 8 XXX
BO_ 804 CRUISE: 8 PCM
SG_ ENGINE_TEMPERATURE : 7|8@0+ (1,0) [0|255] "" NEO
SG_ BOH : 15|8@0+ (1,0) [0|255] "" NEO
SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" NEO
SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" NEO
SG_ BOH2 : 47|8@0- (1,0) [0|255] "" NEO
SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 808 XXX_17: 8 XXX
BO_ 829 LKAS_HUD_2: 5 CAM
SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY
SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY
SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY
SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY
SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY
SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY
SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY
SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY
SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY
SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY
SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY
SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY
SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY
SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY
SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY
SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY
BO_ 882 XXX_18: 2 XXX
BO_ 884 XXX_19: 7 XXX
BO_ 888 XXX_20: 8 XXX
BO_ 891 XXX_21: 8 XXX
BO_ 892 XXX_22: 8 XXX
BO_ 923 XXX_23: 2 XXX
BO_ 929 XXX_24: 8 XXX
BO_ 983 XXX_25: 8 XXX
BO_ 985 XXX_26: 3 XXX
BO_ 1024 XXX_27: 5 XXX
BO_ 1027 XXX_28: 5 XXX
BO_ 1029 DOORS_STATUS: 8 BDY
SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" NEO
SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" NEO
SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" NEO
SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" NEO
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" NEO
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" NEO
BO_ 1033 XXX_29: 5 XXX
BO_ 1036 XXX_30: 8 XXX
BO_ 1039 XXX_31: 8 XXX
BO_ 1057 XXX_32: 5 XXX
BO_ 1064 XXX_32: 7 XXX
BO_ 1108 XXX_33: 8 XXX
BO_ 1125 XXX_34: 8 XXX
BO_ 1296 XXX_35: 8 XXX
BO_ 1365 XXX_36: 5 XXX
BO_ 1424 XXX_37: 5 XXX
BO_ 1600 XXX_38: 5 XXX
BO_ 1601 XXX_39: 8 XXX
BO_TX_BU_ 399 : NEO,CAM;
BO_TX_BU_ 506 : NEO,CAM;
BO_TX_BU_ 780 : NEO,CAM;
BO_TX_BU_ 829 : NEO,CAM;

@ -146,7 +146,11 @@ class CarController(object):
# steer torque is converted back to CAN reference (positive when steering right) # steer torque is converted back to CAN reference (positive when steering right)
apply_gas = int(clip(final_gas*GAS_MAX, 0, GAS_MAX-1)) apply_gas = int(clip(final_gas*GAS_MAX, 0, GAS_MAX-1))
apply_brake = int(clip(final_brake*BRAKE_MAX, 0, BRAKE_MAX-1)) apply_brake = int(clip(final_brake*BRAKE_MAX, 0, BRAKE_MAX-1))
apply_steer = int(clip(-final_steer*STEER_MAX, -STEER_MAX, STEER_MAX)) # crvtodo: tweak steering to match precision of 0xE4 code.
if CS.crv
apply_steer = int(clip((-final_steer*.996)*0x7F0, -0x7F0, 0x7F0))
else:
apply_steer = int(clip(-final_steer*STEER_MAX, -STEER_MAX, STEER_MAX))
# no gas if you are hitting the brake or the user is # no gas if you are hitting the brake or the user is
if apply_gas > 0 and (apply_brake != 0 or CS.brake_pressed): if apply_gas > 0 and (apply_brake != 0 or CS.brake_pressed):
@ -180,7 +184,8 @@ class CarController(object):
print "STEER ERROR" print "STEER ERROR"
self.controls_allowed = False self.controls_allowed = False
if CS.brake_error: # crvtodo, fix brake error, might be issue with dbc.
if CS.brake_error and not CS.crv:
print "BRAKE ERROR" print "BRAKE ERROR"
self.controls_allowed = False self.controls_allowed = False
@ -197,7 +202,7 @@ class CarController(object):
can_sends.append(hondacan.create_accord_steering_control(apply_steer, idx)) can_sends.append(hondacan.create_accord_steering_control(apply_steer, idx))
else: else:
idx = frame % 4 idx = frame % 4
can_sends.append(hondacan.create_steering_control(apply_steer, idx)) can_sends.extend(hondacan.create_steering_control(apply_steer, CS.crv, idx))
# Send gas and brake commands. # Send gas and brake commands.
if (frame % 2) == 0: if (frame % 2) == 0:
@ -214,17 +219,16 @@ class CarController(object):
# Send dashboard UI commands. # Send dashboard UI commands.
if (frame % 10) == 0: if (frame % 10) == 0:
idx = (frame/10) % 4 idx = (frame/10) % 4
can_sends.extend(hondacan.create_ui_commands(pcm_speed, hud, CS.civic, CS.accord, idx)) can_sends.extend(hondacan.create_ui_commands(pcm_speed, hud, CS.civic, CS.accord, CS.crv, idx))
# radar at 20Hz, but these msgs need to be sent at 50Hz on ilx (seems like an Acura bug) # radar at 20Hz, but these msgs need to be sent at 50Hz on ilx (seems like an Acura bug)
if CS.civic or CS.accord: if CS.civic or CS.accord or CS.crv:
radar_send_step = 5 radar_send_step = 5
else: else:
radar_send_step = 2 radar_send_step = 2
if (frame % radar_send_step) == 0: if (frame % radar_send_step) == 0:
idx = (frame/radar_send_step) % 4 idx = (frame/radar_send_step) % 4
can_sends.extend(hondacan.create_radar_commands(CS.v_ego, CS.civic, CS.accord, idx)) can_sends.extend(hondacan.create_radar_commands(CS.v_ego, CS.civic, CS.accord, CS.crv, idx))
sendcan.send(can_list_to_can_capnp(can_sends, msgtype='sendcan').to_bytes()) sendcan.send(can_list_to_can_capnp(can_sends, msgtype='sendcan').to_bytes())

@ -162,7 +162,58 @@ def get_can_parser(CP):
(0x324, 10), (0x324, 10),
(0x405, 3), (0x405, 3),
] ]
elif CP.carFingerprint == "HONDA CR-V 2016 TOURING":
dbc_f = 'honda_crv_touring_2016_can.dbc'
signals = [
("XMISSION_SPEED", 0x158, 0),
("WHEEL_SPEED_FL", 0x1d0, 0),
("WHEEL_SPEED_FR", 0x1d0, 0),
("WHEEL_SPEED_RL", 0x1d0, 0),
("STEER_ANGLE", 0x156, 0),
("STEER_TORQUE_SENSOR", 0x18f, 0),
("GEAR", 0x191, 0),
("WHEELS_MOVING", 0x1b0, 1),
("DOOR_OPEN_FL", 0x405, 1),
("DOOR_OPEN_FR", 0x405, 1),
("DOOR_OPEN_RL", 0x405, 1),
("DOOR_OPEN_RR", 0x405, 1),
("CRUISE_SPEED_PCM", 0x324, 0),
("SEATBELT_DRIVER_LAMP", 0x305, 1),
("SEATBELT_DRIVER_LATCHED", 0x305, 0),
("BRAKE_PRESSED", 0x17c, 0),
#("CAR_GAS", 0x130, 0),
("CRUISE_BUTTONS", 0x1a6, 0),
("ESP_DISABLED", 0x1a4, 1),
("HUD_LEAD", 0x30c, 0),
("USER_BRAKE", 0x1a4, 0),
("STEER_STATUS", 0x18f, 5),
("WHEEL_SPEED_RR", 0x1d0, 0),
("BRAKE_ERROR_1", 0x1b0, 1),
("BRAKE_ERROR_2", 0x1b0, 1),
("GEAR_SHIFTER", 0x191, 0),
("MAIN_ON", 0x1a6, 0),
("ACC_STATUS", 0x17c, 0),
("PEDAL_GAS", 0x17c, 0),
("CRUISE_SETTING", 0x1a6, 0),
("LEFT_BLINKER", 0x294, 0),
("RIGHT_BLINKER", 0x294, 0),
("COUNTER", 0x324, 0),
("ENGINE_RPM", 0x17C, 0)
]
checks = [
(0x156, 100),
(0x158, 100),
(0x17c, 100),
(0x191, 100),
(0x1a3, 50),
(0x1a4, 50),
(0x1a6, 50),
(0x1b0, 50),
(0x1d0, 50),
(0x305, 10),
(0x324, 10),
(0x405, 3),
]
# add gas interceptor reading if we are using it # add gas interceptor reading if we are using it
if CP.enableGas: if CP.enableGas:
signals.append(("INTERCEPTOR_GAS", 0x201, 0)) signals.append(("INTERCEPTOR_GAS", 0x201, 0))
@ -181,6 +232,8 @@ class CarState(object):
elif CP.carFingerprint == "HONDA ACCORD 2016 TOURING": elif CP.carFingerprint == "HONDA ACCORD 2016 TOURING":
# fake civic # fake civic
self.accord = True self.accord = True
elif CP.carFingerprint == "HONDA CR-V 2016 TOURING":
self.crv = True
else: else:
raise ValueError("unsupported car %s" % CP.carFingerprint) raise ValueError("unsupported car %s" % CP.carFingerprint)
@ -278,6 +331,17 @@ class CarState(object):
self.blinker_on = cp.vl[0x294]['LEFT_BLINKER'] or cp.vl[0x294]['RIGHT_BLINKER'] self.blinker_on = cp.vl[0x294]['LEFT_BLINKER'] or cp.vl[0x294]['RIGHT_BLINKER']
self.left_blinker_on = cp.vl[0x294]['LEFT_BLINKER'] self.left_blinker_on = cp.vl[0x294]['LEFT_BLINKER']
self.right_blinker_on = cp.vl[0x294]['RIGHT_BLINKER'] self.right_blinker_on = cp.vl[0x294]['RIGHT_BLINKER']
elif self.crv:
self.gear_shifter = cp.vl[0x191]['GEAR_SHIFTER']
self.angle_steers = cp.vl[0x156]['STEER_ANGLE']
self.gear = cp.vl[0x191]['GEAR']
self.cruise_setting = cp.vl[0x1A6]['CRUISE_SETTING']
self.cruise_buttons = cp.vl[0x1A6]['CRUISE_BUTTONS']
self.main_on = cp.vl[0x1A6]['MAIN_ON']
self.gear_shifter_valid = self.gear_shifter in [1,4] # TODO: 1/P allowed for debug
self.blinker_on = cp.vl[0x294]['LEFT_BLINKER'] or cp.vl[0x294]['RIGHT_BLINKER']
self.left_blinker_on = cp.vl[0x294]['LEFT_BLINKER']
self.right_blinker_on = cp.vl[0x294]['RIGHT_BLINKER']
else: else:
self.gear_shifter = cp.vl[0x1A3]['GEAR_SHIFTER'] self.gear_shifter = cp.vl[0x1A3]['GEAR_SHIFTER']
self.angle_steers = cp.vl[0x156]['STEER_ANGLE'] self.angle_steers = cp.vl[0x156]['STEER_ANGLE']
@ -293,6 +357,10 @@ class CarState(object):
# on the accord, this doesn't seem to include cruise control # on the accord, this doesn't seem to include cruise control
self.car_gas = cp.vl[0x17C]['PEDAL_GAS'] self.car_gas = cp.vl[0x17C]['PEDAL_GAS']
self.steer_override = False self.steer_override = False
elif self.crv:
# like accord, crv doesn't include cruise control
self.car_gas = cp.vl[0x17C]['PEDAL_GAS']
self.steer_override = abs(cp.vl[0x18F]['STEER_TORQUE_SENSOR']) > 1200
else: else:
self.car_gas = cp.vl[0x130]['CAR_GAS'] self.car_gas = cp.vl[0x130]['CAR_GAS']
self.steer_override = abs(cp.vl[0x18F]['STEER_TORQUE_SENSOR']) > 1200 self.steer_override = abs(cp.vl[0x18F]['STEER_TORQUE_SENSOR']) > 1200
@ -304,4 +372,3 @@ class CarState(object):
self.pedal_gas = cp.vl[0x17C]['PEDAL_GAS'] self.pedal_gas = cp.vl[0x17C]['PEDAL_GAS']
self.hud_lead = cp.vl[0x30C]['HUD_LEAD'] self.hud_lead = cp.vl[0x30C]['HUD_LEAD']
self.counter_pcm = cp.vl[0x324]['COUNTER'] self.counter_pcm = cp.vl[0x324]['COUNTER']

@ -68,12 +68,18 @@ def create_accord_steering_control(apply_steer, idx):
return [0,0,dat,8] return [0,0,dat,8]
def create_steering_control(apply_steer, idx): def create_steering_control(apply_steer, crv, idx):
"""Creates a CAN message for the Honda DBC STEERING_CONTROL.""" """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") commands = []
return make_can_msg(0xe4, msg, idx, 0) if crv:
msg_0x194 = struct.pack("!h", apply_steer << 4) + ("\x80" if apply_steer != 0 else "\x00")
commands.append(make_can_msg(0x194, msg_0x194, idx, 0))
else:
msg_0xe4 = struct.pack("!h", apply_steer) + ("\x80\x00" if apply_steer != 0 else "\x00\x00")
commands.append(make_can_msg(0xe4, msg_0xe4, idx, 0))
return commands
def create_ui_commands(pcm_speed, hud, civic, accord, idx): def create_ui_commands(pcm_speed, hud, civic, accord, crv, idx):
"""Creates an iterable of CAN messages for the UIs.""" """Creates an iterable of CAN messages for the UIs."""
commands = [] commands = []
pcm_speed_real = np.clip(int(round(pcm_speed / 0.002759506)), 0, pcm_speed_real = np.clip(int(round(pcm_speed / 0.002759506)), 0,
@ -94,14 +100,15 @@ def create_ui_commands(pcm_speed, hud, civic, accord, idx):
commands.append(make_can_msg(0x39f, msg_0x39f, idx, 0)) commands.append(make_can_msg(0x39f, msg_0x39f, idx, 0))
return commands return commands
def create_radar_commands(v_ego, civic, accord, idx): def create_radar_commands(v_ego, civic, accord, crv, idx):
"""Creates an iterable of CAN messages for the radar system.""" """Creates an iterable of CAN messages for the radar system."""
commands = [] commands = []
v_ego_kph = np.clip(int(round(v_ego * CV.MS_TO_KPH)), 0, 255) v_ego_kph = np.clip(int(round(v_ego * CV.MS_TO_KPH)), 0, 255)
speed = struct.pack('!B', v_ego_kph) speed = struct.pack('!B', v_ego_kph)
msg_0x300 = ("\xf9" + speed + "\x8a\xd0" +\ msg_0x300 = ("\xf9" + speed + "\x8a\xd0" +\
("\x20" if idx == 0 or idx == 3 else "\x00") +\ ("\x20" if idx == 0 or idx == 3 else "\x00") +\
"\x00\x00") "\x00\x00")
if civic: if civic:
msg_0x301 = "\x02\x38\x44\x32\x4f\x00\x00" msg_0x301 = "\x02\x38\x44\x32\x4f\x00\x00"
# add 8 on idx. # add 8 on idx.
@ -112,6 +119,9 @@ def create_radar_commands(v_ego, civic, accord, idx):
msg_0x301 = "\x0e\xd8\x52\x22\x56\x00\x00" msg_0x301 = "\x0e\xd8\x52\x22\x56\x00\x00"
# add 0xc on idx? WTF is this? # add 0xc on idx? WTF is this?
commands.append(make_can_msg(0x300, msg_0x300, idx + 0xc, 1)) commands.append(make_can_msg(0x300, msg_0x300, idx + 0xc, 1))
elif crv:
msg_0x301 = "\x00\x00\x50\x02\x51\x00\x00"
commands.append(make_can_msg(0x300, msg_0x300, idx, 1))
else: else:
msg_0x301 = "\x0f\x18\x51\x02\x5a\x00\x00" msg_0x301 = "\x0f\x18\x51\x02\x5a\x00\x00"
commands.append(make_can_msg(0x300, msg_0x300, idx, 1)) commands.append(make_can_msg(0x300, msg_0x300, idx, 1))

@ -181,7 +181,8 @@ class CarInterface(object):
errors.append('steerTemporarilyUnavailable') errors.append('steerTemporarilyUnavailable')
if self.CS.brake_error: if self.CS.brake_error:
errors.append('brakeUnavailable') errors.append('brakeUnavailable')
if not self.CS.gear_shifter_valid: # crvtodo: fix gearbox read.
if not self.CS.gear_shifter_valid and not self.CS.crv:
errors.append('wrongGear') errors.append('wrongGear')
if not self.CS.door_all_closed: if not self.CS.door_all_closed:
errors.append('doorOpen') errors.append('doorOpen')
@ -246,4 +247,3 @@ class CarInterface(object):
self.frame += 1 self.frame += 1
return not (c.enabled and not self.CC.controls_allowed) return not (c.enabled and not self.CC.controls_allowed)

Loading…
Cancel
Save