LingxinMeng 5 ay önce
ebeveyn
işleme
806c694f29

+ 26 - 4
src/python2/pjibot/callback-pjibot_guide.py

@@ -29,6 +29,24 @@ def add_hour(date_string, hour_number):
     return new_date.strftime("%Y-%m-%d-%H-%M-%S")
 
 
+def judge_report_pdf(callback_json_oss_key):
+    pdf = False
+    try:
+        json_content = bucket.get_object(callback_json_oss_key).read()
+        json_object = json.loads(json_content)
+        if 'check' not in json_object:
+            logging.error("Missing 'check' field in %s", callback_json_oss_key)
+            return pdf
+        check = json_object['check']
+        if '位姿信息缺失' in check or '自车数据缺失' in check:
+            pdf = True
+    except ValueError as e:
+        logging.error("Failed to decode JSON from %s", e)
+    except Exception as e:
+        logging.error("Error processing %s", e)
+    return pdf
+
+
 if __name__ == '__main__':
     # 1 登录验证 。
     auth = oss2.Auth('n8glvFGS25MrLY7j', 'xZ2Fozoarpfw0z28FUhtg8cu0yDc5d')
@@ -57,7 +75,7 @@ if __name__ == '__main__':
                         done6 = False
                         done7 = False
                         done8 = False
-                        done9 = False
+                        pdf_ok = False
                         for obj2 in oss2.ObjectIterator(bucket, prefix=prefix):
                             if '/EgoState_pji.csv' in str(obj2.key):
                                 done1 = True
@@ -72,9 +90,13 @@ if __name__ == '__main__':
                             if '/tfstatic.bag' in str(obj2.key):
                                 done8 = True
                             if '/report.pdf' in str(obj2.key):
-                                done9 = True
-                        if not done1 or not done2 or not done5 or not done6 or not done7 or not done8 or not done9:
+                                pdf_ok = True
+                        if not done1 or not done2 or not done5 or not done6 or not done7 or not done8:
                             continue
+                        if not pdf_ok:
+                            pdf_ok = judge_report_pdf(str(obj1.key))
+                            if not pdf_ok:
+                                continue
                         time.sleep(1)
                         logging.info("发送: %s", str(obj1.key))
                         # 1 获取json内容
@@ -120,7 +142,7 @@ if __name__ == '__main__':
                                 bucket.copy_object(bucket_name, str(obj_old.key),
                                                    str(obj_old.key).replace(old_date, new_date).replace('callback.json',
                                                                                                         'callback_done.json'))
-                                bucket.delete_object(str(obj_old.key)) # 删除 callback.json
+                                bucket.delete_object(str(obj_old.key))  # 删除 callback.json
                         # todo 时区不变也就不需要移动文件了
                         #     else:
                         #         bucket.copy_object(bucket_name, str(obj_old.key),

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

@@ -62,5 +62,10 @@
     "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-P1YNYD1M223000101/data_parse/2024-12-05-16-03-53_obstacledetection_37/"
+    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-12-05-16-03-53_obstacledetection_37/", 
+    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-12-15-15-20-20_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-12-20-06-07-28_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M229000129/data_parse/2024-12-23-01-07-36_obstacledetection_45/", 
+    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-12-25-09-54-00_obstacledetection_30/", 
+    "pjibot/pjibot-P1YNYD1M223000101/data_parse/2024-12-25-10-02-50_obstacledetection_45/"
 ]

+ 1 - 1
src/python2/pjibot/camera-nohup.sh

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

+ 23 - 13
src/python2/pjibot/camera-pjibot_guide.py

@@ -12,28 +12,38 @@ sleep_time = 30  # 每多少秒扫描一次
 error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot/camera-errorBag.json"
 
 
+def get_paths(local_parse_dir,parse_prefix):
+    local_mp4_dir1 = local_parse_dir + '/camera1/'
+    mp4_file_name1 = 'camera1'
+    local_mp4_file_path1 = local_mp4_dir1 + mp4_file_name1 + '.mp4'
+    oss_csv_object_key1 = parse_prefix + 'camera.mp4'
+
+
+    local_mp4_dir2 = local_parse_dir + '/camera2/'
+    mp4_file_name2 = 'camera2'
+    local_mp4_file_path2 = local_parse_dir + '/camera2/' + mp4_file_name2 + '.mp4'
+    oss_csv_object_key2 = parse_prefix + mp4_file_name2 + '.mp4'
+
+    return local_mp4_dir1,local_mp4_file_path1,oss_csv_object_key1, local_mp4_dir2,local_mp4_file_path2, oss_csv_object_key2
+
 def parse_to_mp4(merged_bag_file_path, parse_prefix, local_parse_dir, local_delete_list):
     try:
-        local_mp4_dir1 = parse_pji_image.parse1('/ob_camera_01/color/image_raw', merged_bag_file_path,local_parse_dir + '/camera1/')
-        local_mp4_file_path1 = local_parse_dir + '/camera1/camera1.mp4'
-        local_delete_list.append(local_mp4_file_path1)
-        oss_csv_object_key1 = parse_prefix +  'camera.mp4'
+        local_mp4_dir1,local_mp4_file_path1,oss_csv_object_key1, local_mp4_dir2,local_mp4_file_path2, oss_csv_object_key2 = get_paths(local_parse_dir,parse_prefix)
+
+        parse_pji_image.parse1('/ob_camera_01/color/image_raw', merged_bag_file_path,local_mp4_dir1)
         bucket.put_object_from_file(oss_csv_object_key1, local_mp4_file_path1)
         logging.info("上传 camera1.mp4 成功: %s" , str(oss_csv_object_key1))
