overspeed.go 425 B

123456789101112131415161718192021222324
  1. package main
  2. import (
  3. "github.com/bluenviron/goroslib/v2/pkg/msgs/nav_msgs"
  4. "math"
  5. )
  6. func Topic() string {
  7. return "/odom"
  8. }
  9. func Label() string {
  10. return "overspeed"
  11. }
  12. func Rule(data *nav_msgs.Odometry) string {
  13. velocityX := data.Twist.Twist.Linear.X
  14. velocityY := data.Twist.Twist.Linear.Y
  15. absV := math.Pow(math.Pow(velocityX, 2)+math.Pow(velocityY, 2), 0.5)
  16. if absV*3.6 > 0 {
  17. return "overspeed"
  18. }
  19. return ""
  20. }