openpilot v0.4.2 release

old-commit-hash: 28c0797d30
commatwo_master v0.4.2
Vehicle Researcher 7 years ago
parent 88e1b9aa7f
commit 4e867831f7
  1. 9
      README.md
  2. 9
      RELEASES.md
  3. 4
      SAFETY.md
  4. 2
      common/dbc.py
  5. 8
      common/fingerprints.py
  6. 1
      common/kalman/ekf.py
  7. 2
      common/params.py
  8. 1
      common/realtime.py
  9. 16
      selfdrive/boardd/boardd.cc
  10. 2
      selfdrive/can/common.h
  11. 5
      selfdrive/can/libdbc_py.py
  12. 77
      selfdrive/can/packer.cc
  13. 30
      selfdrive/can/packer.py
  14. 42
      selfdrive/can/parser.cc
  15. 9
      selfdrive/can/parser.py
  16. 17
      selfdrive/can/process_dbc.py
  17. 5
      selfdrive/car/__init__.py
  18. 4
      selfdrive/car/honda/carcontroller.py
  19. 8
      selfdrive/car/honda/carstate.py
  20. 4
      selfdrive/car/honda/interface.py
  21. 1
      selfdrive/car/honda/radar_interface.py
  22. 6
      selfdrive/car/mock/interface.py
  23. 7
      selfdrive/car/toyota/carcontroller.py
  24. 6
      selfdrive/car/toyota/carstate.py
  25. 38
      selfdrive/car/toyota/interface.py
  26. 4
      selfdrive/car/toyota/radar_interface.py
  27. 2
      selfdrive/car/toyota/toyotacan.py
  28. 74
      selfdrive/car/toyota/values.py
  29. 2
      selfdrive/common/version.h
  30. 2
      selfdrive/controls/controlsd.py
  31. 2
      selfdrive/controls/lib/latcontrol.py
  32. 2
      selfdrive/controls/lib/longcontrol.py
  33. 1
      selfdrive/controls/lib/planner.py
  34. 1
      selfdrive/controls/lib/radar_helpers.py
  35. 4
      selfdrive/controls/radard.py
  36. 1
      selfdrive/debug/can_printer.py
  37. 3
      selfdrive/debug/get_fingerprint.py
  38. 2
      selfdrive/debug/getframes/getframes.py
  39. 92
      selfdrive/debug/test_carcontroller.py
  40. 52
      selfdrive/debug/test_carstate.py
  41. 2
      selfdrive/loggerd/loggerd
  42. 20
      selfdrive/manager.py
  43. 1
      selfdrive/registration.py
  44. 2
      selfdrive/sensord/gpsd
  45. 2
      selfdrive/sensord/sensord
  46. 3
      selfdrive/test/plant/maneuver.py
  47. 2
      selfdrive/test/plant/maneuverplots.py
  48. 11
      selfdrive/test/plant/plant.py
  49. 1
      selfdrive/test/test_openpilot.py
  50. 2
      selfdrive/visiond/visiond

