package main import ( "cicv-data-closedloop/pjisuv_msgs" "fmt" "math" "sync" "time" ) var ( ObjDicOfTpperception any objDic = make(map[uint32][][]float32) ok1 bool StartTime int64 IsFollow bool ) func Topic() string { return "/tpperception" } // 禁止存在下划线_ func Label() string { return "CBLA" } func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string { defer func() { if r := recover(); r != nil { fmt.Println("Recovered from panic:", r) } }() ObjDicOfTpperception, ok1 = shareVars.Load("ObjDicOfTpperception") if !ok1 { return "" } objDic = ObjDicOfTpperception.(map[uint32][][]float32) for objid, objval := range objDic { //if obj.Type == 1 && obj.X >= 2 && obj.X <= 20 && math.Abs(float64(obj.Y)) <= 1.2 {//理论条件 if objval[objid][6] == 4 && objval[objid][0] >= 2 && objval[objid][0] <= 20 && math.Abs(float64(objval[objid][1])) <= 1.2 { //简化条件 if StartTime == 0 { StartTime = time.Now().Unix() } // 判断是否持续超过一分钟 if time.Now().Unix()-StartTime > 5 { if !IsFollow { IsFollow = true return Label() } } } else { StartTime = 0 IsFollow = false } } return "" }