TargetAhead.go 855 B

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