LingxinMeng hai 9 meses
pai
achega
3a52b9c751

+ 4 - 4
aarch64/pjibot_delivery/common/config/c_platform.go

@@ -38,7 +38,7 @@ type response struct {
 
 var (
 	PlatformConfig PlatformConfigStruct
-	CollectTopics  []string
+	RecordTopics   []string
 )
 
 // InitPlatformConfig 初始化数据闭环平台的配置
@@ -55,10 +55,10 @@ func InitPlatformConfig() {
 			continue
 		}
 		if checkPlatformConfig() {
-			CollectTopics = strings.Split(PlatformConfig.EquipmentTopic, ",")
+			RecordTopics = strings.Split(PlatformConfig.EquipmentTopic, ",")
 			// 去掉首尾空格
-			for i, topic := range CollectTopics {
-				CollectTopics[i] = strings.TrimSpace(topic)
+			for i, topic := range RecordTopics {
+				RecordTopics[i] = strings.TrimSpace(topic)
 			}
 			break
 		}

+ 7 - 2
aarch64/pjibot_delivery/common/service/rosbag_record.go

@@ -29,8 +29,13 @@ func BagRecord(nodeName string) {
 		command = append(command, "--duration=1")
 		for _, host := range config.CloudConfig.Hosts {
 			if host.Name == nodeName {
-				for _, topic := range host.Topics {
-					command = append(command, topic)
+				// 配置文件中的是node1和node2各自的所有topic,platformConfig中配置用户想缓存的topic,取交集
+				for _, topic1 := range config.RecordTopics {
+					for _, topic2 := range host.Topics {
+						if topic1 == topic2 {
+							command = append(command, topic1)
+						}
+					}
 				}
 			}
 		}

+ 4 - 4
aarch64/pjibot_guide/common/config/c_platform.go

@@ -38,7 +38,7 @@ type response struct {
 
 var (
 	PlatformConfig PlatformConfigStruct
-	CollectTopics  []string
+	RecordTopics   []string
 )
 
 // InitPlatformConfig 初始化数据闭环平台的配置
@@ -55,10 +55,10 @@ func InitPlatformConfig() {
 			continue
 		}
 		if checkPlatformConfig() {
-			CollectTopics = strings.Split(PlatformConfig.EquipmentTopic, ",")
+			RecordTopics = strings.Split(PlatformConfig.EquipmentTopic, ",")
 			// 去掉首尾空格
-			for i, topic := range CollectTopics {
-				CollectTopics[i] = strings.TrimSpace(topic)
+			for i, topic := range RecordTopics {
+				RecordTopics[i] = strings.TrimSpace(topic)
 			}
 			break
 		}

+ 7 - 2
aarch64/pjibot_guide/common/service/rosbag_record.go

@@ -29,8 +29,13 @@ func BagRecord(nodeName string) {
 		command = append(command, "--duration=1")
 		for _, host := range config.CloudConfig.Hosts {
 			if host.Name == nodeName {
-				for _, topic := range host.Topics {
-					command = append(command, topic)
+				// 配置文件中的是node1和node2各自的所有topic,platformConfig中配置用户想缓存的topic,取交集
+				for _, topic1 := range config.RecordTopics {
+					for _, topic2 := range host.Topics {
+						if topic1 == topic2 {
+							command = append(command, topic1)
+						}
+					}
 				}
 			}
 		}

+ 4 - 4
aarch64/pjibot_patrol/common/config/c_platform.go

@@ -38,7 +38,7 @@ type response struct {
 
 var (
 	PlatformConfig PlatformConfigStruct
-	CollectTopics  []string
+	RecordTopics   []string
 )
 
 // 初始化数据闭环平台的配置
@@ -55,10 +55,10 @@ func InitPlatformConfig() {
 			continue
 		}
 		if checkPlatformConfig() {
-			CollectTopics = strings.Split(PlatformConfig.EquipmentTopic, ",")
+			RecordTopics = strings.Split(PlatformConfig.EquipmentTopic, ",")
 			// 去掉首尾空格
-			for i, topic := range CollectTopics {
-				CollectTopics[i] = strings.TrimSpace(topic)
+			for i, topic := range RecordTopics {
+				RecordTopics[i] = strings.TrimSpace(topic)
 			}
 			break
 		}

+ 7 - 2
aarch64/pjibot_patrol/common/service/rosbag_record.go

@@ -29,8 +29,13 @@ func BagRecord(nodeName string) {
 		command = append(command, "--duration=1")
 		for _, host := range config.CloudConfig.Hosts {
 			if host.Name == nodeName {
-				for _, topic := range host.Topics {
-					command = append(command, topic)
+				// 配置文件中的是node1和node2各自的所有topic,platformConfig中配置用户想缓存的topic,取交集
+				for _, topic1 := range config.RecordTopics {
+					for _, topic2 := range host.Topics {
+						if topic1 == topic2 {
+							command = append(command, topic1)
+						}
+					}
 				}
 			}
 		}

+ 4 - 4
aarch64/pjisuv/common/config/c_platform.go

@@ -38,7 +38,7 @@ type response struct {
 
 var (
 	PlatformConfig PlatformConfigStruct
-	CollectTopics  []string
+	RecordTopics   []string
 )
 
 // 初始化数据闭环平台的配置
@@ -54,10 +54,10 @@ func InitPlatformConfig() {
 			continue
 		}
 		if checkPlatformConfig() {
-			CollectTopics = strings.Split(PlatformConfig.EquipmentTopic, ",")
+			RecordTopics = strings.Split(PlatformConfig.EquipmentTopic, ",")
 			// 去掉首尾空格
-			for i, topic := range CollectTopics {
-				CollectTopics[i] = strings.TrimSpace(topic)
+			for i, topic := range RecordTopics {
+				RecordTopics[i] = strings.TrimSpace(topic)
 			}
 			break
 		}

+ 10 - 5
aarch64/pjisuv/common/service/rosbag_record.go

@@ -10,15 +10,15 @@ import (
 
 // BagRecord 打包rosbag
 func BagRecord(nodeName string) {
-	c_log.GlobalLogger.Info("rosbag record goroutine - 启动")
+	c_log.GlobalLogger.Info("rosbag record goroutine - 启动")
 	for {
-		c_log.GlobalLogger.Info("校验必需的 rosnode 是否全部启动。")
+		c_log.GlobalLogger.Info("校验必需的 ROS NODE 是否全部启动。")
 		canRecord := false
 		for !canRecord {
 			time.Sleep(time.Duration(2) * time.Second)
 			canRecord = isCanRecord(config.RosNode)
 		}
-		c_log.GlobalLogger.Info("rosnode启动完成,正在启动record命令。")
+		c_log.GlobalLogger.Info("ROS NODE 启动完成,正在启动record命令。")
 
 		var command []string
 		command = append(command, "record")
@@ -26,8 +26,13 @@ func BagRecord(nodeName string) {
 		command = append(command, "--duration=1")
 		for _, host := range config.CloudConfig.Hosts {
 			if host.Name == nodeName {
-				for _, topic := range host.Topics {
-					command = append(command, topic)
+				// 配置文件中的是node1和node2各自的所有topic,platformConfig中配置用户想缓存的topic,取交集
+				for _, topic1 := range config.RecordTopics {
+					for _, topic2 := range host.Topics {
+						if topic1 == topic2 {
+							command = append(command, topic1)
+						}
+					}
 				}
 			}
 		}

+ 32 - 5
aarch64/pjisuv/common/service/rosbag_upload.go

@@ -46,13 +46,40 @@ outLoop:
 		entity.RemoveHeadOfTimeWindowConsumerQueue()
 		c_log.GlobalLogger.Infof("开始处理窗口,【Lable】=%v,【FaultTime】=%v,【Length】=%v", currentTimeWindow.Labels, currentTimeWindow.FaultTime, currentTimeWindow.Length)
 
-		// 2 获取目录
+		// 2 获取目录和bags
 		dir := domain.GetCopyDir(commonConfig.CloudConfig.BagCopyDir, currentTimeWindow.FaultTime)
 		//bags, _ := commonUtil.ListAbsolutePathWithSuffixAndSort(dir, ".bag")
-		//bagNumber := len(bags)
-		//if bagNumber > currentTimeWindow.Length {
-		//	bagNumber = currentTimeWindow.Length
-		//	bags = bags[0:currentTimeWindow.Length]
+		// 3 如果不是全量采集,则使用 filter 命令对 bag 包进行主题过滤。
+		// todo  需要采集回传的话题是根据触发器设置的,触发器设置了之后进行过滤
+		//if commonConfig.CloudConfig.FullCollect == false {
+		//	filterTopics := commonConfig.CollectTopics
+		//	if nodeName == commonConfig.CloudConfig.Hosts[0].Name {
+		//		filterTopics = currentTimeWindow.MasterTopics
+		//	} else {
+		//		filterTopics = currentTimeWindow.SlaveTopics
+		//	}
+		//	var topicsFilterSlice []string
+		//	for _, topic := range filterTopics {
+		//		topicsFilterSlice = append(topicsFilterSlice, "topic=='"+topic+"'")
+		//	}
+		//	for i, bag := range bags {
+		//		oldName := bag
+		//		newName := bag + "_filter"
+		//		filterCommand := []string{"filter", oldName, newName, "\"" + strings.Join(topicsFilterSlice, " or ") + "\""}
+		//		_, output, err := commonUtil.ExecuteWithEnvSync(commonConfig.RosbagEnvs, commonConfig.RosbagPath, filterCommand...)
+		//		c_log.GlobalLogger.Info("正在过滤中,【FaultTime】=", currentTimeWindow.FaultTime, "【Label】=", currentTimeWindow.Labels, ",进度", i+1, "/", bagNumber, "。")
+		//		if err != nil {
+		//			c_log.GlobalLogger.Errorf("filter 命令执行出错【命令】=%v,【输出】=%v,【err】=%v", filterCommand, output, err)
+		//			continue
+		//		}
+		//		// 删除旧文件
+		//		_ = commonUtil.DeleteFile(oldName)
+		//		// 将新文件改回旧文件名
+		//		if err = os.Rename(newName, oldName); err != nil {
+		//			c_log.GlobalLogger.Info("修改文件名", oldName, "失败,放弃当前时间窗口", currentTimeWindow.FaultTime, ",错误为:", err)
+		//			continue outLoop
+		//		}
+		//	}
 		//}
 		//
 		//if commonConfig.CloudConfig.CompressBag  {