OverSpeed.go 837 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. import (
  3. "cicv-data-closedloop/pjisuv_msgs"
  4. "fmt"
  5. "math"
  6. "sync"
  7. )
  8. func Topic() string {
  9. return "/cicv_location"
  10. }
  11. func Label() string {
  12. return "OverSpeed"
  13. }
  14. func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string {
  15. defer func() {
  16. if r := recover(); r != nil {
  17. fmt.Println("Recovered from panic:", r)
  18. }
  19. }()
  20. //threshold := 65.0
  21. //OutsideWorkshopFlag, _ := shareVars.Load("OutsideWorkshopFlag")
  22. //OutsideWorkshopFlag = OutsideWorkshopFlag.(bool)
  23. threshold := 40.0
  24. //if math.Pow(math.Pow(data.VelocityX, 2)+math.Pow(data.VelocityY, 2), 0.5) >= threshold && OutsideWorkshopFlag == true {
  25. // return "OverSpeed"
  26. //} else {
  27. // return ""
  28. //}
  29. if math.Pow(math.Pow(data.VelocityX, 2)+math.Pow(data.VelocityY, 2), 0.5) >= threshold {
  30. return "OverSpeed"
  31. } else {
  32. return ""
  33. }
  34. }