TargetTooClose.go 832 B

123456789101112131415161718192021222324252627282930313233343536
  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. func Label() string {
  12. return "TargetTooClose"
  13. }
  14. func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string {
  15. defer func() {
  16. if r := recover(); r != nil {
  17. fmt.Println("Recovered from panic:", r)
  18. }
  19. }()
  20. velocityXOfCicvLocation, ok1 := shareVars.Load("VelocityXOfCicvLocation")
  21. angularVelocityZOfCicvLocation, ok2 := shareVars.Load("AngularVelocityZOfCicvLocation")
  22. if ok1 && ok2 {
  23. for _, obj := range data.Objs {
  24. value1 := velocityXOfCicvLocation.(float64)
  25. value2 := angularVelocityZOfCicvLocation.(float64)
  26. if math.Abs(float64(obj.Y)) <= 1.5 && obj.X >= 0 && obj.X <= 6 && value1 < 5.5 && math.Abs(value2) >= 0.5 {
  27. return Label()
  28. }
  29. }
  30. }
  31. return ""
  32. }