OverSpeed.go 517 B

123456789101112131415161718192021222324252627282930
  1. package main
  2. import (
  3. "cicv-data-closedloop/pjisuv_msgs"
  4. "fmt"
  5. "math"
  6. )
  7. func Topic() string {
  8. return "/cicv_location"
  9. }
  10. func Label() string {
  11. return "OverSpeed"
  12. }
  13. func Rule(data *pjisuv_msgs.PerceptionLocalization) string {
  14. defer func() {
  15. if r := recover(); r != nil {
  16. fmt.Println("Recovered from panic:", r)
  17. }
  18. }()
  19. //threshold := 65.0
  20. threshold := 9999.0
  21. if math.Pow(math.Pow(data.VelocityX, 2)+math.Pow(data.VelocityY, 2), 0.5)*3.6 >= threshold {
  22. return "OverSpeed"
  23. } else {
  24. return ""
  25. }
  26. }