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