CCFtap.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 "CCFtap"
  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. OutsideWorkshopFlag, ok3 := shareVars.Load("OutsideWorkshopFlag")
  22. PositionXOfCicvLocation, ok2 := shareVars.Load("PositionXOfCicvLocation")
  23. PositionYOfCicvLocation, ok1 := shareVars.Load("PositionYOfCicvLocation")
  24. LeftCurveFlag, ok := shareVars.Load("LeftCurveFlag")
  25. if ok && ok1 && ok2 && ok3 && OutsideWorkshopFlag.(bool) && LeftCurveFlag.(bool) == true {
  26. for _, obj := range data.Objs {
  27. if obj.Type == 2 || obj.Type == 3 {
  28. Distance := math.Sqrt(math.Pow(PositionXOfCicvLocation.(float64)-obj.Xabs, 2) + math.Pow(PositionYOfCicvLocation.(float64)-obj.Yabs, 2))
  29. //fmt.Println("Distance:", Distance)
  30. if obj.X >= 2.0 && obj.X <= 30.0 && (math.Abs(float64(obj.Y)) <= 4.0 || Distance <= 35.0) {
  31. event_lable := "CCFtap"
  32. fmt.Println(event_lable)
  33. return Label()
  34. }
  35. }
  36. }
  37. }
  38. return ""
  39. }