NumTargetsExceedThreshold.go 728 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. import (
  3. "cicv-data-closedloop/pjisuv_msgs"
  4. "fmt"
  5. "sync"
  6. )
  7. func Topic() string {
  8. return "/tpperception"
  9. }
  10. // 禁止存在下划线_
  11. func Label() string {
  12. return "NumTargetsExceedThreshold"
  13. }
  14. func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string {
  15. NumTargets := 0
  16. defer func() {
  17. if r := recover(); r != nil {
  18. fmt.Println("Recovered from panic:", r)
  19. }
  20. }()
  21. velocityXOfCicvLocation, ok := shareVars.Load("VelocityXOfCicvLocation")
  22. if ok {
  23. if velocityXOfCicvLocation.(float64) > 2.5 && len(data.Objs) > 6 {
  24. for _, obj := range data.Objs {
  25. if obj.Type != 0 && obj.X >= 2 {
  26. NumTargets++
  27. }
  28. }
  29. if NumTargets >= 5 {
  30. return Label()
  31. }
  32. }
  33. }
  34. return ""
  35. }