|
@@ -2,9 +2,9 @@ package main
|
|
|
|
|
|
import (
|
|
|
"cicv-data-closedloop/pjisuv_msgs"
|
|
|
- "cicv-data-closedloop/pjisuv_param"
|
|
|
"fmt"
|
|
|
"math"
|
|
|
+ "sync"
|
|
|
)
|
|
|
|
|
|
|
|
@@ -31,24 +31,30 @@ func Topic() string {
|
|
|
return "/tpperception"
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
func Label() string {
|
|
|
return "TTC"
|
|
|
}
|
|
|
|
|
|
-func Rule(data *pjisuv_msgs.PerceptionObjects, param *pjisuv_param.PjisuvParam) string {
|
|
|
+func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string {
|
|
|
defer func() {
|
|
|
if r := recover(); r != nil {
|
|
|
fmt.Println("Recovered from panic:", r)
|
|
|
}
|
|
|
}()
|
|
|
- for _, obj := range data.Objs {
|
|
|
- if math.Abs(float64(obj.Y)) <= 2 && obj.X >= 6 && param.VelocityXOfCicvLocation > 0.5 {
|
|
|
- ttc := -((float64(obj.X) - 4) / (float64(obj.Vxrel) + 0.001))
|
|
|
- if ttc >= 0 && ttc <= 3 {
|
|
|
- return "TTC"
|
|
|
+
|
|
|
+ velocityXOfCicvLocation, ok := shareVars.Load("VelocityXOfCicvLocation")
|
|
|
+ if ok {
|
|
|
+ value := velocityXOfCicvLocation.(float64)
|
|
|
+ for _, obj := range data.Objs {
|
|
|
+ if math.Abs(float64(obj.Y)) <= 2 && obj.X >= 6 && value > 0.5 {
|
|
|
+ ttc := -((float64(obj.X) - 4) / (float64(obj.Vxrel) + 0.001))
|
|
|
+ if ttc >= 0 && ttc <= 3 {
|
|
|
+ return Label()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return ""
|
|
|
}
|