services.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/usr/bin/env python3
  2. from typing import Optional
  3. class Service:
  4. def __init__(self, should_log: bool, frequency: float, decimation: Optional[int] = None):
  5. self.should_log = should_log
  6. self.frequency = frequency
  7. self.decimation = decimation
  8. _services: dict[str, tuple] = {
  9. # service: (should_log, frequency, qlog decimation (optional))
  10. # note: the "EncodeIdx" packets will still be in the log
  11. "gyroscope": (True, 104., 104),
  12. "gyroscope2": (True, 100., 100),
  13. "accelerometer": (True, 104., 104),
  14. "accelerometer2": (True, 100., 100),
  15. "magnetometer": (True, 25.),
  16. "lightSensor": (True, 100., 100),
  17. "temperatureSensor": (True, 2., 200),
  18. "temperatureSensor2": (True, 2., 200),
  19. "gpsNMEA": (True, 9.),
  20. "deviceState": (True, 2., 1),
  21. "can": (True, 100., 2053), # decimation gives ~3 msgs in a full segment
  22. "controlsState": (True, 100., 10),
  23. "selfdriveState": (True, 100., 10),
  24. "pandaStates": (True, 10., 1),
  25. "peripheralState": (True, 2., 1),
  26. "radarState": (True, 20., 5),
  27. "roadEncodeIdx": (False, 20., 1),
  28. "liveTracks": (True, 20.),
  29. "sendcan": (True, 100., 139),
  30. "logMessage": (True, 0.),
  31. "errorLogMessage": (True, 0., 1),
  32. "liveCalibration": (True, 4., 4),
  33. "liveTorqueParameters": (True, 4., 1),
  34. "androidLog": (True, 0.),
  35. "carState": (True, 100., 10),
  36. "carControl": (True, 100., 10),
  37. "carOutput": (True, 100., 10),
  38. "longitudinalPlan": (True, 20., 10),
  39. "driverAssistance": (True, 20., 20),
  40. "procLog": (True, 0.5, 15),
  41. "gpsLocationExternal": (True, 10., 10),
  42. "gpsLocation": (True, 1., 1),
  43. "ubloxGnss": (True, 10.),
  44. "qcomGnss": (True, 2.),
  45. "gnssMeasurements": (True, 10., 10),
  46. "clocks": (True, 0.1, 1),
  47. "ubloxRaw": (True, 20.),
  48. "livePose": (True, 20., 4),
  49. "liveParameters": (True, 20., 5),
  50. "cameraOdometry": (True, 20., 10),
  51. "thumbnail": (True, 0.2, 1),
  52. "onroadEvents": (True, 1., 1),
  53. "carParams": (True, 0.02, 1),
  54. "roadCameraState": (True, 20., 20),
  55. "driverCameraState": (True, 20., 20),
  56. "driverEncodeIdx": (False, 20., 1),
  57. "driverStateV2": (True, 20., 10),
  58. "driverMonitoringState": (True, 20., 10),
  59. "wideRoadEncodeIdx": (False, 20., 1),
  60. "wideRoadCameraState": (True, 20., 20),
  61. "drivingModelData": (True, 20., 10),
  62. "modelV2": (True, 20.),
  63. "managerState": (True, 2., 1),
  64. "uploaderState": (True, 0., 1),
  65. "navInstruction": (True, 1., 10),
  66. "navRoute": (True, 0.),
  67. "navThumbnail": (True, 0.),
  68. "qRoadEncodeIdx": (False, 20.),
  69. "userFlag": (True, 0., 1),
  70. "microphone": (True, 10., 10),
  71. # debug
  72. "uiDebug": (True, 0., 1),
  73. "testJoystick": (True, 0.),
  74. "alertDebug": (True, 20., 5),
  75. "roadEncodeData": (False, 20.),
  76. "driverEncodeData": (False, 20.),
  77. "wideRoadEncodeData": (False, 20.),
  78. "qRoadEncodeData": (False, 20.),
  79. "livestreamWideRoadEncodeIdx": (False, 20.),
  80. "livestreamRoadEncodeIdx": (False, 20.),
  81. "livestreamDriverEncodeIdx": (False, 20.),
  82. "livestreamWideRoadEncodeData": (False, 20.),
  83. "livestreamRoadEncodeData": (False, 20.),
  84. "livestreamDriverEncodeData": (False, 20.),
  85. "customReservedRawData0": (True, 0.),
  86. "customReservedRawData1": (True, 0.),
  87. "customReservedRawData2": (True, 0.),
  88. }
  89. SERVICE_LIST = {name: Service(*vals) for
  90. idx, (name, vals) in enumerate(_services.items())}
  91. def build_header():
  92. h = ""
  93. h += "/* THIS IS AN AUTOGENERATED FILE, PLEASE EDIT services.py */\n"
  94. h += "#ifndef __SERVICES_H\n"
  95. h += "#define __SERVICES_H\n"
  96. h += "#include <map>\n"
  97. h += "#include <string>\n"
  98. h += "struct service { std::string name; bool should_log; int frequency; int decimation; };\n"
  99. h += "static std::map<std::string, service> services = {\n"
  100. for k, v in SERVICE_LIST.items():
  101. should_log = "true" if v.should_log else "false"
  102. decimation = -1 if v.decimation is None else v.decimation
  103. h += ' { "%s", {"%s", %s, %d, %d}},\n' % \
  104. (k, k, should_log, v.frequency, decimation)
  105. h += "};\n"
  106. h += "#endif\n"
  107. return h
  108. if __name__ == "__main__":
  109. print(build_header())