|
@@ -4,7 +4,6 @@ import (
|
|
|
"cicv-data-closedloop/pjisuv_msgs"
|
|
|
"cicv-data-closedloop/pjisuv_param"
|
|
|
"math"
|
|
|
- "reflect"
|
|
|
)
|
|
|
|
|
|
/*
|
|
@@ -28,34 +27,20 @@ func Topic() string {
|
|
|
|
|
|
// Label todo 禁止存在下划线_
|
|
|
func Label() string {
|
|
|
- return "perceptionspeeddiffer"
|
|
|
+ return "PerceptionSpeedDiffer"
|
|
|
}
|
|
|
|
|
|
func Rule(data *pjisuv_msgs.PerceptionObjects, param pjisuv_param.PjisuvParam) string {
|
|
|
for _, obj := range data.Objs {
|
|
|
if len(param.ObjSpeedDicOfTpperception) != 0 {
|
|
|
- if ContainsElement(param.ObjSpeedDicOfTpperception, obj.Id) {
|
|
|
+ if _, exist := param.ObjSpeedDicOfTpperception[obj.Id]; exist {
|
|
|
objSpeed := math.Pow(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2), 0.5)
|
|
|
diffRate := math.Abs(objSpeed-param.ObjSpeedDicOfTpperception[obj.Id]) / (param.ObjSpeedDicOfTpperception[obj.Id] + 0.0001)
|
|
|
if diffRate > 0.1 && objSpeed > 0.5 && param.ObjSpeedDicOfTpperception[obj.Id] > 0.5 {
|
|
|
- return "perceptionspeeddiffer"
|
|
|
+ return "PerceptionSpeedDiffer"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return ""
|
|
|
}
|
|
|
-
|
|
|
-func ContainsElement(slice interface{}, element interface{}) bool {
|
|
|
- sliceValue := reflect.ValueOf(slice)
|
|
|
- if sliceValue.Kind() != reflect.Slice {
|
|
|
- return false
|
|
|
- }
|
|
|
- for i := 0; i < sliceValue.Len(); i++ {
|
|
|
- currentElement := sliceValue.Index(i).Interface()
|
|
|
- if reflect.DeepEqual(currentElement, element) {
|
|
|
- return true
|
|
|
- }
|
|
|
- }
|
|
|
- return false
|
|
|
-}
|