123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package main
- import (
- "cicv-data-closedloop/pjisuv_msgs"
- "fmt"
- "math"
- "sync"
- )
- func Topic() string {
- return "/tpperception"
- }
- func Label() string {
- return "PerceptionSpeedDiffer"
- }
- func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string {
- defer func() {
- if r := recover(); r != nil {
- fmt.Println("Recovered from panic:", r)
- }
- }()
- value, ok := shareVars.Load("ObjSpeedDicOfTpperception")
- if ok {
- objSpeedDicOfTpperception := value.(map[uint32]float64)
- for _, obj := range data.Objs {
- if len(objSpeedDicOfTpperception) != 0 {
- if _, exist := 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-objSpeedDicOfTpperception[obj.Id]) / (objSpeedDicOfTpperception[obj.Id] + 0.0001)
- if diffRate > 0.1 && objSpeed > 0.5 && objSpeedDicOfTpperception[obj.Id] > 0.5 {
- return Label()
- }
- }
- }
- }
- }
- return ""
- }
|