TrafficCongestion.go 833 B

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