pji_run.py 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. if len(sys.argv) >= 3:
  23. bagPath = sys.argv[1]
  24. resultPath = sys.argv[2]
  25. # graphPath = sys.argv[3]
  26. logFileName = f'{resultPath}/log.txt'
  27. log.setup_logger(logFileName)
  28. logger = log.get_logger()
  29. case_name = bagPath.split('/')[-1].split('.')[0]
  30. # case_name = os.path.basename(os.path.dirname(dataPath))
  31. if not os.path.exists(bagPath):
  32. print('Invalid bagPath!')
  33. logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid bagPath!")
  34. sys.exit(-1)
  35. else:
  36. try:
  37. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  38. print("SINGLE_CASE_EVAL程序开始运行:")
  39. configPath = r"./config.json"
  40. print(f" configPath: {configPath},\n resultPath: {resultPath}")
  41. t1 = time.time()
  42. parsebag(bagPath, resultPath)
  43. single_case_eval(configPath, resultPath, case_name)
  44. t2 = time.time()
  45. print(f"程序结束,执行时间:{int(t2 - t1)} s")
  46. logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")
  47. sys.exit(0)
  48. except Exception as e:
  49. print("异常,退出...")
  50. print(repr(e))
  51. sys.exit(-1)
  52. else:
  53. print('No enough arguments!')
  54. sys.exit(-1)
  55. # bagPath = './bag/2024-04-22-08-48-30_obstacledetection_30.bag'
  56. # resultPath = './result/integration'
  57. #
  58. # logFileName = f'{resultPath}/log.txt'
  59. # log.setup_logger(logFileName)
  60. # logger = log.get_logger()
  61. #
  62. # case_name = bagPath.split('/')[-1].split('.')[0]
  63. # # case_name = os.path.basename(os.path.dirname(dataPath))
  64. #
  65. # if not os.path.exists(bagPath):
  66. # print('Invalid bagPath!')
  67. # logger.error(f"[case:{case_name}] SINGLE_CASE_EVAL: Invalid bagPath!")
  68. # sys.exit(-1)
  69. # else:
  70. # try:
  71. # logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: Start evaluating:")
  72. # print("SINGLE_CASE_EVAL程序开始运行:")
  73. # configPath = r"./config.json"
  74. # print(f" configPath: {configPath},\n resultPath: {resultPath}")
  75. # t1 = time.time()
  76. # parsebag(bagPath, resultPath)
  77. # single_case_eval(configPath, resultPath, case_name)
  78. # t2 = time.time()
  79. # print(f"程序结束,执行时间:{int(t2 - t1)} s")
  80. # logger.info(f"[case:{case_name}] SINGLE_CASE_EVAL: End.")
  81. # sys.exit(0)
  82. # except Exception as e:
  83. # print("异常,退出...")
  84. # print(repr(e))
  85. # sys.exit(-1)