@ -52,11 +52,18 @@ Supported Cars
- By default it uses stock Toyota ACC for longitudinal control - By default it uses stock Toyota ACC for longitudinal control
- openpilot longitudinal control available after unplugging the [Driving Support ECU](https://community.comma.ai/wiki/index.php/Toyota#Corolla_.28for_openpilot.29) and can be enabled above 20 mph - openpilot longitudinal control available after unplugging the [Driving Support ECU](https://community.comma.ai/wiki/index.php/Toyota#Corolla_.28for_openpilot.29) and can be enabled above 20 mph
- Lexus RX 2017 hybrid (alpha!)
- By default it uses stock Lexus ACC for longitudinal control
- openpilot longitudinal control available after unplugging the [Driving Support ECU](https://community.comma.ai/wiki/index.php/Toyota#Lexus_RX_hybrid)
In Progress Cars In Progress Cars
------ ------
- Probably all TSS-P Toyota with Steering Assist. - All TSS-P Toyota with Steering Assist.
- 'Full Speed Range Dynamic Radar Cruise Control' is required to enable stop-and-go. Only the Prius, Camry and C-HR have this option. - 'Full Speed Range Dynamic Radar Cruise Control' is required to enable stop-and-go. Only the Prius, Camry and C-HR have this option.
- Even though the Tundra, Sequoia and the Land Cruiser have TSS-P, they don't have Steering Assist and are not supported. - Even though the Tundra, Sequoia and the Land Cruiser have TSS-P, they don't have Steering Assist and are not supported.
- All LSS-P Lexus with Steering Assist or Lane Keep Assist.
- 'All-Speed Range Dynamic Radar Cruise Control' is required to enable stop-and-go. Only the GS, GSH, GS, F, RX, RXH, LX, NX, NXH, LC, LCH, LS, LSH have this option.
- Even though the LX have TSS-P, it does not have Steering Assist and is not supported.
Community WIP Cars Community WIP Cars
------ ------

@ -1,8 +1,17 @@
Version 0.4.2 (2018-02-05)
==========================
* Add alpha support for 2017 Lexus RX Hybrid
* Add alpha support for 2018 ACURA RDX
* Updated fingerprint to include Toyota Rav4 SE and Prius Prime
* Bugfixes for Acura ILX and Honda Odyssey
Version 0.4.1 (2018-01-30) Version 0.4.1 (2018-01-30)
========================== ==========================
* Add alpha support for 2017 Toyota Corolla * Add alpha support for 2017 Toyota Corolla
* Add alpha support for 2018 Honda Odyssey with Honda Sensing
* Add alpha support for Grey Panda * Add alpha support for Grey Panda
* Refactored car abstraction layer to make car ports easier * Refactored car abstraction layer to make car ports easier
* Increased steering torque limit on Honda CR-V by 30%
Version 0.4.0.2 (2018-01-18) Version 0.4.0.2 (2018-01-18)
========================== ==========================

@ -42,7 +42,7 @@ Honda/Acura
- Honda CAN uses both a counter and a checksum to ensure integrity and prevent - Honda CAN uses both a counter and a checksum to ensure integrity and prevent
replay of the same message. replay of the same message.
Toyota Toyota/Lexus
------ ------
- While the system is engaged, gas, brake and steer limits are subject to the same limits used by - While the system is engaged, gas, brake and steer limits are subject to the same limits used by
@ -59,7 +59,7 @@ Toyota
software to a value of -1500 and 1500. In addition, the vehicle EPS unit will not respond to software to a value of -1500 and 1500. In addition, the vehicle EPS unit will not respond to
commands outside these limits. A steering torque rate limit is enforced by the board and in commands outside these limits. A steering torque rate limit is enforced by the board and in
software so that the commanded steering torque must rise from 0 to max value no faster than software so that the commanded steering torque must rise from 0 to max value no faster than
1.5s. Commanded steering torque is limited by the board and in software to be no more than 500 1.5s. Commanded steering torque is limited by the board and in software to be no more than 350
units above the actual EPS generated motor torque to ensure limited differences between units above the actual EPS generated motor torque to ensure limited differences between
commanded and actual torques. commanded and actual torques.

@ -214,8 +214,6 @@ class dbc(object):
return [sgs.name for sgs in self.msgs[msg][1]] return [sgs.name for sgs in self.msgs[msg][1]]
if __name__ == "__main__": if __name__ == "__main__":
import sys
import os
from opendbc import DBC_PATH from opendbc import DBC_PATH
dbc_test = dbc(os.path.join(DBC_PATH, sys.argv[1])) dbc_test = dbc(os.path.join(DBC_PATH, sys.argv[1]))

@ -11,6 +11,7 @@ class TOYOTA:
RAV4H = "TOYOTA RAV4 2017 HYBRID" RAV4H = "TOYOTA RAV4 2017 HYBRID"
RAV4 = "TOYOTA RAV4 2017" RAV4 = "TOYOTA RAV4 2017"
COROLLA = "TOYOTA COROLLA 2017" COROLLA = "TOYOTA COROLLA 2017"
LEXUS_RXH = "LEXUS RX HYBRID 2017"
_FINGERPRINTS = { _FINGERPRINTS = {
@ -36,10 +37,10 @@ _FINGERPRINTS = {
57L: 3, 148L: 8, 228L: 5, 229L: 4, 316L: 8, 342L: 6, 344L: 8, 380L: 8, 399L: 7, 411L: 5, 419L: 8, 420L: 8, 427L: 3, 432L: 7, 450L: 8, 463L: 8, 464L: 8, 476L: 4, 490L: 8, 506L: 8, 542L: 7, 545L: 6, 597L: 8, 662L: 4, 773L: 7, 777L: 8, 780L: 8, 795L: 8, 800L: 8, 804L: 8, 806L: 8, 808L: 8, 817L: 4, 819L: 7, 821L: 5, 825L: 4, 829L: 5, 837L: 5, 856L: 7, 862L: 8, 871L: 8, 881L: 8, 882L: 4, 884L: 8, 891L: 8, 892L: 8, 905L: 8, 923L: 2, 927L: 8, 929L: 8, 963L: 8, 965L: 8, 966L: 8, 967L: 8, 983L: 8, 985L: 3, 1029L: 8, 1036L: 8, 1052L: 8, 1064L: 7, 1088L: 8, 1089L: 8, 1092L: 1, 1108L: 8, 1110L: 8, 1125L: 8, 1296L: 8, 1302L: 8, 1600L: 5, 1601L: 8, 1612L: 5, 1613L: 5, 1614L: 5, 1615L: 8, 1616L: 5, 1619L: 5, 1623L: 5, 1668L: 5 57L: 3, 148L: 8, 228L: 5, 229L: 4, 316L: 8, 342L: 6, 344L: 8, 380L: 8, 399L: 7, 411L: 5, 419L: 8, 420L: 8, 427L: 3, 432L: 7, 450L: 8, 463L: 8, 464L: 8, 476L: 4, 490L: 8, 506L: 8, 542L: 7, 545L: 6, 597L: 8, 662L: 4, 773L: 7, 777L: 8, 780L: 8, 795L: 8, 800L: 8, 804L: 8, 806L: 8, 808L: 8, 817L: 4, 819L: 7, 821L: 5, 825L: 4, 829L: 5, 837L: 5, 856L: 7, 862L: 8, 871L: 8, 881L: 8, 882L: 4, 884L: 8, 891L: 8, 892L: 8, 905L: 8, 923L: 2, 927L: 8, 929L: 8, 963L: 8, 965L: 8, 966L: 8, 967L: 8, 983L: 8, 985L: 3, 1029L: 8, 1036L: 8, 1052L: 8, 1064L: 7, 1088L: 8, 1089L: 8, 1092L: 1, 1108L: 8, 1110L: 8, 1125L: 8, 1296L: 8, 1302L: 8, 1600L: 5, 1601L: 8, 1612L: 5, 1613L: 5, 1614L: 5, 1615L: 8, 1616L: 5, 1619L: 5, 1623L: 5, 1668L: 5
}, },
TOYOTA.RAV4: { TOYOTA.RAV4: {
36L: 8, 37L: 8, 170L: 8, 180L: 8, 186L: 4, 426L: 6, 452L: 8, 464L: 8, 466L: 8, 467L: 8, 547L: 8, 548L: 8, 552L: 4, 562L: 4, 608L: 8, 610L: 5, 643L: 7, 705L: 8, 725L: 2, 740L: 5, 800L: 8, 835L: 8, 836L: 8, 849L: 4, 869L: 7, 870L: 7, 871L: 2, 896L: 8, 897L: 8, 900L: 6, 902L: 6, 905L: 8, 911L: 8, 916L: 3, 918L: 7, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 951L: 8, 955L: 4, 956L: 8, 979L: 2, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1008L: 2, 1014L: 8, 1017L: 8, 1041L: 8, 1042L: 8, 1043L: 8, 1044L: 8, 1056L: 8, 1059L: 1, 1114L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1176L: 8, 1177L: 8, 1178L: 8, 1179L: 8, 1180L: 8, 1181L: 8, 1190L: 8, 1191L: 8, 1192L: 8, 1196L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1263L: 8, 1279L: 8, 1408L: 8, 1409L: 8, 1410L: 8, 1552L: 8, 1553L: 8, 1554L: 8, 1555L: 8, 1556L: 8, 1557L: 8, 1561L: 8, 1562L: 8, 1568L: 8, 1569L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1584L: 8, 1589L: 8, 1592L: 8, 1593L: 8, 1595L: 8, 1596L: 8, 1597L: 8, 1600L: 8, 1656L: 8, 1664L: 8, 1728L: 8, 1745L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8 36L: 8, 37L: 8, 170L: 8, 180L: 8, 186L: 4, 426L: 6, 452L: 8, 464L: 8, 466L: 8, 467L: 8, 547L: 8, 548L: 8, 552L: 4, 562L: 4, 608L: 8, 610L: 5, 643L: 7, 705L: 8, 725L: 2, 740L: 5, 800L: 8, 835L: 8, 836L: 8, 849L: 4, 869L: 7, 870L: 7, 871L: 2, 896L: 8, 897L: 8, 900L: 6, 902L: 6, 905L: 8, 911L: 8, 916L: 3, 918L: 7, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 951L: 8, 955L: 4, 956L: 8, 979L: 2, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1005L: 2, 1008L: 2, 1014L: 8, 1017L: 8, 1041L: 8, 1042L: 8, 1043L: 8, 1044L: 8, 1056L: 8, 1059L: 1, 1114L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1176L: 8, 1177L: 8, 1178L: 8, 1179L: 8, 1180L: 8, 1181L: 8, 1190L: 8, 1191L: 8, 1192L: 8, 1196L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1263L: 8, 1264L: 8, 1279L: 8, 1408L: 8, 1409L: 8, 1410L: 8, 1552L: 8, 1553L: 8, 1554L: 8, 1555L: 8, 1556L: 8, 1557L: 8, 1561L: 8, 1562L: 8, 1568L: 8, 1569L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1584L: 8, 1589L: 8, 1592L: 8, 1593L: 8, 1595L: 8, 1596L: 8, 1597L: 8, 1600L: 8, 1656L: 8, 1664L: 8, 1728L: 8, 1745L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8
}, },
TOYOTA.RAV4H: { TOYOTA.RAV4H: {
36L: 8, 37L: 8, 170L: 8, 180L: 8, 186L: 4, 426L: 6, 452L: 8, 464L: 8, 466L: 8, 467L: 8, 547L: 8, 548L: 8, 552L: 4, 562L: 4, 608L: 8, 610L: 5, 643L: 7, 705L: 8, 725L: 2, 740L: 5, 800L: 8, 835L: 8, 836L: 8, 849L: 4, 869L: 7, 870L: 7, 871L: 2, 896L: 8, 897L: 8, 900L: 6, 902L: 6, 905L: 8, 911L: 8, 916L: 3, 918L: 7, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 951L: 8, 955L: 8, 956L: 8, 979L: 2, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1008L: 2, 1014L: 8, 1017L: 8, 1041L: 8, 1042L: 8, 1043L: 8, 1044L: 8, 1056L: 8, 1059L: 1, 1114L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1176L: 8, 1177L: 8, 1178L: 8, 1179L: 8, 1180L: 8, 1181L: 8, 1190L: 8, 1191L: 8, 1192L: 8, 1196L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1263L: 8, 1279L: 8, 1408L: 8, 1409L: 8, 1410L: 8, 1552L: 8, 1553L: 8, 1554L: 8, 1555L: 8, 1556L: 8, 1557L: 8, 1561L: 8, 1562L: 8, 1568L: 8, 1569L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1584L: 8, 1589L: 8, 1592L: 8, 1593L: 8, 1595L: 8, 1596L: 8, 1597L: 8, 1600L: 8, 1656L: 8, 1664L: 8, 1728L: 8, 1745L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8, 581L: 5, 296: 8, 552L: 8, 560L: 7, 552L: 4, 713L: 8, 550L: 8, 608L: 8, 37L: 8, 36L: 8, 950L: 8, 1198L: 8, 1197L: 8, 1199L: 8, 1212L: 8, 953L: 3, 1264L: 8, 1184L: 8, 1005L: 2, 1185L: 8, 1232L: 8, 1186L: 8 36L: 8, 37L: 8, 170L: 8, 180L: 8, 186L: 4, 426L: 6, 452L: 8, 464L: 8, 466L: 8, 467L: 8, 547L: 8, 548L: 8, 552L: 4, 562L: 4, 608L: 8, 610L: 5, 643L: 7, 705L: 8, 725L: 2, 740L: 5, 800L: 8, 835L: 8, 836L: 8, 849L: 4, 869L: 7, 870L: 7, 871L: 2, 896L: 8, 897L: 8, 900L: 6, 902L: 6, 905L: 8, 911L: 8, 916L: 3, 918L: 7, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 951L: 8, 955L: 8, 956L: 8, 979L: 2, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1008L: 2, 1014L: 8, 1017L: 8, 1041L: 8, 1042L: 8, 1043L: 8, 1044L: 8, 1056L: 8, 1059L: 1, 1114L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1176L: 8, 1177L: 8, 1178L: 8, 1179L: 8, 1180L: 8, 1181L: 8, 1190L: 8, 1191L: 8, 1192L: 8, 1196L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1263L: 8, 1279L: 8, 1408L: 8, 1409L: 8, 1410L: 8, 1552L: 8, 1553L: 8, 1554L: 8, 1555L: 8, 1556L: 8, 1557L: 8, 1561L: 8, 1562L: 8, 1568L: 8, 1569L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1584L: 8, 1589L: 8, 1592L: 8, 1593L: 8, 1595L: 8, 1596L: 8, 1597L: 8, 1600L: 8, 1656L: 8, 1664L: 8, 1728L: 8, 1745L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8, 581L: 5, 296: 8, 560L: 7, 713L: 8, 550L: 8, 608L: 8, 37L: 8, 36L: 8, 950L: 8, 1198L: 8, 1197L: 8, 1199L: 8, 1212L: 8, 953L: 3, 1264L: 8, 1184L: 8, 1005L: 2, 1185L: 8, 1232L: 8, 1186L: 8
}, },
TOYOTA.PRIUS: [{ TOYOTA.PRIUS: [{
36L: 8, 37L: 8, 166L: 8, 170L: 8, 180L: 8, 295L: 8, 296L: 8, 426L: 6, 452L: 8, 466L: 8, 467L: 8, 550L: 8, 552L: 4, 560L: 7, 562L: 6, 581L: 5, 608L: 8, 610L: 8, 614L: 8, 643L: 7, 658L: 8, 713L: 8, 740L: 5, 742L: 8, 743L: 8, 800L: 8, 810L: 2, 814L: 8, 829L: 2, 830L: 7, 835L: 8, 836L: 8, 863L: 8, 869L: 7, 870L: 7, 871L: 2, 898L: 8, 900L: 6, 902L: 6, 905L: 8, 918L: 8, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 950L: 8, 951L: 8, 953L: 8, 955L: 8, 956L: 8, 971L: 7, 975L: 5, 993L: 8, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1014L: 8, 1017L: 8, 1020L: 8, 1041L: 8, 1042L: 8, 1044L: 8, 1056L: 8, 1057L: 8, 1059L: 1, 1071L: 8, 1077L: 8, 1082L: 8, 1083L: 8, 1084L: 8, 1085L: 8, 1086L: 8, 1114L: 8, 1132L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1175L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1279L: 8, 1552L: 8, 1553L: 8, 1556L: 8, 1557L: 8, 1568L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1595L: 8, 1777L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8 36L: 8, 37L: 8, 166L: 8, 170L: 8, 180L: 8, 295L: 8, 296L: 8, 426L: 6, 452L: 8, 466L: 8, 467L: 8, 550L: 8, 552L: 4, 560L: 7, 562L: 6, 581L: 5, 608L: 8, 610L: 8, 614L: 8, 643L: 7, 658L: 8, 713L: 8, 740L: 5, 742L: 8, 743L: 8, 800L: 8, 810L: 2, 814L: 8, 829L: 2, 830L: 7, 835L: 8, 836L: 8, 863L: 8, 869L: 7, 870L: 7, 871L: 2, 898L: 8, 900L: 6, 902L: 6, 905L: 8, 918L: 8, 921L: 8, 933L: 8, 944L: 8, 945L: 8, 950L: 8, 951L: 8, 953L: 8, 955L: 8, 956L: 8, 971L: 7, 975L: 5, 993L: 8, 998L: 5, 999L: 7, 1000L: 8, 1001L: 8, 1014L: 8, 1017L: 8, 1020L: 8, 1041L: 8, 1042L: 8, 1044L: 8, 1056L: 8, 1057L: 8, 1059L: 1, 1071L: 8, 1077L: 8, 1082L: 8, 1083L: 8, 1084L: 8, 1085L: 8, 1086L: 8, 1114L: 8, 1132L: 8, 1161L: 8, 1162L: 8, 1163L: 8, 1175L: 8, 1227L: 8, 1228L: 8, 1235L: 8, 1237L: 8, 1279L: 8, 1552L: 8, 1553L: 8, 1556L: 8, 1557L: 8, 1568L: 8, 1570L: 8, 1571L: 8, 1572L: 8, 1595L: 8, 1777L: 8, 1779L: 8, 1904L: 8, 1912L: 8, 1990L: 8, 1998L: 8
@ -56,6 +57,9 @@ _FINGERPRINTS = {
TOYOTA.COROLLA: { TOYOTA.COROLLA: {
36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 548: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 2, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1196: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 548: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 2, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1196: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8
}, },
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
},
} }
# support additional internal only fingerprints # support additional internal only fingerprints

@ -1,6 +1,5 @@
import abc import abc
import numpy as np import numpy as np
import numpy.matlib
# The EKF class contains the framework for an Extended Kalman Filter, but must be subclassed to use. # The EKF class contains the framework for an Extended Kalman Filter, but must be subclassed to use.
# A subclass must implement: # A subclass must implement:
# 1) calc_transfer_fun(); see bottom of file for more info. # 1) calc_transfer_fun(); see bottom of file for more info.

@ -227,7 +227,7 @@ class DBWriter(DBAccessor):
data_path = self._data_path() data_path = self._data_path()
try: try:
old_data_path = os.path.join(self._path, os.readlink(data_path)) old_data_path = os.path.join(self._path, os.readlink(data_path))
except (OSError, IOError) as e: except (OSError, IOError):
# NOTE(mgraczyk): If other DB implementations have bugs, this could cause # NOTE(mgraczyk): If other DB implementations have bugs, this could cause
# copies to be left behind, but we still want to overwrite. # copies to be left behind, but we still want to overwrite.
pass pass

@ -1,7 +1,6 @@
"""Utilities for reading real time clocks and keeping soft real time constraints.""" """Utilities for reading real time clocks and keeping soft real time constraints."""
import os import os
import time import time
import ctypes
import platform import platform
import threading import threading
import subprocess import subprocess

@ -451,6 +451,7 @@ void _pigeon_send(const char *dat, int len) {
memcpy(&a[1], &dat[i], ll); memcpy(&a[1], &dat[i], ll);
pthread_mutex_lock(&usb_lock); pthread_mutex_lock(&usb_lock);
err = libusb_bulk_transfer(dev_handle, 2, a, ll+1, &sent, TIMEOUT); err = libusb_bulk_transfer(dev_handle, 2, a, ll+1, &sent, TIMEOUT);
if (err < 0) { handle_usb_issue(err, __func__); }
assert(err == 0); assert(err == 0);
assert(sent == ll+1); assert(sent == ll+1);
//hexdump(a, ll+1); //hexdump(a, ll+1);
@ -460,20 +461,24 @@ void _pigeon_send(const char *dat, int len) {
void pigeon_set_power(int power) { void pigeon_set_power(int power) {
pthread_mutex_lock(&usb_lock); pthread_mutex_lock(&usb_lock);
libusb_control_transfer(dev_handle, 0xc0, 0xd9, power, 0, NULL, 0, TIMEOUT); int err = libusb_control_transfer(dev_handle, 0xc0, 0xd9, power, 0, NULL, 0, TIMEOUT);
if (err < 0) { handle_usb_issue(err, __func__); }
pthread_mutex_unlock(&usb_lock); pthread_mutex_unlock(&usb_lock);
} }
void pigeon_set_baud(int baud) { void pigeon_set_baud(int baud) {
int err;
pthread_mutex_lock(&usb_lock); pthread_mutex_lock(&usb_lock);
libusb_control_transfer(dev_handle, 0xc0, 0xe2, 1, 0, NULL, 0, TIMEOUT); err = libusb_control_transfer(dev_handle, 0xc0, 0xe2, 1, 0, NULL, 0, TIMEOUT);
libusb_control_transfer(dev_handle, 0xc0, 0xe4, 1, baud/300, NULL, 0, TIMEOUT); if (err < 0) { handle_usb_issue(err, __func__); }
err = libusb_control_transfer(dev_handle, 0xc0, 0xe4, 1, baud/300, NULL, 0, TIMEOUT);
if (err < 0) { handle_usb_issue(err, __func__); }
pthread_mutex_unlock(&usb_lock); pthread_mutex_unlock(&usb_lock);
} }
void pigeon_init() { void pigeon_init() {
usleep(1000*1000); usleep(1000*1000);
LOGW("pigeon start"); LOGW("grey panda start");
// power off pigeon // power off pigeon
pigeon_set_power(0); pigeon_set_power(0);
@ -513,7 +518,7 @@ void pigeon_init() {
pigeon_send("\xB5\x62\x06\x01\x03\x00\x01\x07\x01\x13\x51"); pigeon_send("\xB5\x62\x06\x01\x03\x00\x01\x07\x01\x13\x51");
pigeon_send("\xB5\x62\x06\x01\x03\x00\x02\x15\x01\x22\x70"); pigeon_send("\xB5\x62\x06\x01\x03\x00\x02\x15\x01\x22\x70");
LOGW("pigeon is ready to fly"); LOGW("grey panda is ready to fly");
} }
@ -551,6 +556,7 @@ void *pigeon_thread(void *crap) {
while (alen < 0xfc0) { while (alen < 0xfc0) {
pthread_mutex_lock(&usb_lock); pthread_mutex_lock(&usb_lock);
int len = libusb_control_transfer(dev_handle, 0xc0, 0xe0, 1, 0, dat+alen, 0x40, TIMEOUT); int len = libusb_control_transfer(dev_handle, 0xc0, 0xe0, 1, 0, dat+alen, 0x40, TIMEOUT);
if (len < 0) { handle_usb_issue(len, __func__); }
pthread_mutex_unlock(&usb_lock); pthread_mutex_unlock(&usb_lock);
if (len <= 0) break; if (len <= 0) break;

@ -8,6 +8,8 @@
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
unsigned int honda_checksum(unsigned int address, uint64_t d, int l);
unsigned int toyota_checksum(unsigned int address, uint64_t d, int l);
struct SignalPackValue { struct SignalPackValue {
const char* name; const char* name;

@ -67,7 +67,7 @@ typedef struct {
void* can_init(int bus, const char* dbc_name, void* can_init(int bus, const char* dbc_name,
size_t num_message_options, const MessageParseOptions* message_options, size_t num_message_options, const MessageParseOptions* message_options,
size_t num_signal_options, const SignalParseOptions* signal_options); size_t num_signal_options, const SignalParseOptions* signal_options, bool sendcan);
void can_update(void* can, uint64_t sec, bool wait); void can_update(void* can, uint64_t sec, bool wait);
@ -77,8 +77,7 @@ const DBC* dbc_lookup(const char* dbc_name);
void* canpack_init(const char* dbc_name); void* canpack_init(const char* dbc_name);
uint64_t canpack_pack(void* inst, uint32_t address, size_t num_vals, const SignalPackValue *vals); uint64_t canpack_pack(void* inst, uint32_t address, size_t num_vals, const SignalPackValue *vals, int counter);
""") """)
libdbc = ffi.dlopen(libdbc_fn) libdbc = ffi.dlopen(libdbc_fn)

@ -5,6 +5,7 @@
#include <utility> #include <utility>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <cmath>
#include "common.h" #include "common.h"
@ -12,14 +13,23 @@
namespace { namespace {
class CANPacker { uint64_t set_value(uint64_t ret, Signal sig, int64_t ival){
public: uint64_t mask = ((1ULL << sig.b2)-1) << sig.bo;
uint64_t dat = (ival & ((1ULL << sig.b2)-1)) << sig.bo;
ret &= ~mask;
ret |= dat;
return ret;
}
class CANPacker {
public:
CANPacker(const std::string& dbc_name) { CANPacker(const std::string& dbc_name) {
dbc = dbc_lookup(dbc_name); dbc = dbc_lookup(dbc_name);
assert(dbc); assert(dbc);
for (int i=0; i<dbc->num_msgs; i++) { for (int i=0; i<dbc->num_msgs; i++) {
const Msg* msg = &dbc->msgs[i]; const Msg* msg = &dbc->msgs[i];
message_lookup[msg->address] = *msg;
for (int j=0; j<msg->num_sigs; j++) { for (int j=0; j<msg->num_sigs; j++) {
const Signal* sig = &msg->sigs[j]; const Signal* sig = &msg->sigs[j];
signal_lookup[std::make_pair(msg->address, std::string(sig->name))] = *sig; signal_lookup[std::make_pair(msg->address, std::string(sig->name))] = *sig;
@ -27,29 +37,55 @@ public:
} }
} }
uint64_t pack(uint32_t address, const std::vector<SignalPackValue> &signals) { uint64_t pack(uint32_t address, const std::vector<SignalPackValue> &signals, int counter) {
uint64_t ret = 0; uint64_t ret = 0;
for (const auto& sigval : signals) { for (const auto& sigval : signals) {
std::string name = std::string(sigval.name); std::string name = std::string(sigval.name);
double value = sigval.value; double value = sigval.value;
auto sig_it = signal_lookup.find(make_pair(address, name)); auto sig_it = signal_lookup.find(std::make_pair(address, name));
if (sig_it == signal_lookup.end()) { if (sig_it == signal_lookup.end()) {
WARN("undefined signal %s", name.c_str()); WARN("undefined signal %s - %d\n", name.c_str(), address);
continue; continue;
} }
auto sig = sig_it->second; auto sig = sig_it->second;
int64_t ival = (int64_t)((value - sig.offset) / sig.factor); int64_t ival = (int64_t)(round((value - sig.offset) / sig.factor));
if (ival < 0) { if (ival < 0) {
WARN("signed pack unsupported right now"); ival = (1ULL << sig.b2) + ival;
continue;
} }
uint64_t mask = ((1ULL << sig.b2)-1) << sig.bo; ret = set_value(ret, sig, ival);
uint64_t dat = (ival & ((1ULL << sig.b2)-1)) << sig.bo; }
ret &= ~mask;
ret |= dat; if (counter >= 0){
auto sig_it = signal_lookup.find(std::make_pair(address, "COUNTER"));
if (sig_it == signal_lookup.end()) {
WARN("COUNTER not defined\n");
return ret;
}
auto sig = sig_it->second;
if (sig.type != SignalType::HONDA_COUNTER){
WARN("COUNTER signal type not valid\n");
}
ret = set_value(ret, sig, counter);
}
auto sig_it = signal_lookup.find(std::make_pair(address, "CHECKSUM"));
if (sig_it != signal_lookup.end()) {
auto sig = sig_it->second;
if (sig.type == SignalType::HONDA_CHECKSUM){
unsigned int chksm = honda_checksum(address, ret, message_lookup[address].size);
ret = set_value(ret, sig, chksm);
}
else if (sig.type == SignalType::TOYOTA_CHECKSUM){
unsigned int chksm = toyota_checksum(address, ret, message_lookup[address].size);
ret = set_value(ret, sig, chksm);
} else {
WARN("CHECKSUM signal type not valid\n");
}
} }
return ret; return ret;
@ -57,25 +93,24 @@ public:
private: private:
const DBC *dbc = NULL; const DBC *dbc = NULL;
std::map<std::pair<uint32_t, std::string>, Signal> signal_lookup; std::map<std::pair<uint32_t, std::string>, Signal> signal_lookup;
}; std::map<uint32_t, Msg> message_lookup;
};
} }
extern "C" { extern "C" {
void* canpack_init(const char* dbc_name) {
void* canpack_init(const char* dbc_name) {
CANPacker *ret = new CANPacker(std::string(dbc_name)); CANPacker *ret = new CANPacker(std::string(dbc_name));
return (void*)ret; return (void*)ret;
} }
uint64_t canpack_pack(void* inst, uint32_t address, size_t num_vals, const SignalPackValue *vals) { uint64_t canpack_pack(void* inst, uint32_t address, size_t num_vals, const SignalPackValue *vals, int counter, bool checksum) {
CANPacker *cp = (CANPacker*)inst; CANPacker *cp = (CANPacker*)inst;
return cp->pack(address, std::vector<SignalPackValue>(vals, vals+num_vals)); return cp->pack(address, std::vector<SignalPackValue>(vals, vals+num_vals), counter);
} }
} }

@ -1,13 +1,26 @@
import struct import struct
import numbers
from selfdrive.can.libdbc_py import libdbc, ffi from selfdrive.can.libdbc_py import libdbc, ffi
class CANPacker(object): class CANPacker(object):
def __init__(self, dbc_name): def __init__(self, dbc_name):
self.packer = libdbc.canpack_init(dbc_name) self.packer = libdbc.canpack_init(dbc_name)
self.dbc = libdbc.dbc_lookup(dbc_name)
self.sig_names = {} self.sig_names = {}
self.name_to_address_and_size = {}
self.address_to_size = {}
def pack(self, addr, values): num_msgs = self.dbc[0].num_msgs
for i in range(num_msgs):
msg = self.dbc[0].msgs[i]
name = ffi.string(msg.name)
address = msg.address
self.name_to_address_and_size[name] = (address, msg.size)
self.address_to_size[address] = msg.size
def pack(self, addr, values, counter):
# values: [(signal_name, signal_value)] # values: [(signal_name, signal_value)]
values_thing = [] values_thing = []
@ -22,10 +35,19 @@ class CANPacker(object):
values_c = ffi.new("SignalPackValue[]", values_thing) values_c = ffi.new("SignalPackValue[]", values_thing)
return libdbc.canpack_pack(self.packer, addr, len(values_thing), values_c) return libdbc.canpack_pack(self.packer, addr, len(values_thing), values_c, counter)
def pack_bytes(self, addr, values, counter=-1):
if isinstance(addr, numbers.Number):
size = self.address_to_size[addr]
else:
addr, size = self.name_to_address_and_size[addr]
r = struct.pack(">Q", self.pack(addr, values, counter))
return addr, r[:size]
def pack_bytes(self, addr, values): def make_can_msg(self, addr, bus, values, counter=-1):
return struct.pack(">Q", self.pack(addr, values)) addr, msg = self.pack_bytes(addr, values, counter)
return [addr, 0, msg, bus]
if __name__ == "__main__": if __name__ == "__main__":

@ -27,19 +27,6 @@
#define MAX_BAD_COUNTER 5 #define MAX_BAD_COUNTER 5
namespace {
uint64_t read_u64_be(const uint8_t* v) {
return (((uint64_t)v[0] << 56)
| ((uint64_t)v[1] << 48)
| ((uint64_t)v[2] << 40)
| ((uint64_t)v[3] << 32)
| ((uint64_t)v[4] << 24)
| ((uint64_t)v[5] << 16)
| ((uint64_t)v[6] << 8)
| (uint64_t)v[7]);
}
unsigned int honda_checksum(unsigned int address, uint64_t d, int l) { unsigned int honda_checksum(unsigned int address, uint64_t d, int l) {
d >>= ((8-l)*8); // remove padding d >>= ((8-l)*8); // remove padding
d >>= 4; // remove checksum d >>= 4; // remove checksum
@ -64,6 +51,20 @@ unsigned int toyota_checksum(unsigned int address, uint64_t d, int l) {
return s & 0xFF; return s & 0xFF;
} }
namespace {
uint64_t read_u64_be(const uint8_t* v) {
return (((uint64_t)v[0] << 56)
| ((uint64_t)v[1] << 48)
| ((uint64_t)v[2] << 40)
| ((uint64_t)v[3] << 32)
| ((uint64_t)v[4] << 24)
| ((uint64_t)v[5] << 16)
| ((uint64_t)v[6] << 8)
| (uint64_t)v[7]);
}
struct MessageState { struct MessageState {
uint32_t address; uint32_t address;
unsigned int size; unsigned int size;
@ -99,7 +100,7 @@ struct MessageState {
return false; return false;
} }
} else if (sig.type == SignalType::TOYOTA_CHECKSUM) { } else if (sig.type == SignalType::TOYOTA_CHECKSUM) {
// DEBUG("CHECKSUM %d %d %018llX - %lld vs %d\n", address, size, dat, tmp, toyota_checksum(address, dat, size)); // INFO("CHECKSUM %d %d %018llX - %lld vs %d\n", address, size, dat, tmp, toyota_checksum(address, dat, size));
if (toyota_checksum(address, dat, size) != tmp) { if (toyota_checksum(address, dat, size) != tmp) {
INFO("%X CHECKSUM FAIL\n", address); INFO("%X CHECKSUM FAIL\n", address);
@ -140,13 +141,19 @@ class CANParser {
public: public:
CANParser(int abus, const std::string& dbc_name, CANParser(int abus, const std::string& dbc_name,
const std::vector<MessageParseOptions> &options, const std::vector<MessageParseOptions> &options,
const std::vector<SignalParseOptions> &sigoptions) const std::vector<SignalParseOptions> &sigoptions,
bool sendcan)
: bus(abus) { : bus(abus) {
// connect to can on 8006 // connect to can on 8006
context = zmq_ctx_new(); context = zmq_ctx_new();
subscriber = zmq_socket(context, ZMQ_SUB); subscriber = zmq_socket(context, ZMQ_SUB);
zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, "", 0); zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, "", 0);
if (sendcan) {
zmq_connect(subscriber, "tcp://127.0.0.1:8017");
} else {
zmq_connect(subscriber, "tcp://127.0.0.1:8006"); zmq_connect(subscriber, "tcp://127.0.0.1:8006");
}
dbc = dbc_lookup(dbc_name); dbc = dbc_lookup(dbc_name);
assert(dbc); assert(dbc);
@ -323,12 +330,13 @@ extern "C" {
void* can_init(int bus, const char* dbc_name, void* can_init(int bus, const char* dbc_name,
size_t num_message_options, const MessageParseOptions* message_options, size_t num_message_options, const MessageParseOptions* message_options,
size_t num_signal_options, const SignalParseOptions* signal_options) { size_t num_signal_options, const SignalParseOptions* signal_options,
bool sendcan) {
CANParser* ret = new CANParser(bus, std::string(dbc_name), CANParser* ret = new CANParser(bus, std::string(dbc_name),
(message_options ? std::vector<MessageParseOptions>(message_options, message_options+num_message_options) (message_options ? std::vector<MessageParseOptions>(message_options, message_options+num_message_options)
: std::vector<MessageParseOptions>{}), : std::vector<MessageParseOptions>{}),
(signal_options ? std::vector<SignalParseOptions>(signal_options, signal_options+num_signal_options) (signal_options ? std::vector<SignalParseOptions>(signal_options, signal_options+num_signal_options)
: std::vector<SignalParseOptions>{})); : std::vector<SignalParseOptions>{}), sendcan);
return (void*)ret; return (void*)ret;
} }

@ -1,4 +1,3 @@
import os
import time import time
from collections import defaultdict from collections import defaultdict
import numbers import numbers
@ -6,7 +5,7 @@ import numbers
from selfdrive.can.libdbc_py import libdbc, ffi from selfdrive.can.libdbc_py import libdbc, ffi
class CANParser(object): class CANParser(object):
def __init__(self, dbc_name, signals, checks=[], bus=0): def __init__(self, dbc_name, signals, checks=[], bus=0, sendcan=False):
self.can_valid = True self.can_valid = True
self.vl = defaultdict(dict) self.vl = defaultdict(dict)
self.ts = defaultdict(dict) self.ts = defaultdict(dict)
@ -56,12 +55,12 @@ class CANParser(object):
message_options_c = ffi.new("MessageParseOptions[]", [ message_options_c = ffi.new("MessageParseOptions[]", [
{ {
'address': address, 'address': msg_address,
'check_frequency': freq, 'check_frequency': freq,
} for address, freq in message_options.iteritems()]) } for msg_address, freq in message_options.iteritems()])
self.can = libdbc.can_init(bus, dbc_name, len(message_options_c), message_options_c, self.can = libdbc.can_init(bus, dbc_name, len(message_options_c), message_options_c,
len(signal_options_c), signal_options_c) len(signal_options_c), signal_options_c, sendcan)
self.p_can_valid = ffi.new("bool*") self.p_can_valid = ffi.new("bool*")

@ -26,11 +26,28 @@ msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not
if can_dbc.name.startswith("honda") or can_dbc.name.startswith("acura"): if can_dbc.name.startswith("honda") or can_dbc.name.startswith("acura"):
checksum_type = "honda" checksum_type = "honda"
checksum_size = 4
elif can_dbc.name.startswith("toyota"): elif can_dbc.name.startswith("toyota"):
checksum_type = "toyota" checksum_type = "toyota"
checksum_size = 8
else: else:
checksum_type = None checksum_type = None
for address, msg_name, msg_size, sigs in msgs:
for sig in sigs:
if checksum_type is not None and sig.name == "CHECKSUM":
if sig.size != checksum_size:
sys.exit("CHECKSUM is not %d bits longs %s" % (checksum_size, msg_name))
if checksum_type == "honda" and sig.start_bit % 8 != 3:
sys.exit("CHECKSUM starts at wrong bit %s" % msg_name)
if checksum_type == "toyota" and sig.start_bit % 8 != 7:
sys.exit("CHECKSUM starts at wrong bit %s" % msg_name)
if checksum_type == "honda" and sig.name == "COUNTER":
if sig.size != 2:
sys.exit("COUNTER is not 2 bits longs %s" % msg_name)
if sig.start_bit % 8 != 5:
sys.exit("COUNTER starts at wrong bit %s" % msg_name)
# Fail on duplicate messgae names # Fail on duplicate messgae names
c = Counter([msg_name for address, msg_name, msg_size, sigs in msgs]) c = Counter([msg_name for address, msg_name, msg_size, sigs in msgs])

@ -1,5 +1,4 @@
import os import os
from cereal import car
from common.realtime import sec_since_boot from common.realtime import sec_since_boot
from common.fingerprints import eliminate_incompatible_cars, all_known_cars from common.fingerprints import eliminate_incompatible_cars, all_known_cars
@ -33,6 +32,7 @@ interfaces = {
TOYOTA.RAV4: ToyotaInterface, TOYOTA.RAV4: ToyotaInterface,
TOYOTA.RAV4H: ToyotaInterface, TOYOTA.RAV4H: ToyotaInterface,
TOYOTA.COROLLA: ToyotaInterface, TOYOTA.COROLLA: ToyotaInterface,
TOYOTA.LEXUS_RXH: ToyotaInterface,
"simulator2": Sim2Interface, "simulator2": Sim2Interface,
"mock": MockInterface "mock": MockInterface
@ -63,7 +63,8 @@ def fingerprint(logcan, timeout):
# message has elapsed, exit. Toyota needs higher time_fingerprint, since DSU does not # message has elapsed, exit. Toyota needs higher time_fingerprint, since DSU does not
# broadcast immediately # broadcast immediately
if len(candidate_cars) == 1 and st is not None: if len(candidate_cars) == 1 and st is not None:
time_fingerprint = 1.0 if "TOYOTA" in candidate_cars[0] else 0.1 # TODO: better way to decide to wait more if Toyota
time_fingerprint = 1.0 if ("TOYOTA" in candidate_cars[0] or "LEXUS" in candidate_cars[0]) else 0.1
if (ts-st) > time_fingerprint: if (ts-st) > time_fingerprint:
break break

@ -2,7 +2,6 @@ from collections import namedtuple
import os import os
from selfdrive.boardd.boardd import can_list_to_can_capnp from selfdrive.boardd.boardd import can_list_to_can_capnp
from selfdrive.controls.lib.drive_helpers import rate_limit from selfdrive.controls.lib.drive_helpers import rate_limit
from common.realtime import sec_since_boot
from common.numpy_fast import clip from common.numpy_fast import clip
from . import hondacan from . import hondacan
from .values import AH from .values import AH
@ -115,11 +114,10 @@ class CarController(object):
# **** process the car messages **** # **** process the car messages ****
# *** compute control surfaces *** # *** compute control surfaces ***
tt = sec_since_boot()
GAS_MAX = 1004 GAS_MAX = 1004
BRAKE_MAX = 1024/4 BRAKE_MAX = 1024/4
if CS.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY): if CS.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY):
is_fw_modified = os.getenv("DONGLE_ID") in ['b0f5a01cf604185c'] is_fw_modified = os.getenv("DONGLE_ID") in ['99c94dc769b5d96e']
STEER_MAX = 0x1FFF if is_fw_modified else 0x1000 STEER_MAX = 0x1FFF if is_fw_modified else 0x1000
elif CS.CP.carFingerprint in (CAR.CRV, CAR.ACURA_RDX): elif CS.CP.carFingerprint in (CAR.CRV, CAR.ACURA_RDX):
STEER_MAX = 0x3e8 # CR-V only uses 12-bits and requires a lower value (max value from energee) STEER_MAX = 0x3e8 # CR-V only uses 12-bits and requires a lower value (max value from energee)

@ -1,7 +1,5 @@
import os import os
from cereal import car
from common.numpy_fast import interp from common.numpy_fast import interp
import selfdrive.messaging as messaging
from selfdrive.can.parser import CANParser from selfdrive.can.parser import CANParser
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
from common.kalman.simple_kalman import KF1D from common.kalman.simple_kalman import KF1D
@ -120,8 +118,7 @@ def get_can_signals(CP):
signals += [("MAIN_ON", "SCM_BUTTONS", 0)] signals += [("MAIN_ON", "SCM_BUTTONS", 0)]
elif CP.carFingerprint == CAR.ODYSSEY: elif CP.carFingerprint == CAR.ODYSSEY:
dbc_f = 'honda_odyssey_exl_2018_generated.dbc' dbc_f = 'honda_odyssey_exl_2018_generated.dbc'
signals += [("CAR_GAS", "GAS_PEDAL_2", 0), signals += [("MAIN_ON", "SCM_FEEDBACK", 0),
("MAIN_ON", "SCM_FEEDBACK", 0),
("EPB_STATE", "EPB_STATUS", 0), ("EPB_STATE", "EPB_STATUS", 0),
("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0)] ("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0)]
checks += [("EPB_STATUS", 50)] checks += [("EPB_STATUS", 50)]
@ -246,7 +243,7 @@ class CarState(object):
self.pedal_gas = cp.vl["POWERTRAIN_DATA"]['PEDAL_GAS'] self.pedal_gas = cp.vl["POWERTRAIN_DATA"]['PEDAL_GAS']
# crv doesn't include cruise control # crv doesn't include cruise control
if self.CP.carFingerprint in (CAR.CRV, CAR.ACURA_RDX): if self.CP.carFingerprint in (CAR.CRV, CAR.ODYSSEY, CAR.ACURA_RDX):
self.car_gas = self.pedal_gas self.car_gas = self.pedal_gas
else: else:
self.car_gas = cp.vl["GAS_PEDAL_2"]['CAR_GAS'] self.car_gas = cp.vl["GAS_PEDAL_2"]['CAR_GAS']
@ -278,7 +275,6 @@ class CarState(object):
if __name__ == '__main__': if __name__ == '__main__':
import zmq import zmq
import time import time
from selfdrive.services import service_list
context = zmq.Context() context = zmq.Context()
class CarParams(object): class CarParams(object):

@ -158,7 +158,7 @@ class CarInterface(object):
ret.centerToFront = centerToFront_civic ret.centerToFront = centerToFront_civic
ret.steerRatio = 13.0 ret.steerRatio = 13.0
# Civic at comma has modified steering FW, so different tuning for the Neo in that car # Civic at comma has modified steering FW, so different tuning for the Neo in that car
is_fw_modified = os.getenv("DONGLE_ID") in ['b0f5a01cf604185c'] is_fw_modified = os.getenv("DONGLE_ID") in ['99c94dc769b5d96e']
ret.steerKp, ret.steerKi = [0.4, 0.12] if is_fw_modified else [0.8, 0.24] ret.steerKp, ret.steerKi = [0.4, 0.12] if is_fw_modified else [0.8, 0.24]
ret.longitudinalKpBP = [0., 5., 35.] ret.longitudinalKpBP = [0., 5., 35.]
@ -172,7 +172,7 @@ class CarInterface(object):
ret.centerToFront = ret.wheelbase * 0.37 ret.centerToFront = ret.wheelbase * 0.37
ret.steerRatio = 15.3 ret.steerRatio = 15.3
# Acura at comma has modified steering FW, so different tuning for the Neo in that car # Acura at comma has modified steering FW, so different tuning for the Neo in that car
is_fw_modified = os.getenv("DONGLE_ID") in ['cb38263377b873ee'] is_fw_modified = os.getenv("DONGLE_ID") in ['85a6c74d4ad9c310']
ret.steerKp, ret.steerKi = [0.4, 0.12] if is_fw_modified else [0.8, 0.24] ret.steerKp, ret.steerKi = [0.4, 0.12] if is_fw_modified else [0.8, 0.24]
ret.longitudinalKpBP = [0., 5., 35.] ret.longitudinalKpBP = [0., 5., 35.]

@ -1,6 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import numpy as np
from selfdrive.can.parser import CANParser from selfdrive.can.parser import CANParser

@ -1,14 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
import os
import time
import zmq import zmq
from common.realtime import sec_since_boot
import common.numpy_fast as np
from cereal import car from cereal import car
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
from selfdrive.services import service_list from selfdrive.services import service_list
import selfdrive.messaging as messaging import selfdrive.messaging as messaging
from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event
# mocked car interface to work with chffrplus # mocked car interface to work with chffrplus
TS = 0.01 # 100Hz TS = 0.01 # 100Hz
@ -110,7 +105,6 @@ class CarInterface(object):
ret.steeringAngle = curvature * self.CP.steerRatio * self.CP.wheelbase * CV.RAD_TO_DEG ret.steeringAngle = curvature * self.CP.steerRatio * self.CP.wheelbase * CV.RAD_TO_DEG
events = [] events = []
#events.append(create_event('passive', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
ret.events = events ret.events = events
return ret.as_reader() return ret.as_reader()

@ -1,14 +1,10 @@
from common.numpy_fast import clip, interp from common.numpy_fast import clip
from common.realtime import sec_since_boot
from selfdrive.boardd.boardd import can_list_to_can_capnp from selfdrive.boardd.boardd import can_list_to_can_capnp
from selfdrive.controls.lib.drive_helpers import rate_limit
from selfdrive.car.toyota.toyotacan import make_can_msg, create_video_target,\ from selfdrive.car.toyota.toyotacan import make_can_msg, create_video_target,\
create_steer_command, create_ui_command, \ create_steer_command, create_ui_command, \
create_ipas_steer_command, create_accel_command, \ create_ipas_steer_command, create_accel_command, \
create_fcw_command create_fcw_command
from selfdrive.car.toyota.values import ECU, STATIC_MSGS from selfdrive.car.toyota.values import ECU, STATIC_MSGS
from common.fingerprints import TOYOTA as CAR
ACCEL_HYST_GAP = 0.02 # don't change accel command for small oscilalitons within this value ACCEL_HYST_GAP = 0.02 # don't change accel command for small oscilalitons within this value
ACCEL_MAX = 1500 # 1.5 m/s2 ACCEL_MAX = 1500 # 1.5 m/s2
@ -82,7 +78,6 @@ class CarController(object):
pcm_cancel_cmd, hud_alert, audible_alert): pcm_cancel_cmd, hud_alert, audible_alert):
# *** compute control surfaces *** # *** compute control surfaces ***
ts = sec_since_boot()
# 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_accel = actuators.gas - actuators.brake apply_accel = actuators.gas - actuators.brake

@ -1,5 +1,4 @@
import os import os
import selfdrive.messaging as messaging
from common.fingerprints import TOYOTA as CAR from common.fingerprints import TOYOTA as CAR
from selfdrive.can.parser import CANParser from selfdrive.can.parser import CANParser
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
@ -20,7 +19,8 @@ def parse_gear_shifter(can_gear, car_fingerprint):
return "drive" return "drive"
elif can_gear == 0x4: elif can_gear == 0x4:
return "brake" return "brake"
elif car_fingerprint in [CAR.RAV4, CAR.RAV4H, CAR.COROLLA]: elif car_fingerprint in [CAR.RAV4, CAR.RAV4H,
CAR.LEXUS_RXH, CAR.COROLLA]:
if can_gear == 0x20: if can_gear == 0x20:
return "park" return "park"
elif can_gear == 0x10: elif can_gear == 0x10:
@ -45,6 +45,8 @@ def get_can_parser(CP):
dbc_f = 'toyota_rav4_2017_pt_generated.dbc' dbc_f = 'toyota_rav4_2017_pt_generated.dbc'
elif CP.carFingerprint == CAR.COROLLA: elif CP.carFingerprint == CAR.COROLLA:
dbc_f = 'toyota_corolla_2017_pt_generated.dbc' dbc_f = 'toyota_corolla_2017_pt_generated.dbc'
elif CP.carFingerprint == CAR.LEXUS_RXH:
dbc_f = 'lexus_rx_hybrid_2017_pt_generated.dbc'
signals = [ signals = [
# sig_name, sig_address, default # sig_name, sig_address, default

@ -1,11 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import os
from common.realtime import sec_since_boot from common.realtime import sec_since_boot
import common.numpy_fast as np
from cereal import car from cereal import car
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
from selfdrive.services import service_list
import selfdrive.messaging as messaging
from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event
from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.controls.lib.vehicle_model import VehicleModel
from selfdrive.car.toyota.carstate import CarState, get_can_parser from selfdrive.car.toyota.carstate import CarState, get_can_parser
@ -79,34 +75,44 @@ class CarInterface(object):
if candidate == CAR.PRIUS: if candidate == CAR.PRIUS:
ret.safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file ret.safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file
ret.wheelbase = 2.70 ret.wheelbase = 2.70
ret.steerRatio = 14.5 #TODO: find exact value for Prius ret.steerRatio = 14.5 # TODO: find exact value for Prius
ret.mass = 3045./2.205 + std_cargo ret.mass = 3045./2.205 + std_cargo
ret.steerKp, ret.steerKi = 0.6, 0.05
ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594
ret.steerRateCost = 2.
elif candidate in [CAR.RAV4, CAR.RAV4H]: elif candidate in [CAR.RAV4, CAR.RAV4H]:
ret.safetyParam = 73 # see conversion factor for STEER_TORQUE_EPS in dbc file ret.safetyParam = 73 # see conversion factor for STEER_TORQUE_EPS in dbc file
ret.wheelbase = 2.65 ret.wheelbase = 2.65
ret.steerRatio = 14.5 # Rav4 2017 ret.steerRatio = 14.5 # Rav4 2017
ret.mass = 3650./2.205 + std_cargo # mean between normal and hybrid ret.mass = 3650./2.205 + std_cargo # mean between normal and hybrid
ret.steerKp, ret.steerKi = 0.6, 0.05
ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594
ret.steerRateCost = 1.
elif candidate == CAR.COROLLA: elif candidate == CAR.COROLLA:
ret.safetyParam = 100 # see conversion factor for STEER_TORQUE_EPS in dbc file ret.safetyParam = 100 # see conversion factor for STEER_TORQUE_EPS in dbc file
ret.wheelbase = 2.70 ret.wheelbase = 2.70
ret.steerRatio = 17.8 ret.steerRatio = 17.8
ret.mass = 2860./2.205 + std_cargo # mean between normal and hybrid ret.mass = 2860./2.205 + std_cargo # mean between normal and hybrid
ret.centerToFront = ret.wheelbase * 0.44
if candidate == CAR.COROLLA:
ret.steerKp, ret.steerKi = 0.2, 0.05 ret.steerKp, ret.steerKi = 0.2, 0.05
ret.steerKf = 0.00003 # full torque for 20 deg at 80mph means 0.00007818594 ret.steerKf = 0.00003 # full torque for 20 deg at 80mph means 0.00007818594
else: ret.steerRateCost = 1.
ret.steerKp, ret.steerKi = 0.6, 0.05 elif candidate == CAR.LEXUS_RXH:
ret.safetyParam = 100 # see conversion factor for STEER_TORQUE_EPS in dbc file
ret.wheelbase = 2.79
ret.steerRatio = 16. # official specs say 14.8, but it does not seem right
ret.mass = 4481./2.205 + std_cargo # mean between min and max
ret.steerKp, ret.steerKi = 0.6, 0.1
ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 ret.steerKf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594
ret.steerRateCost = .8
ret.centerToFront = ret.wheelbase * 0.44
ret.longPidDeadzoneBP = [0., 9.] ret.longPidDeadzoneBP = [0., 9.]
ret.longPidDeadzoneV = [0., .15] ret.longPidDeadzoneV = [0., .15]
# min speed to enable ACC. if car can do stop and go, then set enabling speed # 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. # to a negative value, so it won't matter.
if candidate in [CAR.PRIUS, CAR.RAV4H]: # rav4 hybrid can do stop and go if candidate in [CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH]: # rav4 hybrid can do stop and go
ret.minEnableSpeed = -1. ret.minEnableSpeed = -1.
elif candidate in [CAR.RAV4, CAR.COROLLA]: # TODO: hack ICE to do stop and go elif candidate in [CAR.RAV4, CAR.COROLLA]: # TODO: hack ICE to do stop and go
ret.minEnableSpeed = 19. * CV.MPH_TO_MS ret.minEnableSpeed = 19. * CV.MPH_TO_MS
@ -154,17 +160,11 @@ class CarInterface(object):
ret.longitudinalKiBP = [0., 35.] ret.longitudinalKiBP = [0., 35.]
ret.longitudinalKiV = [0.54, 0.36] ret.longitudinalKiV = [0.54, 0.36]
if candidate in [CAR.PRIUS]:
ret.steerRateCost = 2.
elif candidate in [CAR.RAV4, CAR.RAV4H, CAR.COROLLA]:
ret.steerRateCost = 1.
return ret return ret
# returns a car.CarState # returns a car.CarState
def update(self, c): def update(self, c):
# ******************* do can recv ******************* # ******************* do can recv *******************
can_pub_main = []
canMonoTimes = [] canMonoTimes = []
self.cp.update(int(sec_since_boot() * 1e9), False) self.cp.update(int(sec_since_boot() * 1e9), False)
@ -189,7 +189,7 @@ class CarInterface(object):
ret.gearShifter = self.CS.gear_shifter ret.gearShifter = self.CS.gear_shifter
# gas pedal # gas pedal
ret.gas = self.CS.car_gas / 256.0 ret.gas = self.CS.car_gas
ret.gasPressed = self.CS.pedal_gas > 0 ret.gasPressed = self.CS.pedal_gas > 0
# brake pedal # brake pedal

@ -1,6 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import numpy as np
from selfdrive.can.parser import CANParser from selfdrive.can.parser import CANParser
from cereal import car from cereal import car
from common.realtime import sec_since_boot from common.realtime import sec_since_boot
@ -14,7 +13,6 @@ RADAR_MSGS = range(0x210, 0x220)
def _create_radard_can_parser(): def _create_radard_can_parser():
dbc_f = 'toyota_prius_2017_adas.dbc' dbc_f = 'toyota_prius_2017_adas.dbc'
msg_n = len(RADAR_MSGS) msg_n = len(RADAR_MSGS)
msg_last = RADAR_MSGS[-1]
signals = zip(['LONG_DIST'] * msg_n + ['NEW_TRACK'] * msg_n + ['LAT_DIST'] * msg_n + signals = zip(['LONG_DIST'] * msg_n + ['NEW_TRACK'] * msg_n + ['LAT_DIST'] * msg_n +
['REL_SPEED'] * msg_n + ['VALID'] * msg_n, ['REL_SPEED'] * msg_n + ['VALID'] * msg_n,
RADAR_MSGS * 5, RADAR_MSGS * 5,
@ -45,7 +43,7 @@ class RadarInterface(object):
while 1: while 1:
tm = int(sec_since_boot() * 1e9) tm = int(sec_since_boot() * 1e9)
updated_messages.update(self.rcp.update(tm, True)) updated_messages.update(self.rcp.update(tm, True))
# TODO: use msg_last # TODO: do not hardcode last msg
if 0x21f in updated_messages: if 0x21f in updated_messages:
break break

@ -1,6 +1,4 @@
import struct import struct
import common.numpy_fast as np
from selfdrive.config import Conversions as CV
# *** Toyota specific *** # *** Toyota specific ***

@ -7,48 +7,48 @@ class ECU:
# addr: (ecu, cars, bus, 1/freq*100, vl) # addr: (ecu, cars, bus, 1/freq*100, vl)
STATIC_MSGS = [(0x141, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 2, '\x00\x00\x00\x46'), STATIC_MSGS = [(0x141, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 2, '\x00\x00\x00\x46'),
(0x128, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 3, '\xf4\x01\x90\x83\x00\x37'), (0x128, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 3, '\xf4\x01\x90\x83\x00\x37'),
(0x292, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 3, '\x00\x00\x00\x00\x00\x00\x00\x9e'), (0x292, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 3, '\x00\x00\x00\x00\x00\x00\x00\x9e'),
(0x283, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 3, '\x00\x00\x00\x00\x00\x00\x8c'), (0x283, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 3, '\x00\x00\x00\x00\x00\x00\x8c'),
(0x2E6, ECU.DSU, (CAR.PRIUS, CAR.RAV4H), 0, 3, '\xff\xf8\x00\x08\x7f\xe0\x00\x4e'), (0x2E6, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, '\xff\xf8\x00\x08\x7f\xe0\x00\x4e'),
(0x2E7, ECU.DSU, (CAR.PRIUS, CAR.RAV4H), 0, 3, '\xa8\x9c\x31\x9c\x00\x00\x00\x02'), (0x2E7, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, '\xa8\x9c\x31\x9c\x00\x00\x00\x02'),
(0x240, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), (0x240, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'),
(0x241, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), (0x241, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'),
(0x244, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), (0x244, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'),
(0x245, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'), (0x245, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x10\x01\x00\x10\x01\x00'),
(0x248, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x00\x00\x00\x00\x00\x01'), (0x248, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 5, '\x00\x00\x00\x00\x00\x00\x01'),
(0x344, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 5, '\x00\x00\x01\x00\x00\x00\x00\x50'), (0x344, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 5, '\x00\x00\x01\x00\x00\x00\x00\x50'),
(0x160, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 7, '\x00\x00\x08\x12\x01\x31\x9c\x51'), (0x160, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 7, '\x00\x00\x08\x12\x01\x31\x9c\x51'),
(0x161, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 7, '\x00\x1e\x00\x00\x00\x80\x07'), (0x161, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 7, '\x00\x1e\x00\x00\x00\x80\x07'),
(0x32E, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 20, '\x00\x00\x00\x00\x00\x00\x00\x00'), (0x32E, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 20, '\x00\x00\x00\x00\x00\x00\x00\x00'),
(0x33E, ECU.DSU, (CAR.PRIUS, CAR.RAV4H), 0, 20, '\x0f\xff\x26\x40\x00\x1f\x00'), (0x33E, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 20, '\x0f\xff\x26\x40\x00\x1f\x00'),
(0x365, ECU.DSU, (CAR.PRIUS, CAR.RAV4H), 0, 20, '\x00\x00\x00\x80\x03\x00\x08'), (0x365, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 20, '\x00\x00\x00\x80\x03\x00\x08'),
(0x365, ECU.DSU, (CAR.RAV4, CAR.COROLLA), 0, 20, '\x00\x00\x00\x80\xfc\x00\x08'), (0x365, ECU.DSU, (CAR.RAV4, CAR.COROLLA), 0, 20, '\x00\x00\x00\x80\xfc\x00\x08'),
(0x366, ECU.DSU, (CAR.PRIUS, CAR.RAV4H), 0, 20, '\x00\x00\x4d\x82\x40\x02\x00'), (0x366, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 20, '\x00\x00\x4d\x82\x40\x02\x00'),
(0x366, ECU.DSU, (CAR.RAV4, CAR.COROLLA), 0, 20, '\x00\x72\x07\xff\x09\xfe\x00'), (0x366, ECU.DSU, (CAR.RAV4, CAR.COROLLA), 0, 20, '\x00\x72\x07\xff\x09\xfe\x00'),
(0x367, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 40, '\x06\x00'), (0x367, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 40, '\x06\x00'),
(0x414, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x17\x00'), (0x414, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x17\x00'),
(0x489, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'), (0x489, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'),
(0x48a, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'), (0x48a, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x00'),
(0x48b, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x66\x06\x08\x0a\x02\x00\x00\x00'), (0x48b, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x66\x06\x08\x0a\x02\x00\x00\x00'),
(0x4d3, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x1C\x00\x00\x01\x00\x00\x00\x00'), (0x4d3, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x1C\x00\x00\x01\x00\x00\x00\x00'),
(0x130, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 1, 100, '\x00\x00\x00\x00\x00\x00\x38'), (0x130, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 1, 100, '\x00\x00\x00\x00\x00\x00\x38'),
(0x466, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4), 1, 100, '\x20\x20\xAD'), (0x466, ECU.CAM, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4), 1, 100, '\x20\x20\xAD'),
(0x466, ECU.CAM, (CAR.COROLLA), 1, 100, '\x24\x20\xB1'), (0x466, ECU.CAM, (CAR.COROLLA), 1, 100, '\x24\x20\xB1'),
(0x396, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\xBD\x00\x00\x00\x60\x0F\x02\x00'), (0x396, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\xBD\x00\x00\x00\x60\x0F\x02\x00'),
(0x43A, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x84\x00\x00\x00\x00\x00\x00\x00'), (0x43A, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x84\x00\x00\x00\x00\x00\x00\x00'),
(0x43B, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x00\x00'), (0x43B, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x00\x00'),
(0x497, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x00\x00'), (0x497, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x00\x00\x00\x00\x00\x00\x00\x00'),
(0x4CC, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x0D\x00\x00\x00\x00\x00\x00\x00'), (0x4CC, ECU.APGS, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x0D\x00\x00\x00\x00\x00\x00\x00'),
(0x4CB, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.RAV4, CAR.COROLLA), 0, 100, '\x0c\x00\x00\x00\x00\x00\x00\x00'), (0x4CB, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.RAV4, CAR.COROLLA), 0, 100, '\x0c\x00\x00\x00\x00\x00\x00\x00'),
(0x470, ECU.DSU, (CAR.PRIUS, CAR.RAV4H), 1, 100, '\x00\x00\x02\x7a'), (0x470, ECU.DSU, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 1, 100, '\x00\x00\x02\x7a'),
] ]

@ -1 +1 @@
#define COMMA_VERSION "0.4.1-openpilot" #define COMMA_VERSION "0.4.2-openpilot"

@ -73,7 +73,7 @@ def data_sample(CI, CC, thermal, calibration, health, poller, cal_status, overte
overtemp_proc = any(t > 950 for t in overtemp_proc = any(t > 950 for t in
(td.thermal.cpu0, td.thermal.cpu1, td.thermal.cpu2, (td.thermal.cpu0, td.thermal.cpu1, td.thermal.cpu2,
td.thermal.cpu3, td.thermal.mem, td.thermal.gpu)) td.thermal.cpu3, td.thermal.mem, td.thermal.gpu))
overtemp_bat = td.thermal.bat > 50000 # 50c overtemp_bat = td.thermal.bat > 60000 # 60c
overtemp = overtemp_proc or overtemp_bat overtemp = overtemp_proc or overtemp_bat
# under 15% of space free no enable allowed # under 15% of space free no enable allowed

@ -94,9 +94,9 @@ class LatControl(object):
output_steer = 0.0 output_steer = 0.0
self.pid.reset() self.pid.reset()
else: else:
dt = min(cur_time - self.angle_steers_des_time, _DT_MPC + _DT) + _DT # no greater than dt mpc + dt, to prevent too high extraps
# TODO: ideally we should interp, but for tuning reasons we keep the mpc solution # TODO: ideally we should interp, but for tuning reasons we keep the mpc solution
# constant for 0.05s. # constant for 0.05s.
#dt = min(cur_time - self.angle_steers_des_time, _DT_MPC + _DT) + _DT # no greater than dt mpc + dt, to prevent too high extraps
#self.angle_steers_des = self.angle_steers_des_prev + (dt / _DT_MPC) * (self.angle_steers_des_mpc - self.angle_steers_des_prev) #self.angle_steers_des = self.angle_steers_des_prev + (dt / _DT_MPC) * (self.angle_steers_des_mpc - self.angle_steers_des_prev)
self.angle_steers_des = self.angle_steers_des_mpc self.angle_steers_des = self.angle_steers_des_mpc
steers_max = get_steer_max(VM.CP, v_ego) steers_max = get_steer_max(VM.CP, v_ego)

@ -1,6 +1,4 @@
import numpy as np
from common.numpy_fast import clip, interp from common.numpy_fast import clip, interp
from selfdrive.config import Conversions as CV
from selfdrive.controls.lib.pid import PIController from selfdrive.controls.lib.pid import PIController
STOPPING_EGO_SPEED = 0.5 STOPPING_EGO_SPEED = 0.5

@ -7,7 +7,6 @@ import math
from collections import defaultdict from collections import defaultdict
from common.realtime import sec_since_boot from common.realtime import sec_since_boot
from common.params import Params
from common.numpy_fast import interp from common.numpy_fast import interp
import selfdrive.messaging as messaging import selfdrive.messaging as messaging
from selfdrive.swaglog import cloudlog from selfdrive.swaglog import cloudlog

@ -1,6 +1,5 @@
import os import os
import sys import sys
import math
import platform import platform
import numpy as np import numpy as np

@ -1,8 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import os
import zmq import zmq
import numpy as np import numpy as np
import numpy.matlib
import importlib import importlib
from collections import defaultdict from collections import defaultdict
from fastcluster import linkage_vector from fastcluster import linkage_vector
@ -16,7 +14,7 @@ from selfdrive.controls.lib.vehicle_model import VehicleModel
from selfdrive.swaglog import cloudlog from selfdrive.swaglog import cloudlog
from cereal import car from cereal import car
from common.params import Params from common.params import Params
from common.realtime import sec_since_boot, set_realtime_priority, Ratekeeper from common.realtime import set_realtime_priority, Ratekeeper
from common.kalman.ekf import EKF, SimpleSensor from common.kalman.ekf import EKF, SimpleSensor
DEBUG = False DEBUG = False

@ -1,7 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import sys import sys
import struct
from collections import defaultdict from collections import defaultdict
from common.realtime import sec_since_boot from common.realtime import sec_since_boot
import zmq import zmq

@ -19,7 +19,8 @@ msgs = {}
while True: while True:
lc = messaging.recv_sock(logcan, True) lc = messaging.recv_sock(logcan, True)
for c in lc.can: for c in lc.can:
if c.src == 0: # read also msgs sent by EON on CAN bus 0x80
if c.src%0x80 == 0:
msgs[c.address] = len(c.dat) msgs[c.address] = len(c.dat)
fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items())) fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items()))

@ -1,9 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import time
import subprocess import subprocess
from cffi import FFI from cffi import FFI
import ctypes
import numpy as np import numpy as np

@ -1,92 +0,0 @@
#!/usr/bin/env python
import time
import numpy as np
import zmq
from evdev import InputDevice
from select import select
from cereal import car
from common.realtime import Ratekeeper
import selfdrive.messaging as messaging
from selfdrive.services import service_list
from selfdrive.car import get_car
if __name__ == "__main__":
# ***** connect to joystick *****
# we use a Mad Catz V.1
dev = InputDevice("/dev/input/event8")
print dev
button_values = [0]*7
axis_values = [0.0, 0.0, 0.0]
# ***** connect to car *****
context = zmq.Context()
logcan = messaging.sub_sock(context, service_list['can'].port)
sendcan = messaging.pub_sock(context, service_list['sendcan'].port)
CI, CP = get_car(logcan, sendcan)
CC = car.CarControl.new_message()
rk = Ratekeeper(100)
while 1:
# **** handle joystick ****
r, w, x = select([dev], [], [], 0.0)
if dev in r:
for event in dev.read():
# button event
if event.type == 1:
btn = event.code - 288
if btn >= 0 and btn < 7:
button_values[btn] = int(event.value)
# axis move event
if event.type == 3:
if event.code < 3:
if event.code == 2:
axis_values[event.code] = np.clip((255-int(event.value))/250.0, 0.0, 1.0)
else:
DEADZONE = 5
if event.value-DEADZONE < 128 and event.value+DEADZONE > 128:
event.value = 128
axis_values[event.code] = np.clip((int(event.value)-128)/120.0, -1.0, 1.0)
print axis_values, button_values
# **** handle car ****
CS = CI.update(CC)
#print CS
CC = car.CarControl.new_message()
CC.enabled = True
CC.gas = float(np.clip(-axis_values[1], 0, 1.0))
CC.brake = float(np.clip(axis_values[1], 0, 1.0))
CC.steeringTorque = float(-axis_values[0])
CC.hudControl.speedVisible = bool(button_values[1])
CC.hudControl.lanesVisible = bool(button_values[2])
CC.hudControl.leadVisible = bool(button_values[3])
CC.cruiseControl.override = bool(button_values[0])
CC.cruiseControl.cancel = bool(button_values[-1])
CC.hudControl.setSpeed = float(axis_values[2] * 100.0)
# TODO: test alerts
CC.hudControl.visualAlert = "none"
CC.hudControl.audibleAlert = "none"
#print CC
if not CI.apply(CC):
print "CONTROLS FAILED"
rk.keep_time()

@ -1,52 +0,0 @@
#!/usr/bin/env python
import os
import zmq
from cereal import car
import selfdrive.messaging as messaging
from selfdrive.services import service_list
from selfdrive.car import get_car
def bpressed(CS, btype):
for b in CS.buttonEvents:
if b.type == btype:
return True
return False
def test_loop():
context = zmq.Context()
logcan = messaging.sub_sock(context, service_list['can'].port)
CI, CP = get_car(logcan)
state = 0
states = [
"'seatbeltNotLatched' in CS.errors",
"CS.gasPressed",
"CS.brakePressed",
"CS.steeringPressed",
"bpressed(CS, 'leftBlinker')",
"bpressed(CS, 'rightBlinker')",
"bpressed(CS, 'cancel')",
"bpressed(CS, 'accelCruise')",
"bpressed(CS, 'decelCruise')",
"bpressed(CS, 'altButton1')",
"'doorOpen' in CS.errors",
"False"]
while 1:
CC = car.CarControl.new_message()
# read CAN
CS = CI.update(CC)
while eval(states[state]) == True:
state += 1
print "IN STATE %d: waiting for %s" % (state, states[state])
#print CS
if __name__ == "__main__":
test_loop()

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2a4054a85749c1fca49b6f13490bb370781012d20577a190b3f2e795dc00aee5 oid sha256:1aef5754792c54dff148331a9dfe287c6e45ca2d83cac045767c99f187bcb951
size 1412368 size 1412368

@ -1,8 +1,6 @@
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
import os import os
import sys import sys
import time
import fcntl import fcntl
import errno import errno
import signal import signal
@ -53,7 +51,6 @@ from common.basedir import BASEDIR
sys.path.append(os.path.join(BASEDIR, "pyextra")) sys.path.append(os.path.join(BASEDIR, "pyextra"))
os.environ['BASEDIR'] = BASEDIR os.environ['BASEDIR'] = BASEDIR
import usb1
import zmq import zmq
from setproctitle import setproctitle from setproctitle import setproctitle
from smbus2 import SMBus from smbus2 import SMBus
@ -250,15 +247,19 @@ def manager_init():
if "-private" in subprocess.check_output(["git", "config", "--get", "remote.origin.url"]): if "-private" in subprocess.check_output(["git", "config", "--get", "remote.origin.url"]):
upstream = "origin/master" upstream = "origin/master"
else: else:
if 'chffrplus' in version:
upstream = "origin/release" upstream = "origin/release"
else:
upstream = "origin/release2"
dirty = subprocess.call(["git", "diff-index", "--quiet", upstream, "--"]) != 0 dirty = subprocess.call(["git", "diff-index", "--quiet", upstream, "--"]) != 0
cloudlog.info("dirty is %d" % dirty) cloudlog.info("dirty is %d" % dirty)
if not dirty: if not dirty:
os.environ['CLEAN'] = '1' os.environ['CLEAN'] = '1'
cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty) cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty, is_eon=EON)
crash.bind_user(id=dongle_id) crash.bind_user(id=dongle_id)
crash.bind_extra(version=version, dirty=dirty) crash.bind_extra(version=version, dirty=dirty, is_eon=EON)
os.umask(0) os.umask(0)
try: try:
@ -463,7 +464,7 @@ def manager_thread():
if passive and not ignition_seen: if passive and not ignition_seen:
should_start = should_start or passive_starter.update(started_ts, location) should_start = should_start or passive_starter.update(started_ts, location)
# with 2% left, we killall, otherwise the phone is bricked # with 2% left, we killall, otherwise the phone will take a long time to boot
should_start = should_start and avail > 0.02 should_start = should_start and avail > 0.02
# require usb power # require usb power
@ -471,9 +472,10 @@ def manager_thread():
should_start = should_start and accepted_terms and (not do_uninstall) should_start = should_start and accepted_terms and (not do_uninstall)
# if any CPU gets above 107 or the battery gets above 53, kill all processes # if any CPU gets above 107 or the battery gets above 63, kill all processes
# controls will warn with CPU above 95 or battery above 50 # controls will warn with CPU above 95 or battery above 60
if max_temp > 107.0 or msg.thermal.bat >= 53000: if max_temp > 107.0 or msg.thermal.bat >= 63000:
# TODO: Add a better warning when this is happening
should_start = False should_start = False
if should_start: if should_start:

@ -1,4 +1,3 @@
import os
import json import json
import subprocess import subprocess

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:270b694abedbfa8e865b5bf769b29114e34c1664910bfc1f699c83f02a1ba319 oid sha256:5061b6fb43d5a6caf54b615c00146bac96d807ffc0fde9509ab9295e4725d132
size 981400 size 981400

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1ed7402c2cdffdcf7b74f381c8f37cce397fd757ac74f66bd7558bbeebb04ac4 oid sha256:00afc9dbd055acd5ade3891a690c05a0220fae7f65533decf7a82bf731034570
size 972296 size 972296

@ -1,5 +1,3 @@
import os
from enum import Enum
from maneuverplots import ManeuverPlot from maneuverplots import ManeuverPlot
from plant import Plant from plant import Plant
import numpy as np import numpy as np
@ -31,7 +29,6 @@ class Maneuver(object):
) )
last_live100 = None last_live100 = None
event_queue = sorted(self.cruise_button_presses, key=lambda a: a[1])[::-1]
plot = ManeuverPlot(self.title) plot = ManeuverPlot(self.title)
buttons_sorted = sorted(self.cruise_button_presses, key=lambda a: a[1]) buttons_sorted = sorted(self.cruise_button_presses, key=lambda a: a[1])

@ -63,7 +63,7 @@ class ManeuverPlot(object):
def write_plot(self, path, maneuver_name): def write_plot(self, path, maneuver_name):
title = self.title or maneuver_name # title = self.title or maneuver_name
# TODO: Missing plots from the old one: # TODO: Missing plots from the old one:
# long_control_state # long_control_state
# proportional_gb, intergral_gb # proportional_gb, intergral_gb

@ -11,7 +11,6 @@ from common.realtime import Ratekeeper
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
import selfdrive.messaging as messaging import selfdrive.messaging as messaging
from selfdrive.services import service_list from selfdrive.services import service_list
from selfdrive.config import CruiseButtons
from selfdrive.car.honda.hondacan import fix from selfdrive.car.honda.hondacan import fix
from common.fingerprints import HONDA as CAR from common.fingerprints import HONDA as CAR
from selfdrive.car.honda.carstate import get_can_signals from selfdrive.car.honda.carstate import get_can_signals
@ -20,7 +19,6 @@ from selfdrive.boardd.boardd import can_capnp_to_can_list, can_list_to_can_capnp
from selfdrive.car.honda.old_can_parser import CANParser from selfdrive.car.honda.old_can_parser import CANParser
from selfdrive.car.honda.interface import CarInterface from selfdrive.car.honda.interface import CarInterface
from cereal import car
from common.dbc import dbc from common.dbc import dbc
honda = dbc(os.path.join(DBC_PATH, "honda_civic_touring_2016_can_generated.dbc")) honda = dbc(os.path.join(DBC_PATH, "honda_civic_touring_2016_can_generated.dbc"))
@ -38,8 +36,7 @@ def car_plant(pos, speed, grade, gas, brake):
speed_base = power_peak/force_peak speed_base = power_peak/force_peak
rolling_res = 0.01 rolling_res = 0.01
g = 9.81 g = 9.81
wheel_r = 0.31 #frontal_area = 2.2 TODO: use it!
frontal_area = 2.2
air_density = 1.225 air_density = 1.225
gas_to_peak_linear_slope = 3.33 gas_to_peak_linear_slope = 3.33
brake_to_peak_linear_slope = 0.3 brake_to_peak_linear_slope = 0.3
@ -191,7 +188,6 @@ class Plant(object):
# ******** run the car ******** # ******** run the car ********
speed, acceleration = car_plant(self.distance_prev, self.speed_prev, grade, gas, brake) speed, acceleration = car_plant(self.distance_prev, self.speed_prev, grade, gas, brake)
standstill = (speed == 0)
distance = self.distance_prev + speed * self.ts distance = self.distance_prev + speed * self.ts
speed = self.speed_prev + self.ts * acceleration speed = self.speed_prev + self.ts * acceleration
if speed <= 0: if speed <= 0:
@ -208,7 +204,6 @@ class Plant(object):
else: else:
d_rel = 200. d_rel = 200.
v_rel = 0. v_rel = 0.
a_rel = 0
lateral_pos_rel = 0. lateral_pos_rel = 0.
# print at 5hz # print at 5hz
@ -312,10 +307,6 @@ class Plant(object):
def plant_thread(rate=100): def plant_thread(rate=100):
plant = Plant(rate) plant = Plant(rate)
while 1: while 1:
if plant.rk.frame%100 >= 20 and plant.rk.frame%100 <= 25:
cruise_buttons = CruiseButtons.RES_ACCEL
else:
cruise_buttons = 0
plant.step() plant.step()
if __name__ == "__main__": if __name__ == "__main__":

@ -4,7 +4,6 @@ os.environ['FAKEUPLOAD'] = "1"
from common.testing import phone_only from common.testing import phone_only
from selfdrive.manager import manager_init, manager_prepare from selfdrive.manager import manager_init, manager_prepare
from selfdrive.manager import start_managed_process, kill_managed_process, get_running from selfdrive.manager import start_managed_process, kill_managed_process, get_running
from selfdrive.config import CruiseButtons
from functools import wraps from functools import wraps
import time import time

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:bb6cd32436a8c4c5d6170222105997ab66d395974dca6e15758e9d9d49ce991e oid sha256:1625ce5b2a59f2a67882f9ae909096a752c4964700e38bf01aa46bf176d6c0b5
size 13345424 size 13345424

Loading…
Cancel
Save