Explorar el Código

Merge remote-tracking branch 'gogs/master'

LingxinMeng hace 9 meses
padre
commit
d5b7ebf483

+ 1 - 1
trigger/pjibot_delivery/locate_info/locationfailed/main/main.go

@@ -13,7 +13,7 @@ func Label() string {
 	return "locationfailed"
 }
 
-func Rule(data *pji_msgs.LocateInfo) string {
+func Rule(data *pjibot_delivery_msgs.LocateInfo) string {
 	if data.LocateStatus == 0 {
 		return "locationfailed"
 	}

+ 2 - 2
trigger/pjibot_delivery/sys_info/cpuoveroccupied/main/main.go

@@ -1,7 +1,7 @@
 package main
 
 import (
-	"cicv-data-closedloop/pji_msgs"
+	"cicv-data-closedloop/pjibot_delivery_msgs"
 )
 
 func Topic() string {
@@ -12,7 +12,7 @@ func Label() string {
 	return "cpuoveroccupied"
 }
 
-func Rule(data *pji_msgs.SysInfo) string {
+func Rule(data *pjibot_delivery_msgs.SysInfo) string {
 	if data.CpuOccupied > 99 {
 		return "cpuoveroccupied"
 	}

+ 2 - 2
trigger/pjibot_delivery/sys_info/memoveroccupied/main/main.go

@@ -1,7 +1,7 @@
 package main
 
 import (
-	"cicv-data-closedloop/pji_msgs"
+	"cicv-data-closedloop/pjibot_delivery_msgs"
 )
 
 func Topic() string {
@@ -12,7 +12,7 @@ func Label() string {
 	return "memoveroccupied"
 }
 
-func Rule(data *pji_msgs.SysInfo) string {
+func Rule(data *pjibot_delivery_msgs.SysInfo) string {
 	if data.MemOccupied > 99 {
 		return "memoveroccupied"
 	}

+ 1 - 1
trigger/pjibot_delivery/task_feedback_info/TaskFailed/main/TaskFailed.go

@@ -13,7 +13,7 @@ func Label() string {
 	return "TaskFailed"
 }
 
-func Rule(data *pji_msgs.TaskFeedbackInfo) string {
+func Rule(data *pjibot_delivery_msgs.TaskFeedbackInfo) string {
 
 	if data.TaskErrorCode != 0 {
 		return "TaskFailed"

+ 114 - 0
trigger/pjisuv/cicv_location/AbnormalStopOnJunction/main/AbnormalStopOnJunction.go

@@ -0,0 +1,114 @@
+package main
+
+import (
+	"cicv-data-closedloop/pjisuv_msgs"
+	"fmt"
+	"math"
+	"sync"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	StartTime  int64
+	threshold  int64 = 3
+	IsStopped  bool
+	IsEndPoint bool
+	IsJunction bool
+	count1     int64
+	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}
+
+	PointJunctionList = []Point{point3, point4, point5, point6, point7, point8}
+	EndPoint          = Point{0, 0}
+)
+
+func Topic() string {
+	return "/cicv_location"
+}
+
+// 禁止存在下划线_
+func Label() string {
+	return "AbnormalStopOnJunction"
+}
+
+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")
+		Longitude, _ := shareVars.Load("EndPointX")
+		Latitude, _ := shareVars.Load("EndPointY")
+		Automode = Automode.(int16)
+		EndPoint.Longitude = Longitude.(float64)
+		EndPoint.Latitude = Latitude.(float64)
+		pointlist2 := []Point{EndPoint}
+		IsJunction = IfEnter(PointJunctionList, 25.0, data.Latitude, data.Longitude)
+		IsEndPoint = IfEnter(pointlist2, 5.0, data.Latitude, data.Longitude)
+		if Automode == 1 && IsJunction && !IsEndPoint {
+			if data.VelocityX < 0.5 {
+				// 如果之前没有记录开始时间,记录当前时间
+				if StartTime == 0 {
+					StartTime = time.Now().Unix()
+				}
+				// 判断是否持续超过 50s
+				if time.Now().Unix()-StartTime > threshold {
+					if !IsStopped {
+						IsStopped = true
+						return Label()
+					}
+				}
+			} else {
+				// 如果速度大于 0.1,重置开始时间和停止标志
+				StartTime = 0
+				IsStopped = false
+			}
+		} else {
+			StartTime = 0
+			IsStopped = false
+		}
+	}
+	count1++
+	return ""
+}

+ 119 - 0
trigger/pjisuv/cicv_ticker/OutOperationZone/main/OutOperationZone.go

@@ -0,0 +1,119 @@
+package main
+
+import (
+	"cicv-data-closedloop/pjisuv_ticker"
+	"fmt"
+	"sync"
+	"time"
+)
+
+type Point struct {
+	x, y float64
+}
+
+var (
+	vertices = []Point{
+		{x: 456095.447, y: 4397845.34},
+		{x: 456445.083, y: 4398067.52},
+		{x: 456536.143, y: 4397909.14},
+		{x: 456168.902, y: 4397709.52},
+	}
+)
+
+func isPointInPolygon(p Point, vertices []Point) bool {
+	intersections := 0
+	for i := 0; i < len(vertices); i++ {
+		j := (i + 1) % len(vertices)
+		if rayIntersectsSegment(p, vertices[i], vertices[j]) {
+			intersections++
+		}
+	}
+	return intersections%2 == 1
+}
+
+func rayIntersectsSegment(p, p1, p2 Point) bool {
+	if p1.y > p2.y {
+		p1, p2 = p2, p1
+	}
+	if p.y == p1.y || p.y == p2.y {
+		p.y += 0.0001
+	}
+
+	if p.y < p1.y || p.y > p2.y {
+		return false
+	}
+
+	if p.x > max(p1.x, p2.x) {
+		return false
+	}
+
+	if p.x < min(p1.x, p2.x) {
+		return true
+	}
+
+	blueSlope := (p.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y) + p1.x
+	return p.x < blueSlope
+}
+
+func min(a, b float64) float64 {
+	if a < b {
+		return a
+	}
+	return b
+}
+
+func max(a, b float64) float64 {
+	if a > b {
+		return a
+	}
+	return b
+}
+
+// 定时任务触发器固定的
+func Topic() string {
+	return pjisuv_ticker.TickerTopic
+}
+
+// ******* 禁止存在下划线_
+// 触发器标记
+
+func Label() string {
+	return "HuaLong"
+}
+
+func Rule(shareVars *sync.Map) {
+	defer func() {
+		if r := recover(); r != nil {
+			fmt.Println("Recovered from panic:", r)
+		}
+	}()
+	// 1 使用goroutine
+	go func(shareVars *sync.Map) {
+		// 2 定义触发器的间隔时间
+		ticker := time.NewTicker(time.Duration(2) * time.Second)
+		defer ticker.Stop()
+		// 3 运行一个无限循环
+		for {
+			select {
+			// 定时器触发时执行的代码
+			case <-ticker.C:
+				FinalCallback(shareVars)
+
+			}
+		}
+	}(shareVars)
+}
+
+func FinalCallback(shareVars *sync.Map) {
+	PositionX, ok1 := shareVars.Load("PositionXOfCicvLocation")
+	PositionY, ok2 := shareVars.Load("PositionYOfCicvLocation")
+	if ok1 && ok2 {
+		p := Point{x: PositionX.(float64), y: PositionY.(float64)}
+		if !isPointInPolygon(p, vertices) {
+			eventLabel := "OutOperationZone"
+			fmt.Println(eventLabel)
+			pjisuv_ticker.TickerChan <- pjisuv_ticker.TickInfo{FaultLabel: Label(), FaultHappenTime: pjisuv_ticker.GetNowTimeCustom()}
+		}
+	}
+
+}