Эх сурвалжийг харах

modify AbnormalParking trigger

zwh 10 сар өмнө
parent
commit
9bc6eecf3a

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

@@ -544,6 +544,7 @@ func ProduceWindow() {
 								currentCurvateres = append(currentCurvateres, math.Abs(float64(point.Curvature)))
 							}
 							pjisuvParam.LastCurvaturesOfCicvAmrTrajectory = currentCurvateres
+							pjisuvParam.DecisionType = data.Trajectoryinfo.DecisionType
 						}
 						mutexOfCicvAmrTrajectory.RUnlock()
 					},
@@ -913,6 +914,7 @@ func ProduceWindow() {
 
 			// 20
 			if topic == masterConfig.TopicOfMapPolygon && (len(masterConfig.RuleOfMapPolygon1) > 0 || len(masterConfig.RuleOfMapPolygon2) > 0) {
+
 				subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
 					Node:  commonConfig.RosNode,
 					Topic: topic,

+ 2 - 0
pjisuv_param/pjisuv_param.go

@@ -1,6 +1,7 @@
 package pjisuv_param
 
 type PjisuvParam struct {
+	WhetherOnfRoad bool
 	// /cicv_location
 	VelocityXOfCicvLocation        float64
 	VelocityYOfCicvLocation        float64
@@ -29,4 +30,5 @@ type PjisuvParam struct {
 
 	// /cicv_amr_trajectory
 	LastCurvaturesOfCicvAmrTrajectory []float64
+	DecisionType                      int8
 }

+ 55 - 0
trigger/pjisuv/cicv_location/AbnormalParking/main/AbnormalParking.go

@@ -0,0 +1,55 @@
+package main
+
+import (
+	"cicv-data-closedloop/pjisuv_msgs"
+	"cicv-data-closedloop/pjisuv_param"
+	"fmt"
+	"time"
+)
+
+var (
+	StartTime int64
+	IsStopped bool
+)
+
+func Topic() string {
+	return "/cicv_location"
+}
+
+// Label todo 禁止存在下划线_
+func Label() string {
+	return "AbnormalParking"
+}
+
+func Rule(data *pjisuv_msgs.PerceptionLocalization, param *pjisuv_param.PjisuvParam) string {
+	defer func() {
+		if r := recover(); r != nil {
+			fmt.Println("Recovered from panic:", r)
+		}
+	}()
+	if param.AutomodeOfPjVehicleFdbPub == 1 && param.DecisionType != 4 {
+		if data.VelocityX < 0.5 {
+			// 如果之前没有记录开始时间,记录当前时间
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+			// 判断是否持续超过 50s
+			if time.Now().Unix()-StartTime > 5 {
+				if !IsStopped {
+					eventLabel := "AbnormalParking"
+					fmt.Println(eventLabel)
+					IsStopped = true
+					return "AbnormalParking"
+				}
+			}
+		} else {
+			// 如果速度大于 0.1,重置开始时间和停止标志
+			StartTime = 0
+			IsStopped = false
+		}
+	} else {
+		StartTime = 0
+		IsStopped = false
+	}
+	return ""
+}

+ 1 - 0
trigger/pjisuv/map_polygon/OutOfLane/main/OutOfLane.go

@@ -80,5 +80,6 @@ func Rule(data *pjisuv_msgs.PolygonStamped, param *pjisuv_param.PjisuvParam) str
 			return "OutOfLane"
 		}
 	}
+
 	return ""
 }