|
@@ -4,9 +4,9 @@ package main
|
|
|
|
|
|
import (
|
|
|
"cicv-data-closedloop/pjisuv_msgs"
|
|
|
- "cicv-data-closedloop/pjisuv_param"
|
|
|
"fmt"
|
|
|
"math"
|
|
|
+ "sync"
|
|
|
)
|
|
|
|
|
|
func Topic() string {
|
|
@@ -17,6 +17,31 @@ func Label() string {
|
|
|
return "OutOfLane"
|
|
|
}
|
|
|
|
|
|
+func Rule(shareVars *sync.Map, data *pjisuv_msgs.PolygonStamped) string {
|
|
|
+ defer func() {
|
|
|
+ if r := recover(); r != nil {
|
|
|
+ fmt.Println("Recovered from panic:", r)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ positionXOfCicvLocation, ok1 := shareVars.Load("PositionXOfCicvLocation")
|
|
|
+ positionYOfCicvLocation, ok2 := shareVars.Load("PositionYOfCicvLocation")
|
|
|
+ yawOfCicvLocation, ok3 := shareVars.Load("YawOfCicvLocation")
|
|
|
+ automodeOfPjVehicleFdbPub, ok4 := shareVars.Load("AutomodeOfPjVehicleFdbPub")
|
|
|
+ if ok1 && ok2 && ok3 && ok4 {
|
|
|
+ Points := data.Polygon.Points
|
|
|
+ D1, D2, D3 := 1.0, 0.4, 0.4 //这是实车缩小后的尺寸
|
|
|
+ corners := getVehicleCorners(positionXOfCicvLocation.(float64), positionYOfCicvLocation.(float64), D1, D2, D3, yawOfCicvLocation.(float64))
|
|
|
+ for i := 0; i < len(Points)-1; i++ {
|
|
|
+ A := Points[i]
|
|
|
+ B := Points[i+1]
|
|
|
+ if polygonLineIntersect(corners, A, B) && automodeOfPjVehicleFdbPub.(int16) == 1 {
|
|
|
+ return Label()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ""
|
|
|
+}
|
|
|
+
|
|
|
type Point struct {
|
|
|
X, Y float64
|
|
|
}
|
|
@@ -62,24 +87,3 @@ func polygonLineIntersect(polygon []pjisuv_msgs.Point64, A, B pjisuv_msgs.Point6
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
-
|
|
|
-func Rule(data *pjisuv_msgs.PolygonStamped, param *pjisuv_param.PjisuvParam) string {
|
|
|
- defer func() {
|
|
|
- if r := recover(); r != nil {
|
|
|
- fmt.Println("Recovered from panic:", r)
|
|
|
- }
|
|
|
- }()
|
|
|
- Points := data.Polygon.Points
|
|
|
- D1, D2, D3 := 1.0, 0.4, 0.4 //这是实车缩小后的尺寸
|
|
|
- corners := getVehicleCorners(param.PositionXOfCicvLocation, param.PositionYOfCicvLocation, D1, D2, D3, param.YawOfCicvLocation)
|
|
|
-
|
|
|
- for i := 0; i < len(Points)-1; i++ {
|
|
|
- A := Points[i]
|
|
|
- B := Points[i+1]
|
|
|
- if polygonLineIntersect(corners, A, B) && param.AutomodeOfPjVehicleFdbPub == 1 {
|
|
|
- return "OutOfLane"
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return ""
|
|
|
-}
|