LingxinMeng 6 meses atrás
pai
commit
219043ce19
44 arquivos alterados com 1247 adições e 293 exclusões
  1. 2 0
      .gitignore
  2. 1 1
      README.md
  3. 2 1
      src/python2/pjibot/camera-errorBag.json
  4. 25 24
      src/python2/pjibot/csv-errorBag.json
  5. 2 0
      src/python2/pjibot/merge-nohup.sh
  6. 0 15
      src/python2/pjibot/merge-pjibot_guide.py
  7. 34 36
      src/python2/pjibot_delivery/2callback-pjibot_delivery.py
  8. 9 0
      src/python2/pjibot_delivery/2camera-nohup.sh
  9. 92 0
      src/python2/pjibot_delivery/2camera-pjibot_delivery.py
  10. 2 2
      src/python2/pjibot_delivery/2pcd-pjibot_delivery.py
  11. 0 0
      src/python2/pjibot_delivery/2simulation-errorBag.json
  12. 1 1
      src/python2/pjibot_delivery/2simulation-nohup.sh
  13. 38 44
      src/python2/pjibot_delivery/callback-pjibot_delivery.py
  14. 2 1
      src/python2/pjibot_delivery/csv-errorBag.json
  15. 1 1
      src/python2/pjibot_delivery/pcd-pjibot_delivery.py
  16. 100 22
      src/python2/pjibot_delivery/resource/parse_robot_image.py
  17. 23 7
      src/python2/pjibot_delivery/resource/pcdtovideo_monitor_overlook.py
  18. 3 1
      src/python2/pjibot_delivery/xosc-errorBag.json
  19. 9 0
      src/python2/pjibot_patrol/2callback-nohup.sh
  20. 167 0
      src/python2/pjibot_patrol/2callback-pjibot_patrol.py
  21. 11 0
      src/python2/pjibot_patrol/2csv-errorBag.json
  22. 9 0
      src/python2/pjibot_patrol/2csv-nohup.sh
  23. 202 0
      src/python2/pjibot_patrol/2csv-pjibot_patrol.py
  24. 9 0
      src/python2/pjibot_patrol/2pcd-nohup.sh
  25. 93 0
      src/python2/pjibot_patrol/2pcd-pjibot_patrol.py
  26. 9 0
      src/python2/pjibot_patrol/2simulation-nohup.sh
  27. 159 0
      src/python2/pjibot_patrol/2simulation-pjibot_patrol.py
  28. 0 0
      src/python2/pjibot_patrol/2xosc-errorBag.json
  29. 9 0
      src/python2/pjibot_patrol/2xosc-nohup.sh
  30. 131 0
      src/python2/pjibot_patrol/2xosc-pjibot_patrol.py
  31. 1 1
      src/python2/pjibot_patrol/callback-nohup.sh
  32. 40 38
      src/python2/pjibot_patrol/callback-pjibot_patrol.py
  33. 4 0
      src/python2/pjibot_patrol/csv-errorBag.json
  34. 2 1
      src/python2/pjibot_patrol/csv-nohup.sh
  35. 2 1
      src/python2/pjibot_patrol/merge-nohup.sh
  36. 1 0
      src/python2/pjibot_patrol/pcd-nohup.sh
  37. 1 1
      src/python2/pjibot_patrol/pcd-pjibot_patrol.py
  38. 0 73
      src/python2/pjibot_patrol/resource/parse_robot_image.py
  39. 23 7
      src/python2/pjibot_patrol/resource/pcdtovideo_monitor_overlook.py
  40. 1 1
      src/python2/pjibot_patrol/simulation-nohup.sh
  41. 18 9
      src/python2/pjibot_patrol/simulation-pjibot_patrol.py
  42. 4 0
      src/python2/pjibot_patrol/xosc-errorBag.json
  43. 1 1
      src/python2/pjibot_patrol/xosc-nohup.sh
  44. 4 4
      src/python2/pjibot_patrol/xosc-pjibot_patrol.py

+ 2 - 0
.gitignore

@@ -10,6 +10,8 @@ src/python2/pjibot_delivery/pjibot_delivery
 src/python2/pjibot_delivery/2csv
 src/python2/pjibot_patrol/camera
 src/python2/pjibot_patrol/csv
+src/python2/pjibot_patrol/pcd
+src/python2/pjibot_patrol/2csv
 src/python2/pjibot_patrol/log
 src/python2/pjibot_patrol/pjibot_patrol
 src/python2/pjisuv/camera

+ 1 - 1
README.md

@@ -2,7 +2,7 @@
 vtd1 : 朴津系统室外配送机器人
 vtd2 : 国汽系统室外配送机器人
 vtd3 : 国汽系统多功能车
-vtd4 : 朴津系统室外巡检机器人
+vtd4 : 朴津系统室外巡检机器人 & 国汽系统室外巡检机器人
 
 # 已实现的错误处理方式
 xosc-pjisuv.py

+ 2 - 1
src/python2/pjibot/camera-errorBag.json

@@ -61,5 +61,6 @@
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-45-29/", 
     "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-29-09-46-26_obstacledetection_42/", 
     "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-29-11-18-30_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-12-05-07-17-30_obstacledetection_60/"
+    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-12-05-07-17-30_obstacledetection_60/", 
+    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-12-05-16-03-53_obstacledetection_37/"
 ]

+ 25 - 24
src/python2/pjibot/csv-errorBag.json

@@ -1,14 +1,13 @@
 [
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-13-05-05_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-10-48-35_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-11-52-13_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-00-48-28_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-21-22-14_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-07-04-02-26-31_obstacledetection_38/", 
+    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-12-05-07-17-30_obstacledetection_60/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-23-01-17_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-19-34-05_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-10-28-16-09-39_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-40-28/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-22-11-48_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-43-02/", 
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/2024-09-04-10-54-22_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-08-06-00-38-07_obstacledetection_30/", 
@@ -17,14 +16,16 @@
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-12-41-00_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-13-16-13_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-19-46-25_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-12-05-16-03-53_obstacledetection_37/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-23-00-07_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-09-55-16_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-22-28-41_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-20-35-53_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-07-07-09-53-10_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-15-10-53-53_obstacledetection_44/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-13-17-07_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-15-10-36-14_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-32-26/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-00-52-30_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000116/data_parse/2024-11-07-16-39-17_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-11-32-18_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-19-06-36_obstacledetection_30/", 
@@ -32,55 +33,55 @@
     "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-29-11-18-30_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-12-19-33_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-30-25/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-08-57-58_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-11-39-55/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-21-30-22_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-13-44-54_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-01-19-13_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-13-04-24_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-18-12-00-09_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-14-07-41_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-11-18-07_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-34-00/", 
+    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-47-59/", 
     "pjibot/pjibot-P1YNYD1M229000131/data_parse/2024-11-11-02-45-56_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-07-09-14-21-48_obstacledetection_67/", 
     "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-29-09-46-26_obstacledetection_42/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-01-19-13_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-08-13-16-01-31_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-22-11-48_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-23-06-46_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-12-03-18-13-53_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-10-10-02-45-27_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-14-06-34_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M229000131/data_parse/2024-11-11-02-40-36_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-22-30-14_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-20-45-18_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-11-39-28_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-08-05-21-49-38_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-31-10/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-01-17-06_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-12-05-07-17-30_obstacledetection_60/", 
+    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-07-04-02-26-31_obstacledetection_38/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-08-39-25_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-23-06-18_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-08-07-07-16-11_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-23-25-14_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-15-10-53-53_obstacledetection_44/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-11-39-28_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-12-46-11_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-07-07-09-53-10_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-08-57-58_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-10-27-21-12-31_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-23-06-46_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-20-45-18_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-08-13-16-01-31_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-14-06-34_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-12-30-47_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-11-54-16_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-20-04-39_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-07-07-09-31-48_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-00-48-28_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-11-52-13_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-12-09-44-23_obstacledetection_29/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-19-22-44_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-22-26-32_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-45-29/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-00-19-05_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-11-18-47_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M228000127/data_parse/2024-07-09-09-53-21_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-27-25/", 
-    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-47-59/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-05-22-30-14_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-14-17-59-21_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-34-00/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-00-19-05_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-07-09-14-21-33_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M229000131/data_parse/2024-11-11-02-40-36_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-12-46-11_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M227000116/data_parse/2024-10-29-09-00-48_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-31-10/", 
-    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-06-00-52-30_obstacledetection_30/"
+    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-11-14-17-59-21_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M227000115/data_parse/2024-09-03-13-44-54_obstacledetection_30/"
 ]

+ 2 - 0
src/python2/pjibot/merge-nohup.sh

@@ -5,4 +5,6 @@ if [ ! -d "./log" ]; then
 else
     echo "Directory './log' already exists."
 fi
+rm -rf log/merge*
+source /root/workspace/devel/setup.sh
 nohup python2 merge-pjibot_guide.py > log/merge-pjibot_guide.out 2>&1 &

+ 0 - 15
src/python2/pjibot/merge-pjibot_guide.py

@@ -72,29 +72,14 @@ def merge(local_bags, merged_prefix, local_merged_dir, merged_bag_name):
         logging.info("map.bag包的key为: %s" % str(map_key))
         bucket.get_object_to_file(map_key, local_map_path)
         jpg_file = local_merged_dir + merged_bag_name.split('.')[0] + '.jpg'
-        # 构建命令
         command1 = ['rosrun', 'trajectory', 'demo_node', local_map_path, output_bag_file, jpg_file]
-
-        # 记录命令
         logging.info("调用命令轨迹图片生成命令: %s" % ' '.join(command1))
