Explorar o código

Merge remote-tracking branch 'origin/master'

Yishi Wang hai 9 meses
pai
achega
c7ff7ba67d

+ 2 - 1
aarch64/pjisuv/master/service/produce_window.go

@@ -601,7 +601,8 @@ func ProduceWindow() {
 						}
 						subscribersTimeMutexes[i].Unlock()
 						// 更新共享变量
-						AccelXSlice = append(AccelXSlice, data.AccelX)
+						AbsAccel := math.Sqrt(math.Pow(data.AccelX, 2) + math.Pow(data.AccelY, 2))
+						AccelXSlice = append(AccelXSlice, AbsAccel)
 						shareVars.Store("AccelXSlice", AccelXSlice)
 						shareVars.Store("VelocityXOfCicvLocation", data.VelocityX)
 						shareVars.Store("VelocityYOfCicvLocation", data.VelocityY)

+ 1 - 1
trigger/pjisuv/cicv_location/CurveOverspeed/main/CurveOverspeed.go

@@ -13,7 +13,7 @@ type Point struct {
 }
 
 var (
-	threshold  float64 = 3
+	threshold  float64 = 10
 	IsCurve    bool
 	count1     int64
 	pointcurve = Point{39.73004426154644, 116.49248639463602}

+ 92 - 0
trigger/pjisuv/cicv_location/JunctionOverspeed/main/JunctionOverspeed.go

@@ -0,0 +1,92 @@
+package main
+
+import (
+	"cicv-data-closedloop/pjisuv_msgs"
+	"fmt"
+	"math"
+	"sync"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	threshold float64 = 10
+	IsCurve   bool
+	count1    int64
+	//定义园区T字路口的经纬度坐标值
+	point3 = Point{39.73040966605621, 116.48995329696209}
+	point4 = Point{39.73083727413453, 116.49079780188244}
+	point5 = Point{39.72976753711939, 116.49043130389033}
+	point6 = Point{39.73012466515933, 116.49128381717591}
+	point7 = Point{39.729251498328246, 116.49077484625299}
+	point8 = Point{39.72964529630643, 116.49164592200161}
+
+	pointlist = []Point{point3, point4, point5, point6, point7, point8}
+)
+
+func Topic() string {
+	return "/cicv_location"
+}
+
+// 禁止存在下划线_
+func Label() string {
+	return "JunctionOverspeed"
+}
+
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+
+func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string {
+	defer func() {
+		if r := recover(); r != nil {
+			fmt.Println("Recovered from panic:", r)
+		}
+	}()
+	if count1%10 == 0 {
+		Automode, _ := shareVars.Load("AutomodeOfPjVehicleFdbPub")
+		Automode = Automode.(int16)
+		IsCurve = IfEnter(pointlist, 16.0, data.Latitude, data.Longitude)
+
+		if Automode == 1 && IsCurve {
+			absspeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+			if absspeed >= threshold {
+				eventLabel := "JunctionOverspeed"
+				fmt.Println(eventLabel)
+				count1 = 1
+				return Label()
+			}
+		}
+	}
+	count1++
+	return ""
+}

+ 5 - 4
trigger/pjisuv/cicv_ticker/Cadence/main/Cadence.go

@@ -32,7 +32,7 @@ func Rule(shareVars *sync.Map) {
 	// 1 使用goroutine
 	go func(shareVars *sync.Map) {
 		// 2 定义触发器的间隔时间
-		ticker := time.NewTicker(time.Duration(6) * time.Second)
+		ticker := time.NewTicker(time.Duration(2) * time.Second)
 		defer ticker.Stop()
 		// 3 运行一个无限循环
 		for {
@@ -77,9 +77,10 @@ func FinalCallback(shareVars *sync.Map) {
 			fmt.Println(event_lable)
 			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
 		}
-
-		AccelXSlice = []float64{}
-		shareVars.Store("AccelXSlice", AccelXSlice)
+		if len(AccelXSlice.([]float64)) >= 500 {
+			AccelXSlice = []float64{}
+			shareVars.Store("AccelXSlice", AccelXSlice)
+		}
 
 	}
 

+ 10 - 3
trigger/pjisuv/cicv_ticker/FrontVehicleBrake/main/FrontVehicleBrake.go

@@ -8,6 +8,10 @@ import (
 	"time"
 )
 
+var (
+	Maxlenobj int32 = 0
+)
+
 // 定时任务触发器固定的
 func Topic() string {
 	return pjisuv_ticker.TickerTopic
@@ -62,6 +66,7 @@ func FinalCallback(shareVars *sync.Map) {
 
 	if ok && ok1 && OutsideWorkshopFlag.(bool) == true {
 		for _, objValue := range ObjDic {
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
 			if len(ObjDic[0]) <= 10 || !isBrake(objValue) {
 				continue
 			}
@@ -69,9 +74,11 @@ func FinalCallback(shareVars *sync.Map) {
 			fmt.Println(event_lable)
 			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
 		}
-
-		ObjDicOfTpperception = make(map[uint32][][]float32)
-		shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+		if Maxlenobj >= 100 {
+			ObjDicOfTpperception = make(map[uint32][][]float32)
+			shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+			Maxlenobj = 0
+		}
 	}
 
 }

+ 10 - 2
trigger/pjisuv/cicv_ticker/FrontVehicleCutInFar/main/FrontVehicleCutInFar.go

@@ -8,6 +8,10 @@ import (
 	"time"
 )
 
+var (
+	Maxlenobj int32 = 0
+)
+
 // 定时任务触发器固定的
 func Topic() string {
 	return pjisuv_ticker.TickerTopic
@@ -67,6 +71,7 @@ func FinalCallback(shareVars *sync.Map) {
 
 	if ok && ok1 && OutsideWorkshopFlag.(bool) == true {
 		for _, objValue := range ObjDic {
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
 			if len(ObjDic[0]) <= 10 || !isCuttingIn(objValue, AngularVelocityZ) {
 				continue
 			}
@@ -75,8 +80,11 @@ func FinalCallback(shareVars *sync.Map) {
 			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
 		}
 
-		ObjDicOfTpperception = make(map[uint32][][]float32)
-		shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+		if Maxlenobj >= 100 {
+			ObjDicOfTpperception = make(map[uint32][][]float32)
+			shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+			Maxlenobj = 0
+		}
 	}
 
 }

+ 11 - 2
trigger/pjisuv/cicv_ticker/FrontVehicleCutInNear/main/FrontVehicleCutInNear.go

@@ -8,6 +8,10 @@ import (
 	"time"
 )
 
+var (
+	Maxlenobj int32 = 0
+)
+
 // 定时任务触发器固定的
 func Topic() string {
 	return pjisuv_ticker.TickerTopic
@@ -66,7 +70,9 @@ func FinalCallback(shareVars *sync.Map) {
 	AngularVelocityZ := AngularVelocityZOfCicvLocation.(float64)
 
 	if ok && ok1 && OutsideWorkshopFlag.(bool) == true {
+
 		for _, objValue := range ObjDic {
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
 			if len(ObjDic[0]) <= 4 || !isCuttingIn(objValue, AngularVelocityZ) {
 				continue
 			}
@@ -75,8 +81,11 @@ func FinalCallback(shareVars *sync.Map) {
 			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
 		}
 
-		ObjDicOfTpperception = make(map[uint32][][]float32)
-		shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+		if Maxlenobj >= 100 {
+			ObjDicOfTpperception = make(map[uint32][][]float32)
+			shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+			Maxlenobj = 0
+		}
 	}
 
 }

+ 10 - 2
trigger/pjisuv/cicv_ticker/FrontVehicleCutOutFar/main/FrontVehicleCutOutFar.go

@@ -8,6 +8,10 @@ import (
 	"time"
 )
 
+var (
+	Maxlenobj int32 = 0
+)
+
 // 定时任务触发器固定的
 func Topic() string {
 	return pjisuv_ticker.TickerTopic
@@ -67,6 +71,7 @@ func FinalCallback(shareVars *sync.Map) {
 
 	if ok && ok1 && OutsideWorkshopFlag.(bool) == true {
 		for _, objValue := range ObjDic {
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
 			if len(ObjDic[0]) <= 10 || !isCuttingIn(objValue, AngularVelocityZ) {
 				continue
 			}
@@ -76,8 +81,11 @@ func FinalCallback(shareVars *sync.Map) {
 			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
 		}
 
-		ObjDicOfTpperception = make(map[uint32][][]float32)
-		shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+		if Maxlenobj >= 100 {
+			ObjDicOfTpperception = make(map[uint32][][]float32)
+			shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+			Maxlenobj = 0
+		}
 	}
 
 }

+ 10 - 2
trigger/pjisuv/cicv_ticker/FrontVehicleCutOutNear/main/FrontVehicleCutOutNear.go

@@ -8,6 +8,10 @@ import (
 	"time"
 )
 
+var (
+	Maxlenobj int32 = 0
+)
+
 // 定时任务触发器固定的
 func Topic() string {
 	return pjisuv_ticker.TickerTopic
@@ -67,6 +71,7 @@ func FinalCallback(shareVars *sync.Map) {
 
 	if ok && ok1 && OutsideWorkshopFlag.(bool) == true {
 		for _, objValue := range ObjDic {
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
 			if len(ObjDic[0]) <= 10 || !isCuttingIn(objValue, AngularVelocityZ) {
 				continue
 			}
@@ -75,8 +80,11 @@ func FinalCallback(shareVars *sync.Map) {
 			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
 		}
 
-		ObjDicOfTpperception = make(map[uint32][][]float32)
-		shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+		if Maxlenobj >= 100 {
+			ObjDicOfTpperception = make(map[uint32][][]float32)
+			shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+			Maxlenobj = 0
+		}
 	}
 
 }

+ 5 - 4
trigger/pjisuv/cicv_ticker/HuaLong/main/HuaLong.go

@@ -32,7 +32,7 @@ func Rule(shareVars *sync.Map) {
 	// 1 使用goroutine
 	go func(shareVars *sync.Map) {
 		// 2 定义触发器的间隔时间
-		ticker := time.NewTicker(time.Duration(6) * time.Second)
+		ticker := time.NewTicker(time.Duration(2) * time.Second)
 		defer ticker.Stop()
 		// 3 运行一个无限循环
 		for {
@@ -77,9 +77,10 @@ func FinalCallback(shareVars *sync.Map) {
 			fmt.Println(event_lable)
 			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
 		}
-
-		egoSteeringRealOfDataRead = []float64{}
-		shareVars.Store("egoSteeringRealOfDataRead", egoSteeringRealOfDataRead)
+		if len(egoSteeringRealOfDataRead.([]float64)) >= 600 {
+			egoSteeringRealOfDataRead = []float64{}
+			shareVars.Store("egoSteeringRealOfDataRead", egoSteeringRealOfDataRead)
+		}
 
 	}
 

+ 10 - 2
trigger/pjisuv/cicv_ticker/RearVehicleApproach/main/RearVehicleApproach.go

@@ -8,6 +8,10 @@ import (
 	"time"
 )
 
+var (
+	Maxlenobj int32 = 0
+)
+
 // 定时任务触发器固定的
 func Topic() string {
 	return pjisuv_ticker.TickerTopic
@@ -61,6 +65,7 @@ func FinalCallback(shareVars *sync.Map) {
 
 	if ok && ok1 && OutsideWorkshopFlag.(bool) == true {
 		for _, objValue := range ObjDic {
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
 			if len(ObjDic[0]) <= 10 || !isApproach(objValue) {
 				continue
 			}
@@ -69,8 +74,11 @@ func FinalCallback(shareVars *sync.Map) {
 			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
 		}
 
-		ObjDicOfTpperception = make(map[uint32][][]float32)
-		shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+		if Maxlenobj >= 100 {
+			ObjDicOfTpperception = make(map[uint32][][]float32)
+			shareVars.Store("ObjDicOfTpperception", ObjDicOfTpperception)
+			Maxlenobj = 0
+		}
 	}
 
 }