pji_run_test.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ##################################################################
  4. #
  5. # Copyright (c) 2023 CICV, Inc. All Rights Reserved
  6. #
  7. ##################################################################
  8. """
  9. @Authors: yangzihao(yangzihao@china-icv.cn)
  10. @Data: 2024/04/21
  11. @Last Modified: 2024/04/21
  12. @Summary: Evaluation entrance
  13. """
  14. import os
  15. import sys
  16. import time
  17. from single_case_eval import single_case_eval
  18. from common import get_subfolders_name
  19. # from pjirebot_evaluate_csv import parsebag
  20. import log
  21. if __name__ == "__main__":
  22. from warnings import simplefilter
  23. # simplefilter(action="ignore", category=FutureWarning)
  24. simplefilter(action="ignore")
  25. # TODO:优化输入为dict
  26. # input_dict = {
  27. # "data_path": dataPath,
  28. # "resultPath": resultPath,
  29. # "trackPath": trackPath
  30. # }
  31. # if len(sys.argv) >= 3:
  32. # dataPath = sys.argv[1]
  33. # resultPath = sys.argv[2]
  34. # trackPath = sys.argv[3]
  35. # if len(sys.argv) > 4:
  36. # case_name = sys.argv[4]
  37. # else:
  38. # case_name = dataPath.split('/')[-1] # .split('.')[0]
  39. #
  40. # # logFileName = f'{resultPath}/log.log'
  41. # logFileName = os.path.join(resultPath, 'log.log')
  42. # log.setup_logger(logFileName)
  43. # logger = log.get_logger()
  44. #
  45. # if not os.path.exists(dataPath):
  46. # print('Invalid dataPath!')
  47. # logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid dataPath!")
  48. # sys.exit(-1)
  49. # else:
  50. # try:
  51. # logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  52. # print("SINGLE_CASE_EVAL程序开始运行:")
  53. # configPath = r"./config.json"
  54. # print(
  55. # f" configPath: {configPath},\n dataPath: {dataPath},\n resultPath: {resultPath},\n trackPath: {trackPath}")
  56. # t1 = time.time()
  57. # parsebag(dataPath, resultPath) # EgoState_pji.csv存放resultPath下
  58. # single_case_eval(configPath, resultPath, resultPath, trackPath, case_name)
  59. # t2 = time.time()
  60. # print(f"程序结束,执行时间:{int(t2 - t1)} s")
  61. # logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")
  62. # sys.exit(0)
  63. # except Exception as e:
  64. # print("异常,退出...")
  65. # print(repr(e))
  66. # sys.exit(-1)
  67. # else:
  68. # print('No enough arguments!')
  69. # sys.exit(-1)
  70. # dataPath = './bag/2024-04-22-08-48-30_obstacledetection_30.bag'
  71. # dataPath = './task/case0613'
  72. dataPath = './task/case0730'
  73. # resultPath = './result/integration'
  74. resultPath = dataPath
  75. trackPath = f'{dataPath}/trajectory.png'
  76. logFileName = f'{resultPath}/log.log'
  77. log.setup_logger(logFileName)
  78. logger = log.get_logger()
  79. case_name = dataPath.split('/')[-1].split('.')[0]
  80. # case_name = os.path.basename(os.path.dirname(dataPath))
  81. if not os.path.exists(dataPath):
  82. print('Invalid dataPath!')
  83. logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid dataPath!")
  84. sys.exit(-1)
  85. else:
  86. try:
  87. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  88. print("SINGLE_CASE_EVAL程序开始运行:")
  89. # configPath = r"./config_comfort.json"
  90. # configPath = r"./config_safe.json"
  91. # configPath = r"./config_accurate.json"
  92. configPath = r"./config_0627.json"
  93. print(f" configPath: {configPath},\n resultPath: {resultPath}")
  94. t1 = time.time()
  95. # parsebag(dataPath, resultPath)
  96. single_case_eval(configPath, resultPath, resultPath, trackPath, case_name)
  97. t2 = time.time()
  98. print(f"程序结束,执行时间:{int(t2 - t1)} s")
  99. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")
  100. sys.exit(0)
  101. except Exception as e:
  102. print("异常,退出...")
  103. print(repr(e))
  104. sys.exit(-1)