-
-        # 使用 subprocess.Popen 来执行命令,并捕获输出和错误
         process = subprocess.Popen(command1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         stdout, stderr = process.communicate()
-
-        # 记录命令的标准输出
         if stdout:
             logging.info("命令输出:\n%s" % stdout.strip())
-
-        # 记录命令的标准错误输出
         if stderr:
             logging.error("命令错误:\n%s" % stderr.strip())
-
-        # 检查命令的返回码
-        if process.returncode != 0:
-            logging.error("命令执行失败,返回码: %d" % process.returncode)
-        else:
-            logging.info("命令执行成功")
         jpg_key = parse_prefix + 'track.png'
         bucket.put_object_from_file(jpg_key, jpg_file)
 

+ 34 - 36
src/python2/pjibot_delivery/2callback-pjibot_delivery.py

@@ -6,9 +6,14 @@ import json
 import time
 import urllib2
 import oss2
-from datetime import datetime, timedelta
 import logging
+from datetime import datetime, timedelta
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket_name = 'open-bucket'
+bucket = oss2.Bucket(auth, endpoint, bucket_name)
 path1 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_delivery/'
+path3 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_delivery/2callback/'
 logging.basicConfig(filename=path1 + 'log/2callback-pjibot_delivery.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
 key1 = 'pjibot_delivery/'
 key2 = 'data/'
@@ -20,34 +25,34 @@ path4 = 'data_parse/'
 url1_private = "http://10.14.86.127:9081/device/auth"
 url2_private = "http://10.14.86.127:9081/device/data/callback"
 
-
 def add_hour(date_string, hour_number):
     original_date = datetime.strptime(date_string, "%Y-%m-%d-%H-%M-%S")
     new_date = original_date + timedelta(hours=hour_number)
     return new_date.strftime("%Y-%m-%d-%H-%M-%S")
 
+def judge_pcd(callback_json_oss_key):
+    json_content = bucket.get_object(callback_json_oss_key).read()
+    json_object = json.loads(json_content)
+    check = json_object['check']
+    if '点云缺失' in check:
+        return True
+
 
 if __name__ == '__main__':
-    auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
-    endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
-    bucket_name = 'open-bucket'
-    bucket = oss2.Bucket(auth, endpoint, bucket_name)
     while True:
         logging.info("开始新一轮扫描")
         try:
             local_delete_list = []
             oss_delete_list = []
             upload_completed_prefix_list = []
-            # 4 获取即将被合并的bag目录
             for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
                 try:
                     if 'callback.json' in str(obj1.key):
                         prefix = '/'.join(str(obj1.key).split('/')[:-1])
-
                         file1 = False
                         file2 = False
                         file3 = False
-                        file4 = False
+                        pcd_ok = False
                         file5 = False
                         file7 = False
                         file8 = False
@@ -55,12 +60,13 @@ if __name__ == '__main__':
                         for obj2 in oss2.ObjectIterator(bucket, prefix=prefix + '/'):
                             if '/callback_done.json' in str(obj2.key):
                                 file1 = True
+                                break
                             if '/ego_pji.csv' in str(obj2.key):
                                 file2 = True
                             if '/objects_pji.csv' in str(obj2.key):
                                 file3 = True
                             if '/pcd_overlook.mp4' in str(obj2.key):
-                                file4 = True
+                                pcd_ok = True
                             if '/drive.csv' in str(obj2.key):
                                 file5 = True
                             if '/scenario_orig.mp4' in str(obj2.key):
@@ -69,45 +75,36 @@ if __name__ == '__main__':
                                 file8 = True
                             if '/trajectory_pji.csv' in str(obj2.key):
                                 file9 = True
-                        if file1 or not file2 or not file3 or not file4 or not file5 or not file7 or not file8 or not file9:
+                        if not pcd_ok:
+                            pcd_ok = judge_pcd(str(obj1.key))
+                        if file1 or not file2 or not file3 or not pcd_ok or not file5 or not file7 or not file8 or not file9:
                             continue
                         time.sleep(1)
                         logging.info("发送:%s", prefix)
-                        # 1 获取json内容
                         json_content = bucket.get_object(str(obj1.key)).read()
-                        # 2 获取token
                         json_object = json.loads(json_content)
-                        data1 = {
-                            "equipmentNo": json_object['equipmentNo'],
-                            "secretKey": json_object['secretKey']
-                        }
+                        data1 = {"equipmentNo": json_object['equipmentNo'],"secretKey": json_object['secretKey']}
                         json_data1 = json.dumps(data1)
                         logging.info("授权接口请求中: %s" % url1_private)
                         logging.info("授权发送参数为: %s" % str(data1))
-                        request1 = urllib2.Request(url1_private, json_data1,
-                                                   headers={'Content-Type': 'application/json'})
+                        request1 = urllib2.Request(url1_private, json_data1,headers={'Content-Type': 'application/json'})
                         response1 = urllib2.urlopen(request1)
                         result_json1 = response1.read()
                         result_object1 = json.loads(result_json1)
                         logging.info("授权接口请求结果为: %s", result_object1)
                         access_token = result_object1.get('data').get('accessToken')
-                        # 要发送的JSON参数
-                        try:
-                            old_date = json_object['dataName']
-                            data_size = bucket.get_object_meta(json_object['rosBagPath']).content_length
-                            equipment_no = json_object['equipmentNo']
-                            old_file_path = json_object['filePath']
-                            old_ros_bag_path = json_object['rosBagPath']
-                            task_id = json_object['taskId']
-                            trigger_id = json_object['triggerId']
-                            check = json_object['check']
-                            check_order = ['自车数据缺失', '不在道路范围', '无规划路径', '目标点缺失','点云缺失', '点云丢帧', '解析程序错误', '还原程序错误', '评价程序错误']
-                            check_order_dict = dict((item, idx) for idx, item in enumerate(check_order))
-                            check = sorted(check, key=lambda x: check_order_dict.get(x, float('inf')))
-                            check = ','.join(check) # 数组元素拼接成字符串序列
-                        except Exception as e:
-                            logging.exception("callback报错:%s", str(e))
-                            continue
+                        old_date = json_object['dataName']
+                        data_size = bucket.get_object_meta(json_object['rosBagPath']).content_length
+                        equipment_no = json_object['equipmentNo']
+                        old_file_path = json_object['filePath']
+                        old_ros_bag_path = json_object['rosBagPath']
+                        task_id = json_object['taskId']
+                        trigger_id = json_object['triggerId']
+                        check = json_object['check']
+                        check_order = ['自车数据缺失', '不在道路范围', '无规划路径', '目标点缺失','点云缺失', '点云丢帧', '解析程序错误', '还原程序错误', '评价程序错误']
+                        check_order_dict = dict((item, idx) for idx, item in enumerate(check_order))
+                        check = sorted(check, key=lambda x: check_order_dict.get(x, float('inf')))
+                        check = ','.join(check) # 数组元素拼接成字符串序列
                         if old_date is None:
                             old_date = ''
                         # 将时区统一(室外不需要需要加8,根据机器人终端的时区判断)
@@ -164,6 +161,7 @@ if __name__ == '__main__':
                         logging.info("回调接口请求结果为: %s", result_object2)
                 except Exception as e:
                     logging.exception("局部异常处理: %s" % str(e))
+                    continue
             time.sleep(10)
         except Exception as e:
             logging.exception("全局错误处理: %s" % str(e))

+ 9 - 0
src/python2/pjibot_delivery/2camera-nohup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+if [ ! -d "./log" ]; then
+    mkdir "./log"
+    echo "Directory './log' created."
+else
+    echo "Directory './log' already exists."
+fi
+rm -rf log/camera*
+nohup python2 camera-pjibot_delivery.py > log/camera-pjibot_delivery.out 2>&1 &

+ 92 - 0
src/python2/pjibot_delivery/2camera-pjibot_delivery.py

@@ -0,0 +1,92 @@
+# -*- coding: utf-8 -*-
+# ------- 全局配置 -------
+import os
+import time
+import oss2
+import logging
+from resource import parse_robot_image
+from utils import json_utils
+path1 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_delivery/'
+logging.basicConfig(filename=path1 + 'log/2camera-pjibot_delivery.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
+key1 = 'pjibot_delivery/'
+sleep_time = 10  # 每多少秒扫描一次
+error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot_delivery/2camera-errorBag.json"
+# 1 创建阿里云对象
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket = oss2.Bucket(auth, endpoint, 'open-bucket')
+# ------- 全局配置 -------
+
+def parse_to_mp4(merged_bag_file_path, parse_prefix1, local_parse_dir2, local_delete_list3):
+    mp4_file_name = 'camera'
+    local_mp4_file_path1 = local_mp4_dir + '/' + mp4_file_name + '.mp4'
+    oss_csv_object_key1 = parse_prefix1 + mp4_file_name + '.mp4'
+    try:
+        flag, local_mp4_dir = parse_robot_image.parse(merged_bag_file_path, local_parse_dir2 + '/camera/')
+        if flag:  # 没有话题就不生成视频了
+            bucket.put_object_from_file(oss_csv_object_key1, local_mp4_file_path1)
+            logging.info("上传 camera.mp4 成功: %s", str(oss_csv_object_key1))
+        else:
+            json_utils.add_error(parse_prefix1,error_bag_json)
+            logging.info("没有图像话题: %s", merged_bag_file_path)
+    except Exception as e2:
+        json_utils.add_error(parse_prefix1,error_bag_json)
+        logging.exception("生成摄像头视频报错: %s", e2)
+    finally:
+        local_delete_list3.append(local_mp4_file_path1)
+        local_delete_list.append(local_merged_bag_path)
+
+def judge(parse_prefix_full):
+    camera_done = False
+    for obj2 in oss2.ObjectIterator(bucket, prefix=parse_prefix_full):
+        if '/camera.mp4' in str(obj2.key):
+            camera_done = True
+    if camera_done:
+        return True
+    
+def end_delete(local_delete_list):
+    # 删除本地临时文件
+    if len(local_delete_list) > 0:
+        for local_delete in local_delete_list:
+            try:
+                os.remove(local_delete)
+            except Exception as e:
+                pass
+
+# ------- 获取合并之后的bag包,解析出csv -------
+if __name__ == '__main__':
+    try:
+        while True:
+            logging.info("开始新一轮扫描")
+            local_delete_list = []
+            oss_delete_list = []
+            prefix_list = []
+            for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
+                try:
+                    merged_bag_object_key = str(obj1.key)
+                    if 'data_merge' in str(obj1.key) and str(obj1.key).endswith('.bag'):
+                        merged_bag_object_key_split = merged_bag_object_key.split('/')
+                        merged_prefix = '/'.join(merged_bag_object_key_split[:-1])
+                        parse_prefix = merged_prefix.replace('data_merge', 'data_parse')
+                        parse_prefix_full = merged_bag_object_key.replace('data_merge', 'data_parse')[:-4] + '/'
+                        if judge():
+                            continue
+                        local_merged_bag_path = path1 + 'camera/' + merged_bag_object_key
+                        local_merged_dir = '/'.join(local_merged_bag_path.split('/')[:-1])
+                        local_parse_dir = local_merged_dir.replace('data_merge', 'data_parse')
+                        if not os.path.exists(local_merged_dir):
+                            os.makedirs(local_merged_dir)
+                        if not os.path.exists(local_parse_dir):
+                            os.makedirs(local_parse_dir)
+                        merged_bag_full_name = merged_bag_object_key_split[-1]
+                        merged_bag_name = merged_bag_full_name.split('.')[0]
+                        bucket.get_object_to_file(merged_bag_object_key, local_merged_bag_path)
+                        logging.info("生成视频: %s" % str(obj1.key))
+                        parse_to_mp4(local_merged_bag_path, parse_prefix_full, local_parse_dir, local_delete_list)
+                except Exception as e:
+                    logging.exception("局部异常处理: %s" % str(e))
+                    continue
+                end_delete()
+                time.sleep(sleep_time)
+    except Exception as e:
+        logging.exception("全局错误处理: %s" % str(e))

+ 2 - 2
src/python2/pjibot_delivery/2pcd-pjibot_delivery.py

@@ -25,7 +25,7 @@ def parse_to_pcd_mp4(merged_bag_file_path, parse_prefix2, local_parse_dir, local
     try:
         local_pcd_mp4_dir = pcdtovideo_monitor_overlook.parse(merged_bag_file_path, local_parse_dir + '/pcd/')
         pcd_mp4_file_name = 'pcd_overlook'
-        local_mp4_path = str(local_pcd_mp4_dir) + '/jpg/'+pcd_mp4_file_name+'.mp4'
+        local_mp4_path = str(local_pcd_mp4_dir) + '/'+pcd_mp4_file_name+'.mp4'
         oss_csv_object_key3 = parse_prefix2 + pcd_mp4_file_name + '.mp4'
         bucket.put_object_from_file(oss_csv_object_key3, local_mp4_path)
         logging.info("上传点云视频到: %s", oss_csv_object_key3)
@@ -87,7 +87,7 @@ if __name__ == '__main__':
                     try:
                         os.remove(local_delete)
                     except Exception as e:
-                        logging.exception("删除本地临时文件报错: %s" % str(e))
+                        pass
             time.sleep(sleep_time)
         except Exception as e:
             logging.exception("全局异常处理: %s" % str(e))

+ 0 - 0
src/python2/pjibot_delivery/2simulation-errorBag.json


+ 1 - 1
src/python2/pjibot_delivery/2simulation-nohup.sh

@@ -5,5 +5,5 @@ if [ ! -d "./log" ]; then
 else
     echo "Directory './log' already exists."
 fi
-rm -rf log/2simulation-pjibot_delivery.out log/2simulation-pjibot_delivery.log
+rm -rf log/2simulation*
 nohup python2 2simulation-pjibot_delivery.py > log/2simulation-pjibot_delivery.out 2>&1 &

+ 38 - 44
src/python2/pjibot_delivery/callback-pjibot_delivery.py

@@ -6,15 +6,15 @@ import json
 import time
 import urllib2
 import oss2
-from datetime import datetime, timedelta
-
 import logging
-
+from datetime import datetime, timedelta
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket_name = 'pji-bucket1'
+bucket = oss2.Bucket(auth, endpoint, bucket_name)
 path1 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_delivery/'
-
-logging.basicConfig(filename=path1 + 'log/callback-pjibot_delivery.log', level=logging.INFO,
-                    format='%(asctime)s - %(levelname)s - %(message)s')
-
+path3 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_delivery/callback/'
+logging.basicConfig(filename=path1 + 'log/callback-pjibot_delivery.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
 key1 = 'pjibot_delivery/'
 key2 = 'data/'
 key3 = 'data_merge/'
@@ -31,41 +31,43 @@ def add_hour(date_string, hour_number):
     new_date = original_date + timedelta(hours=hour_number)
     return new_date.strftime("%Y-%m-%d-%H-%M-%S")
 
+def judge_pcd(callback_json_oss_key):
+    json_content = bucket.get_object(callback_json_oss_key).read()
+    json_object = json.loads(json_content)
+    check = json_object['check']
+    if '点云缺失' in check:
+        return True
+
 
 if __name__ == '__main__':
-    auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
-    endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
-    bucket_name = 'pji-bucket1'
-    bucket = oss2.Bucket(auth, endpoint, bucket_name)
     while True:
         logging.info("开始新一轮扫描")
         try:
             local_delete_list = []
             oss_delete_list = []
             upload_completed_prefix_list = []
-            # 4 获取即将被合并的bag目录
             for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
                 try:
                     if 'callback.json' in str(obj1.key):
                         prefix = '/'.join(str(obj1.key).split('/')[:-1])
-
                         file1 = False
                         file2 = False
                         file3 = False
-                        file4 = False
+                        pcd_ok = False
                         file5 = False
                         file7 = False
                         file8 = False
                         file9 = False
-                        for obj2 in oss2.ObjectIterator(bucket, prefix=prefix+ '/'):
+                        for obj2 in oss2.ObjectIterator(bucket, prefix=prefix + '/'):
                             if '/callback_done.json' in str(obj2.key):
                                 file1 = True
+                                break
                             if '/ego_pji.csv' in str(obj2.key):
                                 file2 = True
                             if '/objects_pji.csv' in str(obj2.key):
                                 file3 = True
                             if '/pcd_overlook.mp4' in str(obj2.key):
-                                file4 = True
+                                pcd_ok = True
                             if '/drive.csv' in str(obj2.key):
                                 file5 = True
                             if '/scenario_orig.mp4' in str(obj2.key):
@@ -74,46 +76,36 @@ if __name__ == '__main__':
                                 file8 = True
                             if '/trajectory_pji.csv' in str(obj2.key):
                                 file9 = True
-                        if file1 or not file2 or not file3 or not file4 or not file5 or not file7 or not file8 or not file9:
+                        if not pcd_ok:
+                            pcd_ok = judge_pcd(str(obj1.key))
+                        if file1 or not file2 or not file3 or not pcd_ok or not file5 or not file7 or not file8 or not file9:
                             continue
                         time.sleep(1)
                         logging.info("发送:%s", prefix)
-                        # 1 获取json内容
                         json_content = bucket.get_object(str(obj1.key)).read()
-                        # 2 获取token
                         json_object = json.loads(json_content)
-                        data1 = {
-                            "equipmentNo": json_object['equipmentNo'],
-                            "secretKey": json_object['secretKey']
-                        }
+                        data1 = {"equipmentNo": json_object['equipmentNo'],"secretKey": json_object['secretKey']}
                         json_data1 = json.dumps(data1)
                         logging.info("授权接口请求中: %s" % url1_private)
                         logging.info("授权发送参数为: %s" % str(data1))
-                        request1 = urllib2.Request(url1_private, json_data1,
-                                                   headers={'Content-Type': 'application/json'})
+                        request1 = urllib2.Request(url1_private, json_data1,headers={'Content-Type': 'application/json'})
                         response1 = urllib2.urlopen(request1)
                         result_json1 = response1.read()
                         result_object1 = json.loads(result_json1)
                         logging.info("授权接口请求结果为: %s", result_object1)
                         access_token = result_object1.get('data').get('accessToken')
-                        # 要发送的JSON参数
-                        try:
-                            # logging.info("bag文件为: %s", json_object['rosBagPath'])
-                            old_date = json_object['dataName']
-                            data_size = bucket.get_object_meta(json_object['rosBagPath']).content_length
-                            equipment_no = json_object['equipmentNo']
-                            old_file_path = json_object['filePath']
-                            old_ros_bag_path = json_object['rosBagPath']
-                            task_id = json_object['taskId']
-                            trigger_id = json_object['triggerId']
-                            check = json_object['check']
-                            check_order = ['自车数据缺失', '不在道路范围', '无规划路径', '目标点缺失','点云缺失', '点云丢帧', '解析程序错误', '还原程序错误', '评价程序错误']
-                            check_order_dict = dict((item, idx) for idx, item in enumerate(check_order))
-                            check = sorted(check, key=lambda x: check_order_dict.get(x, float('inf')))
-                            check = ','.join(check) # 数组元素拼接成字符串序列
-                        except Exception as e:
-                            logging.exception("callback报错:%s", str(e))
-                            continue
+                        old_date = json_object['dataName']
+                        data_size = bucket.get_object_meta(json_object['rosBagPath']).content_length
+                        equipment_no = json_object['equipmentNo']
+                        old_file_path = json_object['filePath']
+                        old_ros_bag_path = json_object['rosBagPath']
+                        task_id = json_object['taskId']
+                        trigger_id = json_object['triggerId']
+                        check = json_object['check']
+                        check_order = ['自车数据缺失', '不在道路范围', '无规划路径', '目标点缺失','点云缺失', '点云丢帧', '解析程序错误', '还原程序错误', '评价程序错误']
+                        check_order_dict = dict((item, idx) for idx, item in enumerate(check_order))
+                        check = sorted(check, key=lambda x: check_order_dict.get(x, float('inf')))
+                        check = ','.join(check) # 数组元素拼接成字符串序列
                         if old_date is None:
                             old_date = ''
                         # 将时区统一(室外不需要需要加8,根据机器人终端的时区判断)
@@ -158,8 +150,9 @@ if __name__ == '__main__':
                                 "triggerId": trigger_id,
                                 "check":check
                             }
+
                         json_data2 = json.dumps(data2)
-                        bucket.put_object(callback_done_oss_key, json_data2)
+                        bucket.put_object(callback_done_oss_key, unicode(json_data2))
                         logging.info("回调接口请求中:%s" % url2_private)
                         logging.info("回调接口发送参数为: %s" % str(data2))
                         request2 = urllib2.Request(url2_private, json_data2,headers={'Content-Type': 'application/json','authorization': access_token})
@@ -169,6 +162,7 @@ if __name__ == '__main__':
                         logging.info("回调接口请求结果为: %s", result_object2)
                 except Exception as e:
                     logging.exception("局部异常处理: %s" % str(e))
+                    continue
             time.sleep(10)
         except Exception as e:
             logging.exception("全局错误处理: %s" % str(e))

+ 2 - 1
src/python2/pjibot_delivery/csv-errorBag.json

@@ -302,5 +302,6 @@
     "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/VD100M6-BJ-Perception2024-11-08-16-43-11/", 
     "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/VD100M6-BJ-Perception2024-11-08-16-45-05/", 
     "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/VD100M6-BJ-Perception2024-11-08-16-46-29/", 
-    "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/VD100M6-BJ-Perception2024-11-08-16-48-55/"
+    "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/VD100M6-BJ-Perception2024-11-08-16-48-55/", 
+    "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/2024-12-04-11-06-47/"
 ]

+ 1 - 1
src/python2/pjibot_delivery/pcd-pjibot_delivery.py

@@ -25,7 +25,7 @@ def parse_to_pcd_mp4(merged_bag_file_path, parse_prefix2, local_parse_dir, local
     try:
         local_pcd_mp4_dir = pcdtovideo_monitor_overlook.parse(merged_bag_file_path, local_parse_dir + '/pcd/')
         pcd_mp4_file_name = 'pcd_overlook'
-        local_mp4_path = str(local_pcd_mp4_dir) + '/jpg/'+pcd_mp4_file_name+'.mp4'
+        local_mp4_path = str(local_pcd_mp4_dir) + '/'+pcd_mp4_file_name+'.mp4'
         oss_csv_object_key3 = parse_prefix2 + pcd_mp4_file_name + '.mp4'
         bucket.put_object_from_file(oss_csv_object_key3, local_mp4_path)
         logging.info("上传点云视频到: %s", oss_csv_object_key3)

+ 100 - 22
src/python2/pjibot_delivery/resource/parse_robot_image.py

@@ -1,5 +1,5 @@
 # coding: utf-8
-# !/usr/bin/env python2
+#!/usr/bin/env python2
 
 import sys
 
@@ -13,61 +13,139 @@ import argparse
 import struct
 import subprocess
 from subprocess import Popen, PIPE
+import numpy as np
 
 bridge = CvBridge()
 
+bag_start_time=0
+bag_end_time=0
 
 def parsebag(f, output_dir, target_topic):
+    global bag_start_time
+    global bag_end_time
     rosbag_name = f.split("/")[-1].split(".")[0]
-    output_path = os.path.join(output_dir, rosbag_name)
-    camera_exist_flag = False
+    output_path = os.path.join(output_dir, rosbag_name) 
+    camera_exist_flag=False
 
     with rosbag.Bag(f, 'r') as bag:
+        bag_start_time = bag.get_start_time()
+        bag_end_time = bag.get_end_time()
         count = 0
         start_time = bag.get_start_time()
         end_time = bag.get_end_time()
         duration = end_time - start_time
-        print('duration', duration)
+        print('duration',duration)
         topics = bag.get_type_and_topic_info()[1].keys()
-        if target_topic in topics:
+        if target_topic in topics:        
             for topic, msg, t in bag.read_messages(topics=[target_topic]):
-                camera_exist_flag = True
+                camera_exist_flag=True
                 img = bridge.imgmsg_to_cv2(msg, 'bgr8')
                 img_resized = cv2.resize(img, (1920, 1080))
                 # img = bridge.compressed_imgmsg_to_cv2(msg, 'bgr8')
                 timestr = msg.header.stamp.to_nsec()
-                image_name = str(timestr) + ".jpg"
+                image_name = str(timestr)[:10]+'.'+str(timestr)[10:] + ".jpg"
                 if not os.path.exists(output_path + '_' + 'image'):
                     os.makedirs(output_path + '_' + 'image')
                 output_path_img = os.path.join(output_path + '_' + 'image', image_name)
                 cv2.imwrite(output_path_img, img_resized)
                 # print(count)
-                count = count + 1
+                count = count + 1   
+            
+    return count , duration, camera_exist_flag
 
-    return count, duration, camera_exist_flag
+def parse(input_dir,output_dir):
 
-
-def parse(input_dir, output_dir):
     # input_dir=sys.argv[1]
     # output_dir = sys.argv[2]
+    
+    #input_dir='/media/dell/HIKSEMI1/2024-12-04-10-32-38.bag'
+    #output_dir ='/media/dell/HIKSEMI1'
+    bagname=input_dir.split('/')[-1].split('.bag')[0]
+    output_dir=os.path.join(output_dir, bagname)
     topic = '/image_raw'  # /camera/color/image_raw
 
-    num_count, duration, flag = parsebag(input_dir, output_dir, topic)
-
+    num_count, duration ,flag = parsebag(input_dir, output_dir, topic)
+    
+    
     if flag:
         dirt = os.path.join(output_dir, input_dir.split('/')[-1].split('.')[0] + '_' + 'image')
+        '''
+        下面这段代码是用ffmpeg通过动态计算视频帧率将图片拼接成视频的代码
+        
         bagtime = duration
         hz = str(float(num_count) / bagtime)
-        print('bagtime=', bagtime)
-        print('num_count=', num_count)
-
+        print('bagtime=',bagtime)
+        print('num_count=',num_count)
+        
         command = ['ffmpeg', '-f', 'image2', '-r', hz, '-pattern_type', 'glob', '-i'] + [dirt + '/*.jpg'] + ['-tag:v',
-                                                                                                             'avc1',
-                                                                                                             '-y'] + [
-                      dirt + '/camera.mp4']
+                                                                                                            'avc1',
+                                                                                                            '-y'] + [
+                    dirt + '/camera.mp4']
         p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         p.communicate()
         print('done')
-        return flag, dirt
-    else:
-        return flag, ''
+        '''
+        
+        '''
+        下面这段代码是利用图像插值算法,通过指定一个频率将图像拼接成视频的代码
+        '''
+        #指定视频帧率
+        hz=10.0
+        
+        # 定义图片文件夹路径
+        folder_path = dirt
+
+        #根据rosbag的起止时间生成黑色图片
+        if bag_end_time!=0 and bag_end_time!=0:
+            black_image = np.zeros((512, 512, 3), dtype=np.uint8)
+            cv2.imwrite(os.path.join(dirt,str(bag_start_time)+'.jpg'), black_image)
+            cv2.imwrite(os.path.join(dirt,str(bag_end_time)+'.jpg'), black_image)
+        
+        # 获取文件夹中的所有图片文件
+        image_files = [f for f in os.listdir(folder_path) if f.endswith('.jpg')]
+
+        # 对文件名进行排序,以便按顺序处理图片
+        image_files.sort()
+
+        # 读取第一张图片
+        first_image = cv2.imread(os.path.join(folder_path, image_files[0]))
+
+        # 获取图片的形状
+        image_shape = first_image.shape
+
+        # 创建视频写入对象
+        video_path=os.path.join(dirt,'camera.mp4')
+        video_writer = cv2.VideoWriter(video_path, cv2.VideoWriter_fourcc('m', 'p', '4', 'v'), hz, (image_shape[1], image_shape[0]))
+
+        # 遍历图片文件列表
+        for i in range(len(image_files) - 1):
+            # 读取当前图片和下一张图片
+            current_image = cv2.imread(os.path.join(folder_path, image_files[i]))
+            next_image = cv2.imread(os.path.join(folder_path, image_files[i + 1]))
+
+            # 获取当前图片和下一张图片的时间戳
+            current_timestamp = float(image_files[i].split('.jpg')[0]) 
+            next_timestamp = float(image_files[i + 1].split('.jpg')[0]) 
+
+            # 计算时间间隔
+            time_interval = next_timestamp - current_timestamp
+            #print(time_interval)
+
+            # 根据实际时间间隔调整循环次数
+            video_writer.write(current_image)
+            if int(time_interval * hz)>1.5:
+                for _ in range(int(time_interval * hz)):     
+                    video_writer.write(current_image)
+
+        # 释放资源
+        video_writer.release()
+        if os.path.exists(video_path):
+            video_output_path=os.path.join(folder_path,'camera_new.mp4')
+            command = ["ffmpeg", "-i", video_path, "-c:v", "libx264", video_output_path]
+            p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            p.communicate()
+            os.remove(video_path)
+            if os.path.exists(video_output_path):
+                os.rename(video_output_path, video_path)
+                print('done')
+    return flag,dirt

+ 23 - 7
src/python2/pjibot_delivery/resource/pcdtovideo_monitor_overlook.py

@@ -74,10 +74,12 @@ def parse(input_dir, output_dir):
     with rosbag.Bag(input_dir, 'r') as bag:
         bag_start_time = bag.get_start_time()
         bag_end_time = bag.get_end_time()
+        print('bag_start_time=',bag_start_time)
+        print('bag_end_time=',bag_end_time)
         num_count = 0
-        for topic, msg, t in bag.read_messages():
-            if topic == "/velodyne_points": #/camera/depth/points   # /scan_map_icp_amcl_node/scan_point_transformed
-                num_count += 1
+        for topic, msg, t in bag.read_messages(topics=['/velodyne_points']):
+             #/camera/depth/points   # /scan_map_icp_amcl_node/scan_point_transformed
+             num_count += 1
         start_time = bag.get_start_time()
         end_time = bag.get_end_time()
         # 计算rosbag的持续时间
@@ -93,6 +95,7 @@ def parse(input_dir, output_dir):
     os.system(command)
     file1 = os.path.join(output_dir[0:-4], 'pcd_ascii')
     file2 = os.path.join(output_dir[0:-4], 'jpg')
+    file3 = os.path.join(output_dir[0:-4], 'pcd')
     if not os.path.exists(file1):
         os.makedirs(file1)
     if not os.path.exists(file2):
@@ -127,6 +130,7 @@ def parse(input_dir, output_dir):
         p = Popen(result_string, shell=True, cwd=output_dir[0:-4] + '/', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         p.wait()
         
+        
         '''
         
         '''
@@ -138,12 +142,11 @@ def parse(input_dir, output_dir):
         # 定义图片文件夹路径
         folder_path = file2
         
-        #根据rosbag的起止时间生成黑色图片2024.11.22添加
+        #根据rosbag的起止时间生成黑色图片
         black_image = np.zeros((512, 512, 3), dtype=np.uint8)
         cv2.imwrite(os.path.join(file2,str(bag_start_time)+'.jpg'), black_image)
         cv2.imwrite(os.path.join(file2,str(bag_end_time)+'.jpg'), black_image)
         
-
         # 获取文件夹中的所有图片文件
         image_files = [f for f in os.listdir(folder_path) if f.endswith('.jpg')]
 
@@ -155,6 +158,9 @@ def parse(input_dir, output_dir):
 
         # 获取图片的形状
         image_shape = first_image.shape
+        
+        
+        
 
         # 创建视频写入对象
         video_path=os.path.join(file2,'pcd_overlook.mp4')
@@ -172,7 +178,7 @@ def parse(input_dir, output_dir):
 
             # 计算时间间隔
             time_interval = next_timestamp - current_timestamp
-            #print(time_interval)
+            print(time_interval)
 
             # 根据实际时间间隔调整循环次数
             video_writer.write(current_image)
@@ -182,6 +188,16 @@ def parse(input_dir, output_dir):
 
         # 释放资源
         video_writer.release()
+        if os.path.exists(video_path):
+            video_output_path=os.path.join(output_dir[0:-4],'pcd_overlook.mp4')
+            command = ["ffmpeg", "-i", video_path, "-c:v", "libx264", video_output_path]
+            p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            p.communicate()
+            os.remove(video_path)
+            shutil.rmtree(file1)
+            shutil.rmtree(file2)
+            shutil.rmtree(file3)
+
     
     e_time=datetime.datetime.now()
     print("using "+str(e_time-s_time)+ "s")
@@ -189,4 +205,4 @@ def parse(input_dir, output_dir):
     #shutil.rmtree(file2)
     #shutil.rmtree(output_dir)
     return output_dir[0:-4]
-
+    

+ 3 - 1
src/python2/pjibot_delivery/xosc-errorBag.json

@@ -60,5 +60,7 @@
     "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/充电桩没电2024-09-29-11-39-55/", 
     "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/障碍物跟随2024-09-29-15-34-00/", 
     "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/2024-09-12-14-24-23_obstacledetection_30/", 
-    "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/2024-09-13-09-23-24_obstacledetection_30/"
+    "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/2024-09-13-09-23-24_obstacledetection_30/", 
+    "pjibot_patrol/pjibot-P1YVXJ1M231M00022/data_parse/2024-08-01-17-28-27_1038/", 
+    "pjibot_patrol/pjibot-P1YVXJ1M231M00023/data_parse/VP100M23-BJ-movebase-2024-11-15-11-23-25/"
 ]

+ 9 - 0
src/python2/pjibot_patrol/2callback-nohup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+if [ ! -d "./log" ]; then
+    mkdir "./log"
+    echo "Directory './log' created."
+else
+    echo "Directory './log' already exists."
+fi
+rm -rf log/2callback*
+nohup python2 2callback-pjibot_patrol.py > log/2callback-pjibot_patrol.out 2>&1 &

+ 167 - 0
src/python2/pjibot_patrol/2callback-pjibot_patrol.py

@@ -0,0 +1,167 @@
+# -*- coding: utf-8 -*-
+import sys
+reload(sys)
+sys.setdefaultencoding("utf-8")
+import json
+import time
+import urllib2
+import oss2
+import logging
+from datetime import datetime, timedelta
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket_name = 'open-bucket'
+bucket = oss2.Bucket(auth, endpoint, bucket_name)
+path1 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/'
+path3 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/2callback/'
+logging.basicConfig(filename=path1 + 'log/2callback-pjibot_patrol.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
+key1 = 'pjibot_patrol/'
+key2 = 'data/'
+key3 = 'data_merge/'
+key4 = 'data_parse/'
+path2 = 'data/'
+path3 = 'data_merge/'
+path4 = 'data_parse/'
+url1_private = "http://10.14.86.127:9081/device/auth"
+url2_private = "http://10.14.86.127:9081/device/data/callback"
+
+def add_hour(date_string, hour_number):
+    original_date = datetime.strptime(date_string, "%Y-%m-%d-%H-%M-%S")
+    new_date = original_date + timedelta(hours=hour_number)
+    return new_date.strftime("%Y-%m-%d-%H-%M-%S")
+
+def judge_pcd(callback_json_oss_key):
+    json_content = bucket.get_object(callback_json_oss_key).read()
+    json_object = json.loads(json_content)
+    check = json_object['check']
+    if '点云缺失' in check:
+        return True
+
+
+if __name__ == '__main__':
+    while True:
+        logging.info("开始新一轮扫描")
+        try:
+            local_delete_list = []
+            oss_delete_list = []
+            upload_completed_prefix_list = []
+            for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
+                try:
+                    if 'callback.json' in str(obj1.key):
+                        prefix = '/'.join(str(obj1.key).split('/')[:-1])
+                        file1 = False
+                        file2 = False
+                        file3 = False
+                        pcd_ok = False
+                        file5 = False
+                        file7 = False
+                        file8 = False
+                        file9 = False
+                        for obj2 in oss2.ObjectIterator(bucket, prefix=prefix + '/'):
+                            if '/callback_done.json' in str(obj2.key):
+                                file1 = True
+                                break
+                            if '/ego_pji.csv' in str(obj2.key):
+                                file2 = True
+                            if '/objects_pji.csv' in str(obj2.key):
+                                file3 = True
+                            if '/pcd_overlook.mp4' in str(obj2.key):
+                                pcd_ok = True
+                            if '/drive.csv' in str(obj2.key):
+                                file5 = True
+                            if '/scenario_orig.mp4' in str(obj2.key):
+                                file7 = True
+                            if '/scenario_hmi.xosc' in str(obj2.key):
+                                file8 = True
+                            if '/trajectory_pji.csv' in str(obj2.key):
+                                file9 = True
+                        if not pcd_ok:
+                            pcd_ok = judge_pcd(str(obj1.key))
+                        if file1 or not file2 or not file3 or not pcd_ok or not file5 or not file7 or not file8 or not file9:
+                            continue
+                        time.sleep(1)
+                        logging.info("发送:%s", prefix)
+                        json_content = bucket.get_object(str(obj1.key)).read()
+                        json_object = json.loads(json_content)
+                        data1 = {"equipmentNo": json_object['equipmentNo'],"secretKey": json_object['secretKey']}
+                        json_data1 = json.dumps(data1)
+                        logging.info("授权接口请求中: %s" % url1_private)
+                        logging.info("授权发送参数为: %s" % str(data1))
+                        request1 = urllib2.Request(url1_private, json_data1,headers={'Content-Type': 'application/json'})
+                        response1 = urllib2.urlopen(request1)
+                        result_json1 = response1.read()
+                        result_object1 = json.loads(result_json1)
+                        logging.info("授权接口请求结果为: %s", result_object1)
+                        access_token = result_object1.get('data').get('accessToken')
+                        old_date = json_object['dataName']
+                        data_size = bucket.get_object_meta(json_object['rosBagPath']).content_length
+                        equipment_no = json_object['equipmentNo']
+                        old_file_path = json_object['filePath']
+                        old_ros_bag_path = json_object['rosBagPath']
+                        task_id = json_object['taskId']
+                        trigger_id = json_object['triggerId']
+                        check = json_object['check']
+                        check_order = ['自车数据缺失', '不在道路范围', '无规划路径', '目标点缺失','点云缺失', '点云丢帧', '解析程序错误', '还原程序错误', '评价程序错误']
+                        check_order_dict = dict((item, idx) for idx, item in enumerate(check_order))
+                        check = sorted(check, key=lambda x: check_order_dict.get(x, float('inf')))
+                        check = ','.join(check) # 数组元素拼接成字符串序列
+                        if old_date is None:
+                            old_date = ''
+                        # 将时区统一(室外不需要需要加8,根据机器人终端的时区判断)
+                        # new_date = add_hour(old_date, 8)
+                        new_date = old_date
+                        old_delete_list = []
+                        callback_done_oss_key = ''
+                        for obj_old in oss2.ObjectIterator(bucket, prefix=old_file_path):
+                            old_delete_list.append(str(obj_old.key))
+                            if 'callback.json' in str(obj_old.key):
+                                callback_done_oss_key = str(obj_old.key).replace(old_date, new_date).replace('callback.json','callback_done.json')
+                        # todo 时区不变也就不需要移动文件了
+                        #     else:
+                        #         bucket.copy_object(bucket_name, str(obj_old.key),
+                        #                            str(obj_old.key).replace(old_date, new_date))
+                        # bucket.copy_object(bucket_name, old_ros_bag_path, old_ros_bag_path.replace(old_date, new_date))
+                        # bucket.delete_object(old_ros_bag_path)
+                        # bucket.batch_delete_objects(old_delete_list)
+
+                        if 'userId' in json_object:
+                            logging.info("json_object 包含 'userId' 字段,值为:", json_object['userId'])
+                            data2 = {
+                                'userId': json_object['userId'],
+                                "dataName": new_date,
+                                "dataSize": data_size,
+                                "equipmentNo": equipment_no,
+                                "filePath": old_file_path.replace(old_date, new_date),
+                                "rosBagPath": old_ros_bag_path.replace(old_date, new_date),
+                                "taskId": task_id,
+                                "triggerId": trigger_id,
+                                "check":check
+                            }
+                        else:
+                            logging.info("json_object 不包含 'userId' 字段")
+                            data2 = {
+                                "dataName": new_date,
+                                "dataSize": data_size,
+                                "equipmentNo": equipment_no,
+                                "filePath": old_file_path.replace(old_date, new_date),
+                                "rosBagPath": old_ros_bag_path.replace(old_date, new_date),
+                                "taskId": task_id,
+                                "triggerId": trigger_id,
+                                "check":check
+                            }
+
+                        json_data2 = json.dumps(data2)
+                        bucket.put_object(callback_done_oss_key, unicode(json_data2))
+                        logging.info("回调接口请求中:%s" % url2_private)
+                        logging.info("回调接口发送参数为: %s" % str(data2))
+                        request2 = urllib2.Request(url2_private, json_data2,headers={'Content-Type': 'application/json','authorization': access_token})
+                        response2 = urllib2.urlopen(request2)
+                        result_json2 = response2.read()
+                        result_object2 = json.loads(result_json2)
+                        logging.info("回调接口请求结果为: %s", result_object2)
+                except Exception as e:
+                    logging.exception("局部异常处理: %s" % str(e))
+                    continue
+            time.sleep(10)
+        except Exception as e:
+            logging.exception("全局错误处理: %s" % str(e))

+ 11 - 0
src/python2/pjibot_patrol/2csv-errorBag.json

@@ -0,0 +1,11 @@
+[
+    "pjibot_delivery/ps001/data_parse/2024-10-23-14-10-24_obstacledetection_30/", 
+    "pjibot_delivery/ps001/data_parse/2024-10-23-14-10-25_obstacledetection_30/", 
+    "pjibot_delivery/ps001/data_parse/2024-10-23-14-10-26_obstacledetection_30/", 
+    "pjibot_delivery/ps001/data_parse/2024-10-23-14-10-27_obstacledetection_30/", 
+    "pjibot_delivery/ps001/data_parse/2024-10-24-15-48-07/", 
+    "pjibot_delivery/ps001/data_parse/VD100M6-BJ-Perception2024-10-24-15-49-34/", 
+    "pjibot_delivery/ps001/data_parse/VP100M23-BJ-movebase-2024-11-15-14-19-41/", 
+    "pjibot_delivery/ps001/data_parse/test_1126_01/", 
+    "pjibot_delivery/ps001/data_parse/mlx11281/"
+]

+ 9 - 0
src/python2/pjibot_patrol/2csv-nohup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+if [ ! -d "./log" ]; then
+    mkdir "./log"
+    echo "Directory './log' created."
+else
+    echo "Directory './log' already exists."
+fi
+rm -rf log/2csv*
+nohup python2 2csv-pjibot_patrol.py > log/2csv-pjibot_patrol.out 2>&1 &

+ 202 - 0
src/python2/pjibot_patrol/2csv-pjibot_patrol.py

@@ -0,0 +1,202 @@
+# -*- coding: utf-8 -*-
+import sys
+reload(sys)
+sys.setdefaultencoding('utf8')
+import os
+import subprocess
+import time
+import oss2
+import json
+import io
+import logging
+from resource import bagtocsv_robot
+from utils import json_utils
+# 1 创建阿里云对象
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket = oss2.Bucket(auth, endpoint, 'open-bucket')
+path1 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/'
+path2 = '/mnt/disk001/pdf_outdoor/run/'
+path3 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/2csv/'
+logging.basicConfig(filename=path1 + 'log/2csv-pjibot_patrol.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
+key1 = 'pjibot_patrol/'
+sleep_time = 10  # 每多少秒扫描一次
+error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/2csv-errorBag.json"
+
+
+    
+def parse_csv(data_bag, parse_prefix, local_parse_dir, local_delete_list):
+    try:
+        bagtocsv_robot.parse(data_bag, local_parse_dir + '/csv/')
+        bagname = data_bag.split('/')[-1].split('.')[0]
+        local_csv_dir = os.path.join(local_parse_dir + '/csv/', bagname)  # 最终生成四个csv文件和output.json的目录
+
+        # ------- 处理 output.json - 开始 -------
+        try:
+            output_json_path = str(local_csv_dir)+'/output.json'
+            if os.path.exists(output_json_path):
+                outputs = json_utils.parse_json_to_string_array(output_json_path)
+                # 2 将 output.json 添加到 callback.json 的 check 字段
+                callback_json_oss_key = parse_prefix+'callback.json'
+                callback_json_local = local_csv_dir+'/callback.json'
+                bucket.get_object_to_file(callback_json_oss_key, callback_json_local)
+                with io.open(callback_json_local, 'r', encoding='utf-8') as f:
+                    data = json.load(f)
+                if 'check' not in data:
+                    data['check'] = []
+                data['check'].extend(outputs)
+                data['check'] = list(set(data['check'])) # 去重
+                json_data = json.dumps(data, ensure_ascii=False, indent=4)
+                with io.open(callback_json_local, 'w', encoding='utf-8') as f:
+                    f.write(unicode(json_data))
+                bucket.put_object_from_file(callback_json_oss_key, callback_json_local)
+        except Exception as e3:
+            pass
+        # ------- 处理 output.json - 结束 -------
+        csv_file_name1 = 'trajectory_pji'
+        local_csv_file_path1 = str(local_csv_dir) + '/' + str(csv_file_name1) + '.csv'
+        oss_csv_object_key1 = parse_prefix + csv_file_name1 + '.csv'
+        if os.path.exists(local_csv_file_path1):
+            bucket.put_object_from_file(oss_csv_object_key1, local_csv_file_path1)
+        else:
+            logging.error("没有 trajectory_pji.csv")
+            json_utils.add_error(parse_prefix,error_bag_json)
+
+        csv_file_name2 = 'ego_pji'
+        local_csv_file_path2 = str(local_csv_dir) + '/' + str(csv_file_name2) + '.csv'
+        oss_csv_object_key2 = parse_prefix + csv_file_name2 + '.csv'
+        if os.path.exists(local_csv_file_path2):
+            bucket.put_object_from_file(oss_csv_object_key2, local_csv_file_path2)
+        else:
+            logging.error("没有 ego_pji.csv")
+            json_utils.add_error(parse_prefix,error_bag_json)
+
+        csv_file_name3 = 'targetposition'
+        local_csv_file_path3 = str(local_csv_dir) + '/' + str(csv_file_name3) + '.csv'
+        oss_csv_object_key3 = parse_prefix + csv_file_name3 + '.csv'
+        if os.path.exists(local_csv_file_path3):
+            bucket.put_object_from_file(oss_csv_object_key3, local_csv_file_path3)
+        else:
+            logging.error("没有 targetposition.csv")
+            json_utils.add_error(parse_prefix,error_bag_json)
+
+        csv_file_name4 = 'objects_pji'
+        local_csv_file_path4 = str(local_csv_dir) + '/' + str(csv_file_name4) + '.csv'
+        oss_csv_object_key4 = parse_prefix + csv_file_name4 + '.csv'
+        if os.path.exists(local_csv_file_path4):
+            bucket.put_object_from_file(oss_csv_object_key4, local_csv_file_path4)
+        else:
+            logging.error("没有 objects_pji.csv")
+            json_utils.add_error(parse_prefix,error_bag_json)
+        
+        csv_file_name5 = 'drive'
+        local_csv_file_path5 = str(local_csv_dir) + '/' + str(csv_file_name5) + '.csv'
+        oss_csv_object_key5 = parse_prefix + csv_file_name5 + '.csv'
+        if os.path.exists(local_csv_file_path5):
+            bucket.put_object_from_file(oss_csv_object_key5, local_csv_file_path5)
+        else:
+            logging.error("没有 drive.csv")
+            json_utils.add_error(parse_prefix,error_bag_json)
+
+        # ------- 生成pdf - 开始 -------
+        pdf_local_path = str(local_csv_dir) + '/report.pdf'
+        can_pdf = True
+        for output in outputs:
+            if str(output) in ['自车数据缺失','无规划路径']:
+                logging.error("【自车数据缺失、无规划路径】导致无法生成评价报告PDF")
+                can_pdf = False
+        if can_pdf:
+            os.chdir(path2)
+            command1 = ['./pji_outdoor_real',
+                        os.path.join(local_csv_dir, ''),  # 注意:这里可能不需要末尾的 '/',取决于程序要求
+                        os.path.join(local_csv_dir, ''),  # 同上
+                        os.path.join(local_csv_dir, 'trajectory.png'),
+                        bagname]
+            logging.info("调用生成pdf 报告命令: %s" % ' '.join(command1))
+            process = subprocess.Popen(command1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            stdout, stderr = process.communicate()  # 等待命令执行完成
+            if stdout:
+                logging.info("命令的标准输出:")
+                logging.info(stdout.decode('utf-8'))  # Python 2 中需要解码
+            if stderr:
+                logging.error("命令的错误输出:")
+                logging.error(stderr.decode('utf-8'))  # Python 2 中需要解码
+            if process.returncode != 0:
+                logging.error("命令执行失败,退出码: %s" % process.returncode)
+            oss_csv_object_key5 = parse_prefix + 'report.pdf'
+            bucket.put_object_from_file(oss_csv_object_key5, pdf_local_path)
+            logging.info("pdf 报告生成并上传完成。")
+        # ------- 生成pdf - 结束 -------
+        
+        # 记得删除
+        local_delete_list.append(local_csv_file_path1)
+        local_delete_list.append(local_csv_file_path2)
+        local_delete_list.append(local_csv_file_path4)
+        local_delete_list.append(output_json_path)
+        local_delete_list.append(pdf_local_path)
+        local_delete_list.append(str(local_csv_dir) + '/trajectory.png')
+
+    except Exception as e2:
+        logging.exception("生成csv报错: %s", e2)
+        json_utils.add_error(parse_prefix,error_bag_json)
+
+if __name__ == '__main__':
+    while True:
+        logging.info("开始新一轮扫描:%s " % key1)
+        try:
+            local_delete_list = []
+            oss_delete_list = []
+            prefix_list = []
+            # 2 获取已经上传完成的所有目录并分组
+            for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
+                if 'data_merge' in str(obj1.key) and str(obj1.key).endswith('.bag'):  # data_merge下的bag是等待解析的
+                    # 获取合并后的包
+                    merged_bag_object_key = str(obj1.key)
+                    merged_bag_object_key_split = merged_bag_object_key.split('/')
+                    merged_prefix = '/'.join(merged_bag_object_key_split[:-1])  # data_merge 目录
+                    parse_prefix = merged_prefix.replace('data_merge', 'data_parse')
+                    parse_prefix_full = merged_bag_object_key.replace('data_merge', 'data_parse').replace('.bag',
+                                                                                                          '/')  # data_parse 目录
+                    csv1_done = False
+                    csv2_done = False
+                    csv4_done = False
+                    csv5_done = False
+                    for obj2 in oss2.ObjectIterator(bucket, prefix=parse_prefix_full): # 判断 data_parse 目录下是否有解析后的文件
+                        if '/trajectory_pji.csv' in str(obj2.key):
+                            csv1_done = True
+                        if '/ego_pji.csv' in str(obj2.key):
+                            csv2_done = True
+                        if '/objects_pji.csv' in str(obj2.key):
+                            csv4_done = True
+                        if '/drive.csv' in str(obj2.key):
+                            csv5_done = True
+                    if csv1_done and csv2_done and csv4_done and csv5_done:
+                        continue
+                    error_bag_list = json_utils.parse_json_to_string_array(error_bag_json)
+                    if parse_prefix_full in error_bag_list:
+                        continue
+                    logging.info("------- 生成场景还原csv - 开始: %s -------" % str(obj1.key))
+                    local_merged_bag_path = path3 + merged_bag_object_key
+                    local_merged_dir = '/'.join(local_merged_bag_path.split('/')[:-1])
+                    local_parse_dir = local_merged_dir.replace('data_merge', 'data_parse')
+                    if not os.path.exists(local_merged_dir):
+                        os.makedirs(local_merged_dir)
+                    if not os.path.exists(local_parse_dir):
+                        os.makedirs(local_parse_dir)
+                    merged_bag_full_name = merged_bag_object_key_split[-1]
+                    merged_bag_name = merged_bag_full_name.split('.')[0]
+                    bucket.get_object_to_file(merged_bag_object_key, local_merged_bag_path)
+                    local_delete_list.append(local_merged_bag_path)
+                    # 2 生成 pos_orig.csv 和 pos_hmi.csv
+                    parse_csv(local_merged_bag_path, parse_prefix_full, local_parse_dir, local_delete_list)
+                    logging.info("------- 生成场景还原csv - 结束: %s -------" % str(obj1.key))
+            # 删除本地临时文件
+            if len(local_delete_list) > 0:
+                for local_delete in local_delete_list:
+                    try:
+                        os.remove(local_delete)
+                    except Exception as e:
+                        pass
+        except Exception as e:
+            logging.exception("全局错误处理: %s" % str(e))
+        time.sleep(sleep_time)

+ 9 - 0
src/python2/pjibot_patrol/2pcd-nohup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+if [ ! -d "./log" ]; then
+    mkdir "./log"
+    echo "Directory './log' created."
+else
+    echo "Directory './log' already exists."
+fi
+rm -rf log/2pcd*
+nohup python2 2pcd-pjibot_patrol.py > log/2pcd-pjibot_patrol.out 2>&1 &

+ 93 - 0
src/python2/pjibot_patrol/2pcd-pjibot_patrol.py

@@ -0,0 +1,93 @@
+# -*- coding: utf-8 -*-
+# ------- 全局配置 -------
+import sys
+reload(sys)
+sys.setdefaultencoding("utf-8")
+import os
+import time
+import oss2
+import logging
+from resource import pcdtovideo_monitor_overlook
+from utils import json_utils
+path1 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/'
+logging.basicConfig(filename=path1 + 'log/2pcd-pjibot_patrol.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
+key1 = 'pjibot_patrol/'
+sleep_time = 30  # 每多少秒扫描一次
+error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/2pcd-errorBag.json"
+# 1 创建阿里云对象
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket = oss2.Bucket(auth, endpoint, 'open-bucket')
+# ------- 全局配置 -------
+
+def parse_to_pcd_mp4(merged_bag_file_path, parse_prefix2, local_parse_dir, local_delete_list):
+    global bucket
+    try:
+        local_pcd_mp4_dir = pcdtovideo_monitor_overlook.parse(merged_bag_file_path, local_parse_dir + '/pcd/')
+        pcd_mp4_file_name = 'pcd_overlook'
+        local_mp4_path = str(local_pcd_mp4_dir) + '/'+pcd_mp4_file_name+'.mp4'
+        oss_csv_object_key3 = parse_prefix2 + pcd_mp4_file_name + '.mp4'
+        bucket.put_object_from_file(oss_csv_object_key3, local_mp4_path)
+        logging.info("上传点云视频到: %s", oss_csv_object_key3)
+        local_delete_list.append(local_mp4_path)
+    except Exception as e:
+        local_delete_list.remove(merged_bag_file_path)
+        error_bag_list = json_utils.jsonparse_json_to_string_array(error_bag_json)
+        error_bag_list.append(parse_prefix2)
+        json_utils.list_to_json_file(error_bag_list, error_bag_json)
+        logging.exception("生成点云视频报错: %s" % str(e))
+
+
+if __name__ == '__main__':
+    while True:
+        logging.info("开始新一轮扫描")
+        try:
+            local_delete_list = []
+            oss_delete_list = []
+            prefix_list = []
+            # 2 获取已经上传完成的所有目录并分组
+            for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
+                try:
+                    # 获取合并后的包
+                    merged_bag_object_key = str(obj1.key)
+                    if 'data_merge' in str(obj1.key) and str(obj1.key).endswith('.bag'):
+                        merged_bag_object_key_split = merged_bag_object_key.split('/')
+                        merged_prefix = '/'.join(merged_bag_object_key_split[:-1])
+                        parse_prefix = merged_prefix.replace('data_merge', 'data_parse')
+                        parse_prefix_full = merged_bag_object_key.replace('data_merge', 'data_parse')[:-4] + '/'
+                        pcd_done = False
+                        for obj2 in oss2.ObjectIterator(bucket, prefix=parse_prefix_full):
+                            if '/pcd_overlook.mp4' in str(obj2.key):
+                                pcd_done = True
+                        if pcd_done:
+                            continue
+                        error_bag_list = json_utils.parse_json_to_string_array(error_bag_json)
+                        if str(parse_prefix_full) in error_bag_list:
+                            continue
+                        logging.info("%s 需要生成点云视频 pcd_overlook.mp4" % str(parse_prefix_full))
+                        local_merged_bag_path = path1 + 'pcd/' + merged_bag_object_key
+                        local_merged_dir = '/'.join(local_merged_bag_path.split('/')[:-1])
+                        local_parse_dir = local_merged_dir.replace('data_merge', 'data_parse')
+                        if not os.path.exists(local_merged_dir):
+                            os.makedirs(local_merged_dir)
+                        if not os.path.exists(local_parse_dir):
+                            os.makedirs(local_parse_dir)
+                        merged_bag_full_name = merged_bag_object_key_split[-1]
+                        merged_bag_name = merged_bag_full_name.split('.')[0]
+                        bucket.get_object_to_file(merged_bag_object_key, local_merged_bag_path)
+                        logging.info("本地 bag 包路径为【%s】" % str(local_merged_bag_path))
+                        local_delete_list.append(local_merged_bag_path)
+                        # 2 生成 pos_orig.csv 和 pos_hmi.csv
+                        parse_to_pcd_mp4(local_merged_bag_path, parse_prefix_full, local_parse_dir, local_delete_list)
+                except Exception as e:
+                    logging.exception("报错: %s" % str(e))
+            # 删除本地临时文件
+            if len(local_delete_list) > 0:
+                for local_delete in local_delete_list:
+                    try:
+                        os.remove(local_delete)
+                    except Exception as e:
+                        logging.exception("删除本地临时文件报错: %s" % str(e))
+            time.sleep(sleep_time)
+        except Exception as e:
+            logging.exception("全局异常处理: %s" % str(e))

+ 9 - 0
src/python2/pjibot_patrol/2simulation-nohup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+if [ ! -d "./log" ]; then
+    mkdir "./log"
+    echo "Directory './log' created."
+else
+    echo "Directory './log' already exists."
+fi
+rm -rf log/2simulation*
+nohup python2 2simulation-pjibot_patrol.py > log/2simulation-pjibot_patrol.out 2>&1 &

+ 159 - 0
src/python2/pjibot_patrol/2simulation-pjibot_patrol.py

@@ -0,0 +1,159 @@
+# -*- coding: utf-8 -*-
+# ------- 全局配置 -------
+import os
+import time
+import oss2
+import xml.etree.ElementTree as ET
+import shutil
+import docker
+import logging
+from utils import json_utils
+key1 = 'pjibot_patrol/'
+path1 = '/scenarios4/'
+container_name = 'vtd4'
+path2 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/'
+vehicle_name = 'PuJin_patrol_robot'  # 配送 PuJin_distribution 巡检 PuJin_patrol_robot
+xoscName = 'scenario.xosc'
+logging.basicConfig(filename=path2 + 'log/2simulation-pjibot_patrol.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
+sleep_time = 30  # 每多少秒扫描一次
+error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/2simulation-errorBag.json"
+# 1 创建阿里云对象
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket = oss2.Bucket(auth, endpoint, 'open-bucket')
+# ------- 全局配置 -------
+
+def move_xosc_before_simulation(root_path):
+    try:
+        xosc_src = os.path.join(root_path, 'scenario_orig.xosc')
+        xosc_target = os.path.join(root_path, 'openx0.xosc')
+        tree1 = ET.parse(xosc_src)
+        root1 = tree1.getroot()
+        for node0 in root1:
+            if node0.tag == 'RoadNetwork':
+                for node1 in node0:
+                    # 打印根元素的标签名
+                    if 'LogicFile' == node1.tag:
+                        xodr_src = str(node1.get('filepath'))
+                        xodr_target = root_path + xodr_src.rsplit('/', 1)[-1]
+                        shutil.copy(xodr_src, xodr_target)
+                        node1.set('filepath', xodr_target)
+                    if 'SceneGraphFile' == node1.tag:
+                        osgb_src = str(node1.get('filepath'))
+                        osgb_target = root_path + osgb_src.rsplit('/', 1)[-1]
+                        shutil.copy(osgb_src, osgb_target)
+                        node1.set('filepath', osgb_target)
+            if node0.tag == 'Entities':
+                for node1 in node0:
+                    if node1.get("name") == 'Ego':
+                        for node2 in node1:
+                            if node2.tag == 'Vehicle':
+                                node2.set('name', vehicle_name)
+        tree1.write(xosc_target)
+        # 检查文件是否存在,以避免在文件不存在时引发异常
+        if os.path.exists(xosc_src):
+            # 删除文件
+            os.remove(xosc_src)
+            print("文件已删除:", xosc_src)
+        else:
+            print("文件不存在:", xosc_src)
+
+    except Exception as e:
+        logging.exception("修改xosc报错: %s" % str(e))
+
+
+def upload_simulation(parse_prefix, mp41):
+    try:
+        # 上传两次吧,对应上
+        bucket.put_object_from_file(parse_prefix + 'scenario_orig.mp4', mp41)
+        bucket.put_object_from_file(parse_prefix + 'scenario_hmi.mp4', mp41)
+        logging.info('上传仿真视频到 %s' % parse_prefix + 'scenario_orig.mp4')
+        shutil.rmtree(path1)  # 仿真完就删除
+    except Exception as e:
+        error_bag_list = json_utils.parse_json_to_string_array(error_bag_json)
+        error_bag_list.append(parse_prefix)
+        json_utils.list_to_json_file(error_bag_list, error_bag_json)
+        logging.exception("上传视频报错 %s" % str(e))
+
+
+def simulation(parse_prefix, mp41):
+    try:
+        os.system("docker start "+container_name)
+        # 实例化Docker客户端
+        client = docker.from_env()
+        while True:
+            time.sleep(5)
+            # 获取容器列表
+            containers = client.containers.list()
+            run = False
+            # 打印容器列表
+            for container in containers:
+                if container_name == container.name:
+                    run = True
+                    break
+            if not run:
+                break
+        time.sleep(5)
+        upload_simulation(parse_prefix, mp41)
+    except Exception as e:
+        logging.exception("生成仿真视频报错 %s" % str(e))
+
+
+def is_upload_completed(bucket, prefix):
+    target_number = str(prefix).split('_')[-1][:-1]
+    count = 0
+    for obj in oss2.ObjectIterator(bucket, prefix=prefix):
+        if obj.key != prefix:
+            count += 1
+    return int(count) == int(target_number)
+
+
+# ------- 获取合并之后的bag包,解析出csv -------
+if __name__ == '__main__':
+    while True:
+        try:
+            logging.info("开始新一轮扫描")
+            oss_delete_list = []
+            prefix_list = []
+            # 2 获取已经上传完成的所有目录并分组
+            for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
+                try:
+                    # 获取合并后的包
+                    merged_bag_object_key = str(obj1.key)
+                    if 'data_merge' in str(obj1.key) and str(obj1.key).endswith('.bag'):
+                        merged_bag_object_key_split = merged_bag_object_key.split('/')
+                        merged_prefix = '/'.join(merged_bag_object_key_split[:-1])
+                        parse_prefix = merged_prefix.replace('data_merge', 'data_parse')
+                        parse_prefix_full = merged_bag_object_key.replace('data_merge', 'data_parse')[:-4] + '/'
+                        xosc_done = False
+                        mp4_done = False
+                        for obj3 in oss2.ObjectIterator(bucket, prefix=str(parse_prefix_full)):
+                            if xoscName in str(obj3.key):
+                                xosc_done = True
+                            if '/scenario_orig.mp4' in str(obj3.key):
+                                mp4_done = True
+                        if not xosc_done:
+                            continue
+                        if mp4_done:
+                            continue
+                        error_bag_list = json_utils.parse_json_to_string_array(error_bag_json)
+                        if str(parse_prefix_full) in error_bag_list:
+                            continue
+                        logging.info("需要生成仿真视频: %s" % str(parse_prefix_full))
+                        parse_prefix_full = str(parse_prefix_full)
+                        local_dir_full = path1 + parse_prefix_full
+                        if not os.path.exists(local_dir_full):
+                            os.makedirs(local_dir_full)
+                        # 下载两个csv
+                        root_path1 = local_dir_full + 'orig/'
+                        if not os.path.exists(root_path1):
+                            os.makedirs(root_path1)
+                        bucket.get_object_to_file(parse_prefix_full + xoscName, root_path1 + 'scenario_orig.xosc')
+                        move_xosc_before_simulation(root_path1)
+                        simulation(parse_prefix_full, root_path1 + 'simulation.mp4')
+                except Exception as e:
+                    logging.exception("局部异常处理: %s", str(e))
+            # 删除本地临时文件
+            time.sleep(sleep_time)
+        except Exception as e:
+            logging.exception("全局异常处理: %s", str(e))

+ 0 - 0
src/python2/pjibot_patrol/2xosc-errorBag.json


+ 9 - 0
src/python2/pjibot_patrol/2xosc-nohup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+if [ ! -d "./log" ]; then
+    mkdir "./log"
+    echo "Directory './log' created."
+else
+    echo "Directory './log' already exists."
+fi
+rm -rf log/2xosc*
+nohup python2 2xosc-pjibot_patrol.py > log/2xosc-pjibot_patrol.out 2>&1 &

+ 131 - 0
src/python2/pjibot_patrol/2xosc-pjibot_patrol.py

@@ -0,0 +1,131 @@
+# -*- coding: utf-8 -*-
+# ------- 全局配置 -------
+import sys
+reload(sys)
+sys.setdefaultencoding("utf-8")
+import os
+import time
+import oss2
+import logging
+import json
+import subprocess
+import io
+from utils import json_utils
+path1 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/'
+path2 = '/mnt/disk001/dcl_data_process/src/python3/pjibot_outdoor/'
+logging.basicConfig(filename=path1 + 'log/2xosc-pjibot_patrol.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
+key1 = 'pjibot_patrol/'
+sleep_time = 30  # 每多少秒扫描一次
+error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/2xosc-errorBag.json"
+# 1 创建阿里云对象
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket = oss2.Bucket(auth, endpoint, 'open-bucket')
+
+def generate_xosc(parse_prefix, local_parse_dir, local_delete_list):
+    try:
+        os.chdir(path2)
+        command2 = 'python3 jiqiren_outdoor.py {} 0'.format(local_parse_dir[:-1])  # 配送机器人0 巡检机器人1
+        logging.info("进入目录 %s 调用命令2: %s", path2, command2)
+        process = subprocess.Popen(command2, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        stdout, stderr = process.communicate()  # 等待进程执行完成并获取输出
+        if process.returncode == 0:
+            logging.info("命令输出: %s", stdout.decode("utf-8"))
+        else:
+            logging.error("命令错误输出: %s", stderr.decode("utf-8"))
+        local_xosc_path2 = local_parse_dir + 'simulation/xosc/openx_outdoor0.xosc'
+        bucket.put_object_from_file(parse_prefix + 'scenario.xosc', local_xosc_path2)
+        bucket.put_object_from_file(parse_prefix + 'scenario_hmi.xosc', local_xosc_path2)
+        logging.info("上传 scenario_hmi.xosc 成功: %s" % str(parse_prefix + 'scenario.xosc'))
+        
+        # ------- 处理 output.json - 开始 -------
+        output_json_path = local_parse_dir + 'simulation/xosc/output.json'
+        callback_json_oss_key = parse_prefix+'callback.json'
+        callback_json_local = local_parse_dir+'callback.json'
+        try:
+            # 1 解析 output.json
+            if os.path.exists(output_json_path):
+                outputs = json_utils.parse_json_to_string_array(output_json_path)
+                # 2 将 output.json 添加到 callback.json 的 check 字段
+                bucket.get_object_to_file(callback_json_oss_key, callback_json_local)
+                with io.open(callback_json_local, 'r', encoding='utf-8') as f:
+                    data = json.load(f)
+                if 'check' not in data:
+                    data['check'] = []
+                data['check'].extend(outputs)
+                data['check'] = list(set(data['check']))
+                json_data = json.dumps(data, ensure_ascii=False, indent=4)
+                with io.open(callback_json_local, 'w', encoding='utf-8') as f:
+                    f.write(unicode(json_data))
+                bucket.put_object_from_file(callback_json_oss_key, callback_json_local)
+        except Exception as e3:
+            # todo 可能没有callback.json,已经处理成 callback_done.json了,暂时不管
+            logging.exception("处理 output.json报错: %s" % str(e3))
+            pass
+        # ------- 处理 output.json - 结束 -------
+        
+        
+        # 处理删除
+        local_delete_list.append(local_xosc_path2)
+        local_delete_list.append(callback_json_local)
+    except Exception as e:
+        error_bag_list = json_utils.parse_json_to_string_array(error_bag_json)
+        error_bag_list.append(parse_prefix)
+        json_utils.list_to_json_file(error_bag_list, error_bag_json)
+        logging.exception("生成xosc报错: %s" % str(e))
+
+if __name__ == '__main__':
+    while True:
+        try:
+            logging.info("开始新一轮扫描")
+            local_delete_list = []
+            oss_delete_list = []
+            prefix_list = []
+            # 2 获取已经上传完成的所有目录并分组
+            for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
+                try:
+                    # 获取合并后的包
+                    merged_bag_object_key = str(obj1.key)
+                    if 'data_merge' in str(obj1.key) and str(obj1.key).endswith('.bag'):
+                        merged_bag_object_key_split = merged_bag_object_key.split('/')
+                        merged_prefix = '/'.join(merged_bag_object_key_split[:-1])
+                        parse_prefix = merged_prefix.replace('data_merge', 'data_parse')
+                        parse_prefix_full = merged_bag_object_key.replace('data_merge', 'data_parse')[:-4] + '/'
+                        xosc_done = False
+                        csv1_done = False
+                        csv2_done = False
+                        for obj3 in oss2.ObjectIterator(bucket, prefix=str(parse_prefix_full)):
+                            if '/scenario_hmi.xosc' in str(obj3.key): # 仿真使用的 scenario_hmi.xosc 所以必须有
+                                xosc_done = True
+                            if '/objects_pji.csv' in str(obj3.key):
+                                csv1_done = True
+                            if '/ego_pji.csv' in str(obj3.key):
+                                csv2_done = True
+                        if xosc_done:
+                            continue
+                        if not csv1_done:
+                            continue
+                        if not csv2_done:
+                            continue
+                        error_bag_list = json_utils.parse_json_to_string_array(error_bag_json)
+                        if str(parse_prefix_full) in error_bag_list:
+                            continue
+                        logging.info("需要生成 scenario_hmi.xosc: %s" % str(parse_prefix_full))
+                        local_dir_full = path1 + parse_prefix_full
+                        if not os.path.exists(local_dir_full):
+                            os.makedirs(local_dir_full)
+                        bucket.get_object_to_file(parse_prefix_full + 'objects_pji.csv',local_dir_full + 'objects_pji.csv')
+                        bucket.get_object_to_file(parse_prefix_full + 'ego_pji.csv', local_dir_full + 'ego_pji.csv')
+                        generate_xosc(parse_prefix_full, local_dir_full, local_delete_list)
+                except Exception as e:
+                    logging.exception("局部异常处理: %s", str(e))
+            # 删除本地临时文件
+            if len(local_delete_list) > 0:
+                for local_delete in local_delete_list:
+                    try:
+                        os.remove(local_delete)
+                    except Exception as e:
+                        pass
+            time.sleep(sleep_time)
+        except Exception as e:
+            logging.exception("全局异常处理: %s", str(e))

+ 1 - 1
src/python2/pjibot_patrol/callback-nohup.sh

@@ -5,5 +5,5 @@ if [ ! -d "./log" ]; then
 else
     echo "Directory './log' already exists."
 fi
-rm -rf log/callback-pjibot_patrol.out log/callback-pjibot_patrol.log
+rm -rf log/callback*
 nohup python2 callback-pjibot_patrol.py > log/callback-pjibot_patrol.out 2>&1 &

+ 40 - 38
src/python2/pjibot_patrol/callback-pjibot_patrol.py

@@ -1,11 +1,19 @@
 # -*- coding: utf-8 -*-
+import sys
+reload(sys)
+sys.setdefaultencoding("utf-8")
 import json
 import time
 import urllib2
 import oss2
-from datetime import datetime, timedelta
 import logging
+from datetime import datetime, timedelta
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket_name = 'pji-bucket1'
+bucket = oss2.Bucket(auth, endpoint, bucket_name)
 path1 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/'
+path3 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/callback/'
 logging.basicConfig(filename=path1 + 'log/callback-pjibot_patrol.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
 key1 = 'pjibot_patrol/'
 key2 = 'data/'
@@ -23,41 +31,43 @@ def add_hour(date_string, hour_number):
     new_date = original_date + timedelta(hours=hour_number)
     return new_date.strftime("%Y-%m-%d-%H-%M-%S")
 
+def judge_pcd(callback_json_oss_key):
+    json_content = bucket.get_object(callback_json_oss_key).read()
+    json_object = json.loads(json_content)
+    check = json_object['check']
+    if '点云缺失' in check:
+        return True
+
 
 if __name__ == '__main__':
-    auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
-    endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
-    bucket_name = 'pji-bucket1'
-    bucket = oss2.Bucket(auth, endpoint, bucket_name)
     while True:
         logging.info("开始新一轮扫描")
         try:
             local_delete_list = []
             oss_delete_list = []
             upload_completed_prefix_list = []
-            # 4 获取即将被合并的bag目录
             for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
                 try:
                     if 'callback.json' in str(obj1.key):
                         prefix = '/'.join(str(obj1.key).split('/')[:-1])
-
                         file1 = False
                         file2 = False
                         file3 = False
-                        file4 = False
+                        pcd_ok = False
                         file5 = False
                         file7 = False
                         file8 = False
                         file9 = False
-                        for obj2 in oss2.ObjectIterator(bucket, prefix=prefix+ '/'):
+                        for obj2 in oss2.ObjectIterator(bucket, prefix=prefix + '/'):
                             if '/callback_done.json' in str(obj2.key):
                                 file1 = True
+                                break
                             if '/ego_pji.csv' in str(obj2.key):
                                 file2 = True
                             if '/objects_pji.csv' in str(obj2.key):
                                 file3 = True
                             if '/pcd_overlook.mp4' in str(obj2.key):
-                                file4 = True
+                                pcd_ok = True
                             if '/drive.csv' in str(obj2.key):
                                 file5 = True
                             if '/scenario_orig.mp4' in str(obj2.key):
@@ -66,46 +76,36 @@ if __name__ == '__main__':
                                 file8 = True
                             if '/trajectory_pji.csv' in str(obj2.key):
                                 file9 = True
-                        if file1 or not file2 or not file3 or not file4 or not file5 or not file7 or not file8 or not file9:
+                        if not pcd_ok:
+                            pcd_ok = judge_pcd(str(obj1.key))
+                        if file1 or not file2 or not file3 or not pcd_ok or not file5 or not file7 or not file8 or not file9:
                             continue
                         time.sleep(1)
                         logging.info("发送:%s", prefix)
-                        # 1 获取json内容
                         json_content = bucket.get_object(str(obj1.key)).read()
-                        # 2 获取token
                         json_object = json.loads(json_content)
-                        data1 = {
-                            "equipmentNo": json_object['equipmentNo'],
-                            "secretKey": json_object['secretKey']
-                        }
+                        data1 = {"equipmentNo": json_object['equipmentNo'],"secretKey": json_object['secretKey']}
                         json_data1 = json.dumps(data1)
                         logging.info("授权接口请求中: %s" % url1_private)
                         logging.info("授权发送参数为: %s" % str(data1))
-                        request1 = urllib2.Request(url1_private, json_data1,
-                                                   headers={'Content-Type': 'application/json'})
+                        request1 = urllib2.Request(url1_private, json_data1,headers={'Content-Type': 'application/json'})
                         response1 = urllib2.urlopen(request1)
                         result_json1 = response1.read()
                         result_object1 = json.loads(result_json1)
                         logging.info("授权接口请求结果为: %s", result_object1)
                         access_token = result_object1.get('data').get('accessToken')
-                        # 要发送的JSON参数
-                        try:
-                            # logging.info("bag文件为: %s", json_object['rosBagPath'])
-                            old_date = json_object['dataName']
-                            data_size = bucket.get_object_meta(json_object['rosBagPath']).content_length
-                            equipment_no = json_object['equipmentNo']
-                            old_file_path = json_object['filePath']
-                            old_ros_bag_path = json_object['rosBagPath']
-                            task_id = json_object['taskId']
-                            trigger_id = json_object['triggerId']
-                            check = json_object['check']
-                            check_order = ['自车数据缺失', '不在道路范围', '无规划路径', '目标点缺失','点云缺失', '点云丢帧', '解析程序错误', '还原程序错误', '评价程序错误']
-                            check_order_dict = dict((item, idx) for idx, item in enumerate(check_order))
-                            check = sorted(check, key=lambda x: check_order_dict.get(x, float('inf')))
-                            check = ','.join(check) # 数组元素拼接成字符串序列
-                        except Exception as e:
-                            logging.exception("callback报错:%s", str(e))
-                            continue
+                        old_date = json_object['dataName']
+                        data_size = bucket.get_object_meta(json_object['rosBagPath']).content_length
+                        equipment_no = json_object['equipmentNo']
+                        old_file_path = json_object['filePath']
+                        old_ros_bag_path = json_object['rosBagPath']
+                        task_id = json_object['taskId']
+                        trigger_id = json_object['triggerId']
+                        check = json_object['check']
+                        check_order = ['自车数据缺失', '不在道路范围', '无规划路径', '目标点缺失','点云缺失', '点云丢帧', '解析程序错误', '还原程序错误', '评价程序错误']
+                        check_order_dict = dict((item, idx) for idx, item in enumerate(check_order))
+                        check = sorted(check, key=lambda x: check_order_dict.get(x, float('inf')))
+                        check = ','.join(check) # 数组元素拼接成字符串序列
                         if old_date is None:
                             old_date = ''
                         # 将时区统一(室外不需要需要加8,根据机器人终端的时区判断)
@@ -150,8 +150,9 @@ if __name__ == '__main__':
                                 "triggerId": trigger_id,
                                 "check":check
                             }
+
                         json_data2 = json.dumps(data2)
-                        bucket.put_object(callback_done_oss_key, json_data2)
+                        bucket.put_object(callback_done_oss_key, unicode(json_data2))
                         logging.info("回调接口请求中:%s" % url2_private)
                         logging.info("回调接口发送参数为: %s" % str(data2))
                         request2 = urllib2.Request(url2_private, json_data2,headers={'Content-Type': 'application/json','authorization': access_token})
@@ -161,6 +162,7 @@ if __name__ == '__main__':
                         logging.info("回调接口请求结果为: %s", result_object2)
                 except Exception as e:
                     logging.exception("局部异常处理: %s" % str(e))
+                    continue
             time.sleep(10)
         except Exception as e:
             logging.exception("全局错误处理: %s" % str(e))

+ 4 - 0
src/python2/pjibot_patrol/csv-errorBag.json

@@ -0,0 +1,4 @@
+[
+    "pjibot_patrol/pjibot-P1YVXJ1M231M00022/data_parse/2024-08-01-17-28-27_1038/", 
+    "pjibot_patrol/pjibot-P1YVXJ1M231M00023/data_parse/VP100M23-BJ-movebase-2024-11-15-11-23-25/"
+]

+ 2 - 1
src/python2/pjibot_patrol/csv-nohup.sh

@@ -5,4 +5,5 @@ if [ ! -d "./log" ]; then
 else
     echo "Directory './log' already exists."
 fi
-nohup python2 csv-pjibot_patrol.py > log/csv.out 2>&1 &
+rm -rf log/csv*
+nohup python2 csv-pjibot_patrol.py > log/csv-pjibot_patrol.out 2>&1 &

+ 2 - 1
src/python2/pjibot_patrol/merge-nohup.sh

@@ -5,4 +5,5 @@ if [ ! -d "./log" ]; then
 else
     echo "Directory './log' already exists."
 fi
-nohup python2 merge-pjibot_patrol.py > log/merge.out 2>&1 &
+rm -rf log/merge*
+nohup python2 merge-pjibot_patrol.py > log/merge-pjibot_patrol.out 2>&1 &

+ 1 - 0
src/python2/pjibot_patrol/pcd-nohup.sh

@@ -5,4 +5,5 @@ if [ ! -d "./log" ]; then
 else
     echo "Directory './log' already exists."
 fi
+rm -rf log/pcd*
 nohup python2 pcd-pjibot_patrol.py > log/pcd-pjibot_patrol.out 2>&1 &

+ 1 - 1
src/python2/pjibot_patrol/pcd-pjibot_patrol.py

@@ -25,7 +25,7 @@ def parse_to_pcd_mp4(merged_bag_file_path, parse_prefix2, local_parse_dir, local
     try:
         local_pcd_mp4_dir = pcdtovideo_monitor_overlook.parse(merged_bag_file_path, local_parse_dir + '/pcd/')
         pcd_mp4_file_name = 'pcd_overlook'
-        local_mp4_path = str(local_pcd_mp4_dir) + '/jpg/'+pcd_mp4_file_name+'.mp4'
+        local_mp4_path = str(local_pcd_mp4_dir) + '/'+pcd_mp4_file_name+'.mp4'
         oss_csv_object_key3 = parse_prefix2 + pcd_mp4_file_name + '.mp4'
         bucket.put_object_from_file(oss_csv_object_key3, local_mp4_path)
         logging.info("上传点云视频到: %s", oss_csv_object_key3)

+ 0 - 73
src/python2/pjibot_patrol/resource/parse_robot_image.py

@@ -1,73 +0,0 @@
-# coding: utf-8
-# !/usr/bin/env python2
-
-import sys
-
-import os
-import rospy
-import rosbag
-import csv
-import cv2
-from cv_bridge import CvBridge, CvBridgeError
-import argparse
-import struct
-import subprocess
-from subprocess import Popen, PIPE
-
-bridge = CvBridge()
-
-
-def parsebag(f, output_dir, target_topic):
-    rosbag_name = f.split("/")[-1].split(".")[0]
-    output_path = os.path.join(output_dir, rosbag_name)
-    camera_exist_flag = False
-
-    with rosbag.Bag(f, 'r') as bag:
-        count = 0
-        start_time = bag.get_start_time()
-        end_time = bag.get_end_time()
-        duration = end_time - start_time
-        print('duration', duration)
-        topics = bag.get_type_and_topic_info()[1].keys()
-        if target_topic in topics:
-            for topic, msg, t in bag.read_messages(topics=[target_topic]):
-                camera_exist_flag = True
-                img = bridge.imgmsg_to_cv2(msg, 'bgr8')
-                img_resized = cv2.resize(img, (1920, 1080))
-                # img = bridge.compressed_imgmsg_to_cv2(msg, 'bgr8')
-                timestr = msg.header.stamp.to_nsec()
-                image_name = str(timestr) + ".jpg"
-                if not os.path.exists(output_path + '_' + 'image'):
-                    os.makedirs(output_path + '_' + 'image')
-                output_path_img = os.path.join(output_path + '_' + 'image', image_name)
-                cv2.imwrite(output_path_img, img_resized)
-                # print(count)
-                count = count + 1
-
-    return count, duration, camera_exist_flag
-
-
-def parse(input_dir, output_dir):
-    # input_dir=sys.argv[1]
-    # output_dir = sys.argv[2]
-    topic = '/image_raw'  # /camera/color/image_raw
-
-    num_count, duration, flag = parsebag(input_dir, output_dir, topic)
-
-    if flag:
-        dirt = os.path.join(output_dir, input_dir.split('/')[-1].split('.')[0] + '_' + 'image')
-        bagtime = duration
-        hz = str(float(num_count) / bagtime)
-        print('bagtime=', bagtime)
-        print('num_count=', num_count)
-
-        command = ['ffmpeg', '-f', 'image2', '-r', hz, '-pattern_type', 'glob', '-i'] + [dirt + '/*.jpg'] + ['-tag:v',
-                                                                                                             'avc1',
-                                                                                                             '-y'] + [
-                      dirt + '/camera.mp4']
-        p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-        p.communicate()
-        print('done')
-        return flag, dirt
-    else:
-        return flag, ''

+ 23 - 7
src/python2/pjibot_patrol/resource/pcdtovideo_monitor_overlook.py

@@ -74,10 +74,12 @@ def parse(input_dir, output_dir):
     with rosbag.Bag(input_dir, 'r') as bag:
         bag_start_time = bag.get_start_time()
         bag_end_time = bag.get_end_time()
+        print('bag_start_time=',bag_start_time)
+        print('bag_end_time=',bag_end_time)
         num_count = 0
-        for topic, msg, t in bag.read_messages():
-            if topic == "/velodyne_points": #/camera/depth/points   # /scan_map_icp_amcl_node/scan_point_transformed
-                num_count += 1
+        for topic, msg, t in bag.read_messages(topics=['/velodyne_points']):
+             #/camera/depth/points   # /scan_map_icp_amcl_node/scan_point_transformed
+             num_count += 1
         start_time = bag.get_start_time()
         end_time = bag.get_end_time()
         # 计算rosbag的持续时间
@@ -93,6 +95,7 @@ def parse(input_dir, output_dir):
     os.system(command)
     file1 = os.path.join(output_dir[0:-4], 'pcd_ascii')
     file2 = os.path.join(output_dir[0:-4], 'jpg')
+    file3 = os.path.join(output_dir[0:-4], 'pcd')
     if not os.path.exists(file1):
         os.makedirs(file1)
     if not os.path.exists(file2):
@@ -127,6 +130,7 @@ def parse(input_dir, output_dir):
         p = Popen(result_string, shell=True, cwd=output_dir[0:-4] + '/', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         p.wait()
         
+        
         '''
         
         '''
@@ -138,12 +142,11 @@ def parse(input_dir, output_dir):
         # 定义图片文件夹路径
         folder_path = file2
         
-        #根据rosbag的起止时间生成黑色图片2024.11.22添加
+        #根据rosbag的起止时间生成黑色图片
         black_image = np.zeros((512, 512, 3), dtype=np.uint8)
         cv2.imwrite(os.path.join(file2,str(bag_start_time)+'.jpg'), black_image)
         cv2.imwrite(os.path.join(file2,str(bag_end_time)+'.jpg'), black_image)
         
-
         # 获取文件夹中的所有图片文件
         image_files = [f for f in os.listdir(folder_path) if f.endswith('.jpg')]
 
@@ -155,6 +158,9 @@ def parse(input_dir, output_dir):
 
         # 获取图片的形状
         image_shape = first_image.shape
+        
+        
+        
 
         # 创建视频写入对象
         video_path=os.path.join(file2,'pcd_overlook.mp4')
@@ -172,7 +178,7 @@ def parse(input_dir, output_dir):
 
             # 计算时间间隔
             time_interval = next_timestamp - current_timestamp
-            #print(time_interval)
+            print(time_interval)
 
             # 根据实际时间间隔调整循环次数
             video_writer.write(current_image)
@@ -182,6 +188,16 @@ def parse(input_dir, output_dir):
 
         # 释放资源
         video_writer.release()
+        if os.path.exists(video_path):
+            video_output_path=os.path.join(output_dir[0:-4],'pcd_overlook.mp4')
+            command = ["ffmpeg", "-i", video_path, "-c:v", "libx264", video_output_path]
+            p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            p.communicate()
+            os.remove(video_path)
+            shutil.rmtree(file1)
+            shutil.rmtree(file2)
+            shutil.rmtree(file3)
+
     
     e_time=datetime.datetime.now()
     print("using "+str(e_time-s_time)+ "s")
@@ -189,4 +205,4 @@ def parse(input_dir, output_dir):
     #shutil.rmtree(file2)
     #shutil.rmtree(output_dir)
     return output_dir[0:-4]
-
+    

+ 1 - 1
src/python2/pjibot_patrol/simulation-nohup.sh

@@ -5,5 +5,5 @@ if [ ! -d "./log" ]; then
 else
     echo "Directory './log' already exists."
 fi
-rm -rf log/simulation-pjibot_patrol.out log/simulation-pjibot_patrol.log
+rm -rf log/simulation*
 nohup python2 simulation-pjibot_patrol.py > log/simulation-pjibot_patrol.out 2>&1 &

+ 18 - 9
src/python2/pjibot_patrol/simulation-pjibot_patrol.py

@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+# ------- 全局配置 -------
 import os
 import time
 import oss2
@@ -6,15 +7,20 @@ import xml.etree.ElementTree as ET
 import shutil
 import docker
 import logging
+from utils import json_utils
 key1 = 'pjibot_patrol/'
 path1 = '/scenarios4/'
+container_name = 'vtd4'
 path2 = '/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/'
-path3 = '/mnt/disk001/simulation_outdoor/'
 vehicle_name = 'PuJin_patrol_robot'  # 配送 PuJin_distribution 巡检 PuJin_patrol_robot
 xoscName = 'scenario.xosc'
 logging.basicConfig(filename=path2 + 'log/simulation-pjibot_patrol.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
-sleep_time = 60  # 每多少秒扫描一次
-
+sleep_time = 30  # 每多少秒扫描一次
+error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/simulation-errorBag.json"
+# 1 创建阿里云对象
+auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
+endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
+bucket = oss2.Bucket(auth, endpoint, 'pji-bucket1')
 
 def move_xosc_before_simulation(root_path):
     try:
@@ -63,12 +69,15 @@ def upload_simulation(parse_prefix, mp41):
         logging.info('上传仿真视频到 %s' % parse_prefix + 'scenario_orig.mp4')
         shutil.rmtree(path1)  # 仿真完就删除
     except Exception as e:
+        error_bag_list = json_utils.parse_json_to_string_array(error_bag_json)
+        error_bag_list.append(parse_prefix)
+        json_utils.list_to_json_file(error_bag_list, error_bag_json)
         logging.exception("上传视频报错 %s" % str(e))
 
 
 def simulation(parse_prefix, mp41):
     try:
-        os.system("docker start vtd1")
+        os.system("docker start "+container_name)
         # 实例化Docker客户端
         client = docker.from_env()
         while True:
@@ -78,7 +87,7 @@ def simulation(parse_prefix, mp41):
             run = False
             # 打印容器列表
             for container in containers:
-                if 'vtd1' == container.name:
+                if container_name == container.name:
                     run = True
                     break
             if not run:
@@ -100,10 +109,6 @@ def is_upload_completed(bucket, prefix):
 
 # ------- 获取合并之后的bag包,解析出csv -------
 if __name__ == '__main__':
-    # 1 创建阿里云对象
-    auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
-    endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
-    bucket = oss2.Bucket(auth, endpoint, 'pji-bucket1')
     while True:
         try:
             logging.info("开始新一轮扫描")
@@ -130,6 +135,9 @@ if __name__ == '__main__':
                             continue
                         if mp4_done:
                             continue
+                        error_bag_list = json_utils.parse_json_to_string_array(error_bag_json)
+                        if str(parse_prefix_full) in error_bag_list:
+                            continue
                         logging.info("需要生成仿真视频: %s" % str(parse_prefix_full))
                         parse_prefix_full = str(parse_prefix_full)
                         local_dir_full = path1 + parse_prefix_full
@@ -144,6 +152,7 @@ if __name__ == '__main__':
                         simulation(parse_prefix_full, root_path1 + 'simulation.mp4')
                 except Exception as e:
                     logging.exception("局部异常处理: %s", str(e))
+            # 删除本地临时文件
             time.sleep(sleep_time)
         except Exception as e:
             logging.exception("全局异常处理: %s", str(e))

+ 4 - 0
src/python2/pjibot_patrol/xosc-errorBag.json

@@ -0,0 +1,4 @@
+[
+    "pjibot_patrol/pjibot-P1YVXJ1M231M00022/data_parse/2024-08-01-17-28-27_1038/", 
+    "pjibot_patrol/pjibot-P1YVXJ1M231M00023/data_parse/VP100M23-BJ-movebase-2024-11-15-11-23-25/"
+]

+ 1 - 1
src/python2/pjibot_patrol/xosc-nohup.sh

@@ -5,5 +5,5 @@ if [ ! -d "./log" ]; then
 else
     echo "Directory './log' already exists."
 fi
-rm -rf log/xosc-pjibot_patrol.out log/xosc-pjibot_patrol.log
+rm -rf log/xosc*
 nohup python2 xosc-pjibot_patrol.py > log/xosc-pjibot_patrol.out 2>&1 &

+ 4 - 4
src/python2/pjibot_patrol/xosc-pjibot_patrol.py

@@ -16,7 +16,7 @@ path2 = '/mnt/disk001/dcl_data_process/src/python3/pjibot_outdoor/'
 logging.basicConfig(filename=path1 + 'log/xosc-pjibot_patrol.log', level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s')
 key1 = 'pjibot_patrol/'
 sleep_time = 60  # 每多少秒扫描一次
-error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot_delivery/xosc-errorBag.json"
+error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot_patrol/xosc-errorBag.json"
 # 1 创建阿里云对象
 auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
 endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
@@ -33,7 +33,6 @@ def generate_xosc(parse_prefix, local_parse_dir, local_delete_list):
         if process.returncode == 0:
             logging.info("命令输出: %s", stdout.decode("utf-8"))
         else:
-            logging.error("命令执行失败,错误码: %d", process.returncode)
             logging.error("命令错误输出: %s", stderr.decode("utf-8"))
         local_xosc_path2 = local_parse_dir + 'simulation/xosc/openx_outdoor0.xosc'
         bucket.put_object_from_file(parse_prefix + 'scenario.xosc', local_xosc_path2)
@@ -43,7 +42,7 @@ def generate_xosc(parse_prefix, local_parse_dir, local_delete_list):
         # ------- 处理 output.json - 开始 -------
         output_json_path = local_parse_dir + 'simulation/xosc/output.json'
         callback_json_oss_key = parse_prefix+'callback.json'
-        callback_json_local = local_parse_dir+'/callback.json'
+        callback_json_local = local_parse_dir+'callback.json'
         try:
             # 1 解析 output.json
             if os.path.exists(output_json_path):
@@ -55,6 +54,7 @@ def generate_xosc(parse_prefix, local_parse_dir, local_delete_list):
                 if 'check' not in data:
                     data['check'] = []
                 data['check'].extend(outputs)
+                data['check'] = list(set(data['check']))
                 json_data = json.dumps(data, ensure_ascii=False, indent=4)
                 with io.open(callback_json_local, 'w', encoding='utf-8') as f:
                     f.write(unicode(json_data))
@@ -126,7 +126,7 @@ if __name__ == '__main__':
                     try:
                         os.remove(local_delete)
                     except Exception as e:
-                        logging.exception("删除本地临时文件报错: %s" % str(e))
+                        pass
             time.sleep(sleep_time)
         except Exception as e:
             logging.exception("全局异常处理: %s", str(e))