12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package main
- import (
- "cicv-data-closedloop/pjisuv_msgs"
- "cicv-data-closedloop/pjisuv_param"
- "fmt"
- "math"
- )
- func Topic() string {
- return "/tpperception"
- }
- func Label() string {
- return "PerceptionSpeedDiffer"
- }
- func Rule(data *pjisuv_msgs.PerceptionObjects, param *pjisuv_param.PjisuvParam) string {
- defer func() {
- if r := recover(); r != nil {
- fmt.Println("Recovered from panic:", r)
- }
- }()
- for _, obj := range data.Objs {
- if len(param.ObjSpeedDicOfTpperception) != 0 {
- 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 ""
- }
|