TargetAhead.go 1011 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. OutsideWorkshopFlag, ok3 := shareVars.Load("OutsideWorkshopFlag")
  24. OutsideWorkshopFlag = OutsideWorkshopFlag.(bool)
  25. if ok1 && ok2 && ok3 {
  26. value1 := velocityXOfCicvLocation.(float64)
  27. value2 := angularVelocityZOfCicvLocation.(float64)
  28. for _, obj := range data.Objs {
  29. if math.Abs(float64(obj.Y)) <= 2.3 && obj.X >= 0 && obj.X <= 13 && value1 < 5.5 && math.Abs(value2) >= 0.5 && OutsideWorkshopFlag == true {
  30. return Label()
  31. }
  32. }
  33. }
  34. return ""
  35. }