LingxinMeng il y a 11 mois
Parent
commit
535511bc75

+ 12 - 1
aarch64/kinglong/master/package/service/produce_window.go

@@ -93,7 +93,7 @@ func PrepareTimeWindowProducerQueue() {
 				Node:  commonConfig.RosNode,
 				Topic: topic,
 				Callback: func(data *kinglong_msgs.PerceptionObjects) {
-					// 更新共享变量
+					// ------- 触发前更新共享变量
 					mutexOfTpperception.RLock()
 					{
 						for _, obj := range data.Objs {
@@ -124,6 +124,17 @@ func PrepareTimeWindowProducerQueue() {
 						subscribersMutexes[i].Unlock()
 					}
 					subscribersTimeMutexes[i].Unlock()
+
+					// -------- 触发后更新共享变量
+					mutexOfTpperception.RLock()
+					{
+						for _, obj := range data.Objs {
+							extendParam.ObjTypeDicOfTpperception[obj.Id] = obj.Type
+							extendParam.ObjSpeedDicOfTpperception[obj.Id] = math.Pow(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2), 0.5)
+						}
+					}
+					mutexOfTpperception.RUnlock()
+
 				},
 			})
 		}

+ 9 - 0
aarch64/pjisuv/master/service/produce_window.go

@@ -909,6 +909,15 @@ func PrepareTimeWindowProducerQueue() {
 						subscribersMutexes[i].Unlock()
 					}
 					subscribersTimeMutexes[i].Unlock()
+					// -------- 触发后更新共享变量
+					mutexOfTpperception.RLock()
+					{
+						for _, obj := range data.Objs {
+							pjisuvParam.ObjTypeDicOfTpperception[obj.Id] = obj.Type
+							pjisuvParam.ObjSpeedDicOfTpperception[obj.Id] = math.Pow(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2), 0.5)
+						}
+					}
+					mutexOfTpperception.RUnlock()
 				},
 			})
 		}

+ 6 - 2
common/entity/extend_param.go

@@ -11,7 +11,9 @@ type PjisuvParam struct {
 	PositionYOfCicvLocation        float64
 
 	// /tpperception
-	ObjDicOfTpperception map[uint32][]float32
+	ObjDicOfTpperception      map[uint32][]float32
+	ObjTypeDicOfTpperception  map[uint32]uint8
+	ObjSpeedDicOfTpperception map[uint32]float64
 
 	// /pji_control_pub
 	NumCountPjiControlCommandOfPjControlPub int
@@ -34,7 +36,9 @@ type KinglongParam struct {
 	AngularVelocityZOfCicvLocation float64
 
 	// /tpperception
-	ObjDicOfTpperception map[uint32][]float32
+	ObjDicOfTpperception      map[uint32][]float32
+	ObjTypeDicOfTpperception  map[uint32]uint8
+	ObjSpeedDicOfTpperception map[uint32]float64
 
 	// /pji_control_pub
 	NumCountJinlongControlCommandOfPjControlPub int

+ 39 - 0
trigger/pjisuv/tpperception/perceptiontypediffer/main/perceptiontypediffer.go

@@ -0,0 +1,39 @@
+package main
+
+import (
+	"cicv-data-closedloop/common/entity"
+	"cicv-data-closedloop/pjisuv_msgs"
+)
+
+/*
+   if obj_type_dic is not {}: #相邻两帧对于同一目标物感知类型不一致
+       if obj.id in obj_type_dic:
+           if obj.type != obj_type_dic[obj.id]:
+               event_label='perceptiontypediffer'
+
+               print(event_label)
+           else:
+               print(obj.type,"   ",obj_type_dic[obj.id])
+*/
+
+func Topic() string {
+	return "/tpperception"
+}
+
+// Label todo 禁止存在下划线_
+func Label() string {
+	return "TTC"
+}
+
+func Rule(data *pjisuv_msgs.PerceptionObjects, param entity.PjisuvParam) string {
+	for _, obj := range data.Objs {
+		if len(param.ObjTypeDicOfTpperception) != 0 {
+			for _, lastObjType := range param.ObjTypeDicOfTpperception {
+				if lastObjType != obj.Type {
+					return "perceptiontypediffer"
+				}
+			}
+		}
+	}
+	return ""
+}