-        local_mp4_dir2 = parse_pji_image.parse2('/ob_camera_02/color/image_raw', merged_bag_file_path,local_parse_dir + '/camera2/')
-        mp4_file_name2 = 'camera2'
-        local_mp4_file_path2 = local_parse_dir + '/camera2/' + mp4_file_name2 + '.mp4'
-        local_delete_list.append(local_mp4_file_path2)
-        oss_csv_object_key2 = parse_prefix + mp4_file_name2 + '.mp4'
+
+        parse_pji_image.parse2('/ob_camera_02/color/image_raw', merged_bag_file_path,local_mp4_dir2)
         bucket.put_object_from_file(oss_csv_object_key2, local_mp4_file_path2)
         logging.info("上传 camera2.mp4 成功: %s" , str(oss_csv_object_key1))
 
+        local_delete_list.append(local_mp4_file_path1)
+        local_delete_list.append(local_mp4_file_path2)
     except Exception as e2:
-        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("生成摄像头视频报错,添加到 camera-errorBag.json: %s", e2)
+        json_utils.add_error(parse_prefix,error_bag_json)
+        # 当出现异常时执行的代码
 
 
 # ------- 获取合并之后的bag包,解析出csv -------

+ 67 - 62
src/python2/pjibot/csv-errorBag.json

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

+ 43 - 15
src/python2/pjibot/csv-pjibot_guide.py

@@ -69,6 +69,7 @@ def parse_csv(costmap_bag, data_bag, parse_prefix, local_parse_dir, local_delete
         # ------- 上传 csv - 结束 -------
         
         # ------- 处理 output.json - 开始 -------
+        outputs = []
         try:
             # 1 解析 output.json
             output_json_path = str(local_csv_dir)+'/output.json'
@@ -95,25 +96,53 @@ def parse_csv(costmap_bag, data_bag, parse_prefix, local_parse_dir, local_delete
         
 
         # ------- 生成 pdf 报告 - 开始 -------
-        pdf_local_path = str(local_csv_dir) + '/report.pdf'
-        track_png_key = parse_prefix + 'track.png'
-        bucket.get_object_to_file(track_png_key, str(local_csv_dir) + '/track1.png')
-        os.chdir(path2)
-        command1 = './pji_single ' + str(local_csv_dir) + '/ ' + str(local_csv_dir) + '/ ' + str(local_csv_dir) + '/track1.png ' + data_bag.split('/')[-1].split('.')[0]
-        logging.info("调用生成pdf 报告命令: %s" % str(command1))
-        os.system(command1)
-        if os.path.exists(pdf_local_path):
-            bucket.put_object_from_file(parse_prefix + 'report.pdf',pdf_local_path)
-            local_delete_list.append(pdf_local_path)
-        else:
-            logging.error("没有 report.pdf")
-            json_utils.add_error(parse_prefix,error_bag_json)
+        if '自车数据缺失' not in outputs and '位姿信息缺失' not in outputs:
+            pdf_local_path = os.path.join(local_csv_dir, 'report.pdf')
+            track_png_key = parse_prefix + 'track.png'
+            bucket.get_object_to_file(track_png_key, os.path.join(local_csv_dir, 'track1.png'))
+            os.chdir(path2)
+
+            # 构建生成PDF报告的命令
+            data_bag_base = data_bag.split('/')[-1].split('.')[0]
+            command1 = ['./pji_single', local_csv_dir, local_csv_dir, os.path.join(local_csv_dir, 'track1.png'), data_bag_base]
+
+            # 打印调用生成PDF报告命令的日志
+            logging.info("调用生成pdf 报告命令: %s" % ' '.join(command1))
+
+            # 使用subprocess.call()执行命令(Python 2中没有直接的subprocess.run(),但可以用subprocess.call()或Popen())
+            try:
+                # subprocess.call()会等待命令完成并返回退出码,但不直接提供stdout和stderr的访问
+                # 如果需要捕获输出,我们需要使用Popen()
+                process = subprocess.Popen(command1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+                stdout, stderr = process.communicate()  # 等待进程完成并获取输出
+                exit_code = process.returncode
+
+                if exit_code == 0:
+                    # 命令成功执行
+                    logging.info("PDF报告生成成功,输出:\n%s" % stdout.decode('utf-8'))  # Python 2中字符串需要解码
+                else:
+                    # 命令执行失败
+                    logging.error("PDF报告生成失败,错误:\n%s" % stderr.decode('utf-8'))
+                    json_utils.add_error(parse_prefix, error_bag_json)
+            except Exception as e:
+                # 捕获其他可能的异常
+                logging.error("执行命令时发生异常: %s" % str(e))
+                json_utils.add_error(parse_prefix, error_bag_json)
+            else:
+                # 如果PDF文件存在
+                if os.path.exists(pdf_local_path):
+                    bucket.put_object_from_file(parse_prefix + 'report.pdf', pdf_local_path)
+                    local_delete_list.append(pdf_local_path)
+                else:
+                    # 如果不存在,记录错误日志
+                    logging.error("命令执行成功,但没有找到 report.pdf")
+                    json_utils.add_error(parse_prefix, error_bag_json)
         # ------- 生成 pdf 报告 - 结束 -------
         
 
         # ------- 根据 merged_obstacles 和 机器人指定的pgm文件 生成新的 merged_obstacles 文件 -------
         os.chdir(path3)
-        command2 = "python2 {} {} {}".format(path4, pgm_path, local_csv_file_path3)
+        command2 = "python3 {} {} {}".format(path4, pgm_path, local_csv_file_path3)
         logging.info("调用命令 merged_obstacles_new.csv 生成命令: %s", command2)
         process = subprocess.Popen(command2, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         stdout, stderr = process.communicate()  # 获取标准输出和错误输出
@@ -178,7 +207,6 @@ if __name__ == '__main__':
                     local_delete_list.append(local_merged_bag_path)
                     # 下载costmap.bag
                     costmap_key = merged_prefix.replace('data_merge', '') + 'costmap.bag'
-                    logging.info("costmap.bag包的key为: %s" % str(costmap_key))
                     bucket.get_object_to_file(costmap_key, local_merged_dir + 'costmap.bag')
                     # 2 生成 pos_orig.csv 和 pos_hmi.csv
                     parse_csv(local_merged_dir + 'costmap.bag', local_merged_bag_path, parse_prefix_full,local_parse_dir, local_delete_list)

+ 2 - 11
src/python2/pjibot/pcd-errorBag.json

@@ -1,15 +1,6 @@
 [
+    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-11-39-55/", 
     "pjibot/pjibot-P1YNYD1M227000116/data_parse/2024-11-07-16-39-17_obstacledetection_30/", 
     "pjibot/pjibot-P1YNYD1M229000131/data_parse/2024-11-11-02-40-36_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M229000131/data_parse/2024-11-11-02-45-56_obstacledetection_30/", 
-    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-11-39-55/", 
-    "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-30-25/", 
-    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-31-10/", 
-    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-32-26/", 
-    "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-43-02/", 
-    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-40-28/", 
-    "pjibot/pjibot-P1YNYD1M225000112/data_parse/TS100M36-BJ-dock-2024-09-29-15-45-29/", 
-    "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/"
 ]

+ 1 - 1
src/python2/pjibot/pcd-nohup.sh

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

+ 6 - 19
src/python2/pjibot/pcd-pjibot_guide.py

@@ -17,6 +17,8 @@ key1 = 'pjibot/'
 sleep_time = 30  # 每多少秒扫描一次
 
 error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjibot/pcd-errorBag.json"
+
+
 def parse_json_to_string_array(file_path):
     try:
         # 打开并读取JSON文件(Python 2中不支持encoding参数,需要使用codecs模块或处理文件读取后的编码)
@@ -60,11 +62,6 @@ def list_to_json_file(data, file_path):
 def parse_to_pcd_mp4(merged_bag_file_path, parse_prefix2, local_parse_dir, local_delete_list):
     global bucket
     try:
-        # local_pcd_mp4_dir1 = pcdtovideo_pji_deepcamera.parse1('/ob_camera_01/depth/points', merged_bag_file_path,
-        #                                                       local_parse_dir + '/depth1/')
-        # local_pcd_mp4_dir2 = pcdtovideo_pji_deepcamera.parse2('/ob_camera_02/depth/points', merged_bag_file_path,
-        #                                                       local_parse_dir + '/depth2/')
-
         os.chdir(path2)
         command1 = 'sh run.sh ' + merged_bag_file_path + ' ' + local_parse_dir
         logging.info("调用命令lidar视频生成命令: %s" % str(command1))
@@ -75,23 +72,13 @@ def parse_to_pcd_mp4(merged_bag_file_path, parse_prefix2, local_parse_dir, local
         parent_directory = os.path.dirname(merged_bag_file_path)
         local_pcd_mp4_dir3 = parent_directory.replace('data_merge',
                                                       'data_parse') + '/' + file_name_without_extension + '_pcd_lidar'
-        # local_pcd_mp4_dir3 = pcdtovideo_pji_lidar.parse(merged_bag_file_path, local_parse_dir + '/lidar/')
-
-        # pcd_mp4_file_name1 = 'pcd_depthcamera'
-        # pcd_mp4_file_name2 = 'pcd_depthcamera2'
         pcd_mp4_file_name3 = 'pcd_lidar'
-        # local_delete_list.append(local_pcd_mp4_dir1 + '/' + pcd_mp4_file_name1 + '.mp4')
-        # local_delete_list.append(local_pcd_mp4_dir2 + '/' + pcd_mp4_file_name2 + '.mp4')
-        local_delete_list.append(local_pcd_mp4_dir3 + '/output_video_converted.mp4')
-        # oss_csv_object_key1 = parse_prefix2 + pcd_mp4_file_name1 + '.mp4'
-        # oss_csv_object_key2 = parse_prefix2 + pcd_mp4_file_name2 + '.mp4'
+        local_pcd_mp4_path3 = local_pcd_mp4_dir3 + '/pcd_overlook.mp4'
         oss_csv_object_key3 = parse_prefix2 + pcd_mp4_file_name3 + '.mp4'
-        # bucket.put_object_from_file(oss_csv_object_key1, local_pcd_mp4_dir1 + '/' + pcd_mp4_file_name1 + '.mp4')
-        # logging.info("上传点云视频到: %s", oss_csv_object_key1)
-        # bucket.put_object_from_file(oss_csv_object_key2, local_pcd_mp4_dir2 + '/' + pcd_mp4_file_name2 + '.mp4')
-        # logging.info("上传点云视频到: %s", oss_csv_object_key2)
-        bucket.put_object_from_file(oss_csv_object_key3, local_pcd_mp4_dir3 + '/output_video_converted.mp4')
+        bucket.put_object_from_file(oss_csv_object_key3, local_pcd_mp4_path3)
         logging.info("上传点云视频到: %s", oss_csv_object_key3)
+        # ------- end -------
+        local_delete_list.append(local_pcd_mp4_path3)
     except Exception as e:
         error_bag_list = parse_json_to_string_array(error_bag_json)
         error_bag_list.append(parse_prefix2)

+ 167 - 175
src/python2/pjibot/resource/bagtocsv_robot.py

@@ -1,9 +1,9 @@
 # coding: utf-8
-#!/usr/bin/env python2
+# !/usr/bin/env python2
 import os
 import rosbag
 import csv
-import math 
+import math
 import rospy
 import sys
 import time
@@ -12,7 +12,8 @@ from datetime import datetime
 import argparse
 import pandas as pd
 import json
-#from nav_msgs.msg import OccupancyGrid
+
+# from nav_msgs.msg import OccupancyGrid
 
 
 global_height, global_costmap, global_origin, global_resolution = None, None, None, None
@@ -68,7 +69,7 @@ def process_local_rosbag(bagfile, local_topic):
         for topic, msg, t in bag.read_messages(topics=local_topic):
             local_messages.append((msg, t))
 
-        local_interval = total_time / len(local_messages)
+        local_interval = total_time / (len(local_messages) + 0.01)
 
         for index, (msg, t) in enumerate(local_messages):
             local_costmap = np.array(msg.data).reshape(msg.info.height, msg.info.width)
@@ -92,6 +93,7 @@ def process_local_rosbag(bagfile, local_topic):
 
     return df
 
+
 def merge_obstacles(df, global_height):
     df.sort_values(by=['frame_time', 'x', 'y'], inplace=True)
 
@@ -132,210 +134,195 @@ def merge_obstacles(df, global_height):
     return result_df
 
 
-
-
-def parsezihao(input_dir, output_dir):   
-    dic_EgoState = ['Time','simTime','simFrame','posX','posY','posZ','speedX','speedY','speedZ','accelX','accelY','accelZ',
-                            'dimX','dimY','dimZ','obstacle','traveledDist']
-    #dic_DriverCtrl=['Time','simTime','simFrame','tarspeedX','tarspeedY','tarspeedZ','tardimX','tardimY','tardimZ']
-    EgoState_file = open(output_dir + "/"+"EgoState_pji.csv", 'w')
-    #DriverCtrl_file = open(output_dir + "/"+"DriverCtrl_pji.csv", 'w')
-    writer_EgoState = csv.writer(EgoState_file)
-    writer_EgoState.writerow(dic_EgoState)
-    #writer_DriverCtrl = csv.writer(DriverCtrl_file)
-    #writer_DriverCtrl.writerow(dic_DriverCtrl)
-
-
-    frame_max=sys.maxsize
-    count=1
-    with rosbag.Bag(input_dir ,'r') as bag:
-        odom_flag=False
-        first_message_time = None
-        Frame_imu=1
-        Frame_cmd_vel=1
-        obstacle_state=0
-        cur_mileage=''
-        
-
-        for topic,msg,t in bag.read_messages(topics=['/obstacle_detection','sys_info','odom','imu']):    #t代表时间
-            
-            if first_message_time is None:  
-                first_message_time = t
-                first_message_time = rospy.Time.to_sec(first_message_time)
-                first_message_time = datetime.fromtimestamp(first_message_time)
-            
-            if topic == "/obstacle_detection":
-                obstacle_state=msg.data
-                #print(msg.data)
-                
-            if topic == "/sys_info":
-                cur_mileage=msg.cur_mileage
-          
-
-            if topic == "/odom": 
-                odom_flag=True 
-                posX=msg.pose.pose.position.x
-                posY=msg.pose.pose.position.y
-                posZ=msg.pose.pose.position.z
-                speedX=msg.twist.twist.linear.x*3.6
-                speedY=msg.twist.twist.linear.y*3.6
-                speedZ=msg.twist.twist.linear.z*3.6
-                dimX=msg.twist.twist.angular.x
-                dimY=msg.twist.twist.angular.y
-                dimZ=msg.twist.twist.angular.z
-                
-            if topic == "/imu":
-               
-                if odom_flag:
-                    accelX=msg.linear_acceleration.x
-                    accelY=msg.linear_acceleration.y
-                    accelZ=msg.linear_acceleration.z
-                    timestamp = rospy.Time.to_sec(t)
-                    date_time_imu = datetime.fromtimestamp(timestamp)
-                    simtime_imu=(date_time_imu-first_message_time).total_seconds()
-
-                    message_EgoState =[date_time_imu,simtime_imu,Frame_imu,posX,posY,posZ,speedX,speedY,speedZ,accelX,accelY,
-                              accelZ,dimX,dimY,dimZ,obstacle_state,cur_mileage]
-                 
-                    writer_EgoState.writerow(message_EgoState)
-                    Frame_imu+=1
-                else:
-                    print('6666')               
-            '''        
-            if topic =='/cmd_vel':
-                timestamp = rospy.Time.to_sec(t)
-                date_time_cmd_vel = datetime.fromtimestamp(timestamp)
-                simtime_cmd_vel=(date_time_cmd_vel-first_message_time).total_seconds()
-                message_DriverCtrl =[date_time_cmd_vel,simtime_cmd_vel,Frame_cmd_vel,msg.linear.x*3.6,msg.linear.y*3.6,msg.linear.z*3.6,
-                                     msg.angular.x,msg.angular.y,msg.angular.z]
-                
-                                     
-                writer_DriverCtrl.writerow(message_DriverCtrl)
-                Frame_cmd_vel+=1
-            '''           
-
-        EgoState_file.close()
-        #DriverCtrl_file.close()
-
-
-def parsehancheng(input_dir, output_dir):   
+def parsehancheng(input_dir, output_dir):
     def quaternion_to_euler(x, y, z, w):
         # 将四元数归一化
         try:
-            length = np.sqrt(x**2 + y**2 + z**2 + w**2)
+            length = np.sqrt(x ** 2 + y ** 2 + z ** 2 + w ** 2)
             x /= length
             y /= length
             z /= length
             w /= length
-        
+
             # 计算欧拉角
-            #roll = np.arctan2(2*(w*x + y*z), 1 - 2*(x**2 + y**2))
-            #pitch = np.arcsin(2*(w*y - z*x))
-            yaw = np.arctan2(2*(w*z + x*y), 1 - 2*(y**2 + z**2))  
-            return  yaw
-        except :
+            # roll = np.arctan2(2*(w*x + y*z), 1 - 2*(x**2 + y**2))
+            # pitch = np.arcsin(2*(w*y - z*x))
+            yaw = np.arctan2(2 * (w * z + x * y), 1 - 2 * (y ** 2 + z ** 2))
+            return yaw
+        except:
             return 0
 
-    json_path=os.path.join(output_dir,'output.json')
-    dic_object_detection = ['Time','FrameID','HeadingAngle','X', 'Y' ,'Z']
-    object_detection_file = open(output_dir + "/"+"pos_pji.csv", 'w')
+    json_path = os.path.join(output_dir, 'output.json')
+    dic_object_detection = ['Time', 'FrameID', 'HeadingAngle', 'X', 'Y', 'Z']
+    object_detection_file = open(output_dir + "/" + "pos_pji.csv", 'w')
     writer_object_detection = csv.writer(object_detection_file)
     writer_object_detection.writerow(dic_object_detection)
 
+    dic_EgoState = ['Time', 'simTime', 'simFrame', 'posX', 'posY', 'posZ', 'speedX', 'speedY', 'speedZ', 'accelX',
+                    'accelY', 'accelZ',
+                    'dimX', 'dimY', 'dimZ', 'obstacle', 'traveledDist']
+    # dic_DriverCtrl=['Time','simTime','simFrame','tarspeedX','tarspeedY','tarspeedZ','tardimX','tardimY','tardimZ']
+    EgoState_file = open(output_dir + "/" + "EgoState_pji.csv", 'w')
+    # DriverCtrl_file = open(output_dir + "/"+"DriverCtrl_pji.csv", 'w')
+    writer_EgoState = csv.writer(EgoState_file)
+    writer_EgoState.writerow(dic_EgoState)
+    # writer_DriverCtrl = csv.writer(DriverCtrl_file)
+    # writer_DriverCtrl.writerow(dic_DriverCtrl)
+
+    frame_max = sys.maxsize
+    count = 1
 
-    frame_max=sys.maxsize
-    with rosbag.Bag(input_dir ,'r') as bag:
-        poseX=poseY=0
-        #flag=False
+    frame_max = sys.maxsize
+    with rosbag.Bag(input_dir, 'r') as bag:
+        poseX = poseY = 0
+        # flag=False
         framenum = 1
-        #hasLoc = False
-        #用来判断机器人点云/图像/规划/定位是否丢帧↓↓↓
-        num_cam1=0
-        rate_cam1=10
-        
-        num_cam2=0
-        rate_cam2=10
-        
-        cam1_exist_flag=False
-        cam2_exist_flag=False
-        
-        #num_pcd=0
-        #rate_pcd=10
-        
+        # hasLoc = False
+        # 用来判断机器人点云/图像/规划/定位是否丢帧↓↓↓
+        num_cam1 = 0
+        rate_cam1 = 10
+
+        num_cam2 = 0
+        rate_cam2 = 10
+
+        cam1_exist_flag = False
+        cam2_exist_flag = False
+
+        # num_pcd=0
+        # rate_pcd=10
+
         bag_start_time = bag.get_start_time()
         bag_end_time = bag.get_end_time()
-        duration=bag_end_time-bag_start_time
-        
-        #Theoretical_pcd_num=int(duration*rate_pcd)
-        Theoretical_cam1_num=int(duration*rate_cam1)
-        Theoretical_cam2_num=int(duration*rate_cam2)
-
-        amcl_pose_lost_flag=True
-        
-        
-        #用来判断机器人点云/图像/规划/定位是否丢帧↑↑↑
-        for topic,msg,t in bag.read_messages(topics=['/amcl_pose','/scan_map_icp_amcl_node/scan_point_transformed','/ob_camera_01/color/image_raw','/ob_camera_02/color/image_raw']):    #t代表时间
+        duration = bag_end_time - bag_start_time
+
+        # Theoretical_pcd_num=int(duration*rate_pcd)
+        Theoretical_cam1_num = int(duration * rate_cam1)
+        Theoretical_cam2_num = int(duration * rate_cam2)
+
+        amcl_pose_lost_flag = True
+
+        odom_flag = False
+        first_message_time = None
+        Frame_imu = 1
+        Frame_cmd_vel = 1
+        obstacle_state = 0
+        cur_mileage = 0
+        imu_odom_flag = False
+
+        # 用来判断机器人点云/图像/规划/定位是否丢帧↑↑↑
+        for topic, msg, t in bag.read_messages(
+                topics=['/amcl_pose', '/scan_map_icp_amcl_node/scan_point_transformed', '/ob_camera_01/color/image_raw',
+                        '/ob_camera_02/color/image_raw', '/obstacle_detection', '/sys_info', '/odom', '/imu']):  # t代表时间
             '''
             if topic == "/scan_map_icp_amcl_node/scan_point_transformed":
                 num_pcd+=1
-            '''    
+            '''
             if topic == "/ob_camera_01/color/image_raw":
-                cam1_exist_flag=True
-                num_cam1+=1
-                
+                cam1_exist_flag = True
+                num_cam1 += 1
+
             if topic == "/ob_camera_01/color/image_raw":
-                cam2_exist_flag=True
-                num_cam2+=1
-        
-            if topic == "/amcl_pose":#100hz  /odom
-                
-                poseX=msg.pose.pose.position.x
-                poseY=msg.pose.pose.position.y
-                poseZ=msg.pose.pose.position.z
-                if poseX!=0 and poseY!=0:
-                    amcl_pose_lost_flag=False
-                orientationX=msg.pose.pose.orientation.x
-                orientationY=msg.pose.pose.orientation.y
-                orientationZ=msg.pose.pose.orientation.z
-                orientationW=msg.pose.pose.orientation.w
-                egoyaw=quaternion_to_euler(orientationX,orientationY,orientationZ,orientationW)
-                message_location =[str(t)[:-6],framenum,egoyaw,poseX,poseY,poseZ]
-                  
+                cam2_exist_flag = True
+                num_cam2 += 1
+
+            if topic == "/amcl_pose":  # 100hz  /odom
+
+                poseX = msg.pose.pose.position.x
+                poseY = msg.pose.pose.position.y
+                poseZ = msg.pose.pose.position.z
+                if poseX != 0 and poseY != 0:
+                    amcl_pose_lost_flag = False
+                orientationX = msg.pose.pose.orientation.x
+                orientationY = msg.pose.pose.orientation.y
+                orientationZ = msg.pose.pose.orientation.z
+                orientationW = msg.pose.pose.orientation.w
+                egoyaw = quaternion_to_euler(orientationX, orientationY, orientationZ, orientationW)
+                message_location = [str(t)[:-6], framenum, egoyaw, poseX, poseY, poseZ]
+
                 writer_object_detection.writerow(message_location)
-                framenum+=1
+                framenum += 1
+
+            if first_message_time is None:
+                first_message_time = t
+                first_message_time = rospy.Time.to_sec(first_message_time)
+                first_message_time = datetime.fromtimestamp(first_message_time)
+
+            if topic == "/obstacle_detection":
+                obstacle_state = msg.data
+                # print(msg.data)
+
+            if topic == "/sys_info":
+                cur_mileage = msg.cur_mileage
+
+            if topic == "/odom":
+                odom_flag = True
+                posX = msg.pose.pose.position.x
+                posY = msg.pose.pose.position.y
+                posZ = msg.pose.pose.position.z
+                speedX = msg.twist.twist.linear.x * 3.6
+                speedY = msg.twist.twist.linear.y * 3.6
+                speedZ = msg.twist.twist.linear.z * 3.6
+                dimX = msg.twist.twist.angular.x
+                dimY = msg.twist.twist.angular.y
+                dimZ = msg.twist.twist.angular.z
+
+            if topic == "/imu":
+
+                if odom_flag:
+                    # print(posX)
+                    accelX = msg.linear_acceleration.x
+                    accelY = msg.linear_acceleration.y
+                    accelZ = msg.linear_acceleration.z
+                    timestamp = rospy.Time.to_sec(t)
+                    date_time_imu = datetime.fromtimestamp(timestamp)
+                    simtime_imu = (date_time_imu - first_message_time).total_seconds()
+
+                    message_EgoState = [date_time_imu, simtime_imu, Frame_imu, posX, posY, posZ, speedX, speedY, speedZ,
+                                        accelX, accelY,
+                                        accelZ, dimX, dimY, dimZ, obstacle_state, cur_mileage]
+
+                    writer_EgoState.writerow(message_EgoState)
+                    imu_odom_flag = True
+                    Frame_imu += 1
+
         object_detection_file.close()
-        
+        EgoState_file.close()
+
         with open(json_path, "w") as file:
             data = []
             '''
             if (Theoretical_pcd_num - num_pcd) / Theoretical_pcd_num > 0.5:
                 data.append('点云丢帧')
             '''
-            if cam1_exist_flag==False and cam2_exist_flag==False:
+            if cam1_exist_flag == False and cam2_exist_flag == False:
                 data.append('图像缺失')
-            if cam1_exist_flag==True and cam2_exist_flag==True:
-                if ((Theoretical_cam1_num - num_cam1) / Theoretical_cam1_num > 0.5) or ((Theoretical_cam2_num - num_cam2) / Theoretical_cam2_num > 0.5):
+            if cam1_exist_flag == True and cam2_exist_flag == True:
+                if ((Theoretical_cam1_num - num_cam1) / Theoretical_cam1_num > 0.5) or (
+                        (Theoretical_cam2_num - num_cam2) / Theoretical_cam2_num > 0.5):
                     data.append('图像丢帧')
-            if amcl_pose_lost_flag :
+            if amcl_pose_lost_flag:
+                data.append('位姿信息缺失')
+            if not imu_odom_flag:
                 data.append('自车数据缺失')
-        
+
             if data == []:
                 data = ['正常']
-        
+
             # 将数据转换为 JSON 格式并写入文件
             json.dump(data, file, ensure_ascii=False)
 
+
 def parse(costmap_bag, data_bag, output_dir):
     global_bagfile = costmap_bag  # 全局地图的rosbag包
     # global_bagfile = '/media/dell/56FAD34BFAD32651/data/pujin_datareturn/20240428/costmap.bag'
     input_dir = data_bag  # 触发采集的rosbag包
-    #input_dir='/media/dell/56FAD34BFAD32651/data/pujin_datareturn/20240428/2024-04-25-15-58-27_obstacledetection_30.bag'
-    bagname=input_dir.split('/')[-1].split('.')[0]
-    #output_dir='/media/dell/56FAD34BFAD32651/data/pujin_datareturn/20240428'
+    # input_dir='/media/dell/56FAD34BFAD32651/data/pujin_datareturn/20240428/2024-04-25-15-58-27_obstacledetection_30.bag'
+    bagname = input_dir.split('/')[-1].split('.')[0]
+    # output_dir='/media/dell/56FAD34BFAD32651/data/pujin_datareturn/20240428'
     global_topic = '/move_base/global_costmap/costmap'
     local_topic = '/move_base/local_costmap/costmap'
-    
-    output_dir=os.path.join(output_dir, bagname)
+
+    output_dir = os.path.join(output_dir, bagname)
     if not os.path.exists(output_dir):
         os.makedirs(output_dir)
     '''
@@ -347,18 +334,23 @@ def parse(costmap_bag, data_bag, output_dir):
     print('successfully analysis '+input_dir)
     '''
 
-    try:
-        process_global_rosbag(global_bagfile, global_topic)
-        df = process_local_rosbag(input_dir, local_topic)
-        result_df = merge_obstacles(df, global_height)
-        result_df.to_csv(os.path.join(output_dir,'merged_obstacles.csv'), index=False)
-        parsehancheng(input_dir, output_dir)
-        parsezihao(input_dir, output_dir)
-        print('successfully analysis '+input_dir)
+    # try:
+    process_global_rosbag(global_bagfile, global_topic)
+    df = process_local_rosbag(input_dir, local_topic)
+    result_df = merge_obstacles(df, global_height)
+    result_df.to_csv(os.path.join(output_dir, 'merged_obstacles.csv'), index=False)
+    parsehancheng(input_dir, output_dir)
+
+    print('successfully analysis ' + input_dir)
+    '''
     except Exception as e:
         print(e)
         json_path=os.path.join(output_dir,'output.json')
         with open(json_path, "w") as file:
-                data = ['解析程序错误']
-                # 将数据转换为 JSON 格式并写入文件
-                json.dump(data, file, ensure_ascii=False)
+            data = ['解析程序错误']
+
+
+            # 将数据转换为 JSON 格式并写入文件
+            json.dump(data, file, ensure_ascii=False)
+
+    '''

+ 67 - 45
src/python2/pjibot/resource/parse_pji_image.py

@@ -14,18 +14,21 @@ import subprocess
 from subprocess import Popen, PIPE
 import numpy as np
 import shutil
+
 bridge = CvBridge()
-bag_start_time=0
-bag_end_time=0
+bag_start_time = 0
+bag_end_time = 0
+
 
 def parsebag(f, output_dir, target_topic):
     rosbag_name = f[f.rindex("/"):-4]
     output_path = output_dir + rosbag_name
 
-    with rosbag.Bag(f, 'r') as bag:  
+    with rosbag.Bag(f, 'r') as bag:
         global bag_start_time
         global bag_end_time
-        
+        bag_start_time = bag.get_start_time()
+        bag_end_time = bag.get_end_time()
         count = 0
         for key, val in bag.get_type_and_topic_info()[1].items():
             if val[0] == 'sensor_msgs/Image':
@@ -35,7 +38,7 @@ def parsebag(f, output_dir, target_topic):
                         img = bridge.imgmsg_to_cv2(msg, 'bgr8')
                         # img = bridge.compressed_imgmsg_to_cv2(msg, 'bgr8')
                         timestr = msg.header.stamp.to_nsec()
-                        image_name = str(timestr)[:10]+'.'+str(timestr)[10:] + ".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)
@@ -47,29 +50,30 @@ def parsebag(f, output_dir, target_topic):
 
 def parse1(topic, input_bag_file, output_mp4_dir):
     global bag_start_time
-    global bag_end_time 
+    global bag_end_time
     input_dir = input_bag_file
     output_dir = output_mp4_dir
     num_count = parsebag(input_dir, output_dir, topic)
-    #print("解析完成")
-    dirt = os.path.join(output_dir, input_dir.split('/')[-1].split('.')[0] + '_' + 'image')
+    # print("解析完成")
+    bagname = input_dir.split('/')[-1].split('.')[0]
+    dirt = os.path.join(output_dir, bagname + '_' + 'image')
     bagtime = int(input_dir.split('/')[-1].split('.')[0].split('_')[-1])
-    #hz = str(float(num_count / bagtime))
-    #print(hz)
+    # hz = str(float(num_count / bagtime))
+    # print(hz)
     list1 = os.listdir(dirt)
-    if list1!=[]:
-        #指定视频帧率
-        hz=10.0
-        
+    if list1 != []:
+        # 指定视频帧率
+        hz = 30.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')]
 
@@ -83,8 +87,9 @@ def parse1(topic, input_bag_file, output_mp4_dir):
         image_shape = first_image.shape
 
         # 创建视频写入对象
-        video_path=os.path.join(dirt,'camera1.mp4')
-        video_writer = cv2.VideoWriter(video_path, cv2.VideoWriter_fourcc('m', 'p', '4', 'v'), hz, (image_shape[1], image_shape[0]))
+        video_path = os.path.join(dirt, 'camera1.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):
@@ -93,55 +98,58 @@ def parse1(topic, input_bag_file, output_mp4_dir):
             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]) 
+            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)
+            # print(time_interval)
 
             # 根据实际时间间隔调整循环次数
             video_writer.write(current_image)
-            if int(time_interval * hz)>1.5:
-                for _ in range(int(time_interval * hz)):     
+            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(output_dir,'camera1.mp4')
+            video_output_path = os.path.join(output_dir, 'camera1.mp4')
             command = ["ffmpeg", "-i", video_path, "-c:v", "libx264", video_output_path]
             p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
             p.communicate()
             shutil.rmtree(folder_path)
+            # print("1 done")
+
+    return output_dir
 
-    return dirt
 
 def parse2(topic, input_bag_file, output_mp4_dir):
     global bag_start_time
-    global bag_end_time 
+    global bag_end_time
     input_dir = input_bag_file
     output_dir = output_mp4_dir
     num_count = parsebag(input_dir, output_dir, topic)
-    #print("解析完成")
-    dirt = os.path.join(output_dir, input_dir.split('/')[-1].split('.')[0] + '_' + 'image')
+    # print("解析完成")
+    bagname = input_dir.split('/')[-1].split('.')[0]
+    dirt = os.path.join(output_dir, bagname + '_' + 'image')
     bagtime = int(input_dir.split('/')[-1].split('.')[0].split('_')[-1])
-    #hz = str(float(num_count / bagtime))
-    #print(hz)
+    # hz = str(float(num_count / bagtime))
+    # print(hz)
     list1 = os.listdir(dirt)
-    if list1!=[]:
-        #指定视频帧率
-        hz=10.0
-        
+    if list1 != []:
+        # 指定视频帧率
+        hz = 30.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')]
 
@@ -155,8 +163,9 @@ def parse2(topic, input_bag_file, output_mp4_dir):
         image_shape = first_image.shape
 
         # 创建视频写入对象
-        video_path=os.path.join(dirt,'camera2.mp4')
-        video_writer = cv2.VideoWriter(video_path, cv2.VideoWriter_fourcc('m', 'p', '4', 'v'), hz, (image_shape[1], image_shape[0]))
+        video_path = os.path.join(dirt, 'camera2.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):
@@ -165,26 +174,39 @@ def parse2(topic, input_bag_file, output_mp4_dir):
             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]) 
+            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)
+            # print(time_interval)
 
             # 根据实际时间间隔调整循环次数
             video_writer.write(current_image)
-            if int(time_interval * hz)>1.5:
-                for _ in range(int(time_interval * hz)):     
+            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(output_dir,'camera2.mp4')
+            video_output_path = os.path.join(output_dir, 'camera2.mp4')
             command = ["ffmpeg", "-i", video_path, "-c:v", "libx264", video_output_path]
             p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
             p.communicate()
             shutil.rmtree(folder_path)
+            # print("1 done")
+
+    return output_dir
+
+
+'''
+if __name__ == "__main__":
+    topic1='/ob_camera_01/color/image_raw'
+    topic2='/ob_camera_02/color/image_raw'
+    input_bag_file='/home/dell/下载/2024-12-17-07-37-31_obstacledetection_55.bag'
+    output_mp4_dir='/home/dell/下载'
+    parse2(topic2, input_bag_file,output_mp4_dir )
+    #parse1(topic1, input_bag_file,output_mp4_dir )
+'''
 
-    return dirt

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

@@ -51,7 +51,6 @@ if __name__ == '__main__':
             for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
                 # 获取合并后的包
                 merged_bag_object_key = str(obj1.key)
-                # print(f'判断1{merged_bag_object_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])
@@ -88,7 +87,6 @@ if __name__ == '__main__':
                         os.remove(local_delete)
                     except Exception as e:
                         pass
-                        # logging.exception("捕获到一个异常: %s" % str(e))
             time.sleep(sleep_time)
         except Exception as e:
             logging.exception("全局错误处理: %s" % str(e))

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

@@ -301,5 +301,7 @@
     "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/充电桩有电 轮廓遮挡2024-09-29-15-30-25/", 
     "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/充电桩没电 轮廓遮挡2024-09-29-15-27-25/", 
     "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-29-15-34-00/", 
+    "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/2024-12-25-10-42-18_obstacledetection_3/", 
+    "pjibot_delivery/pjibot-P1YYPS1M227M00107/data_parse/2024-12-25-11-01-00_obstacledetection_14/"
 ]

+ 1 - 0
src/python2/pjibot_delivery/csv-pjibot_delivery.py

@@ -34,6 +34,7 @@ def parse_csv(data_bag, parse_prefix, local_parse_dir, local_delete_list):
         local_csv_dir = os.path.join(local_parse_dir + '/csv/', bagname)  # 最终生成四个csv文件和output.json的目录
 
         # ------- 处理 output.json - 开始 -------
+        outputs = []
         try:
             output_json_path = str(local_csv_dir)+'/output.json'
             if os.path.exists(output_json_path):

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

@@ -147,5 +147,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-25-09-26-48_obstacledetection_30/"
 ]

+ 4 - 1
src/python2/pjibot_patrol/pcd-errorBag.json

@@ -1,3 +1,6 @@
 [
-    "pjibot_patrol/pjibot-P1YVXJ1M231M00022/data_parse/2024-08-01-17-28-27_1038/"
+    "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/", 
+    "pjibot_patrol/pjibot-P1YVXJ1M231M00023/data_parse/VP100M23-BJ-movebase-2024-11-15-14-06-59/", 
+    "pjibot_patrol/pjibot-P1YVXJ1M231M00023/data_parse/VP100M23-BJ-movebase-2024-11-15-14-25-17/"
 ]

+ 2 - 0
src/python3/pjibot_indoor/filter_pos.py

@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
 import pandas as pd
 from PIL import Image
 import csv