OverSwing.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package main
  2. import (
  3. "cicv-data-closedloop/pjisuv_msgs"
  4. "fmt"
  5. "math"
  6. "sync"
  7. )
  8. /*
  9. def callback_cicv_location(data):
  10. global angular_velocity_z
  11. global Ego_position_x
  12. global Ego_position_y
  13. global Ego_yaw
  14. Ego_position_x=data.position_x
  15. Ego_position_y=data.position_y
  16. Ego_yaw=data.yaw
  17. #print(Ego_yaw)
  18. angular_velocity_z=data.angular_velocity_z
  19. #print(angular_velocity_z)
  20. if abs(angular_velocity_z)>=27:
  21. event_label='overswing' #横摆角速度过大
  22. print(event_label)
  23. */
  24. func Topic() string {
  25. return "/cicv_location"
  26. }
  27. func Label() string {
  28. return "OverSwing"
  29. }
  30. func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string {
  31. defer func() {
  32. if r := recover(); r != nil {
  33. fmt.Println("Recovered from panic:", r)
  34. }
  35. }()
  36. automodeOfPjVehicleFdbPub, ok := shareVars.Load("AutomodeOfPjVehicleFdbPub")
  37. if ok {
  38. if math.Abs(data.AngularVelocityZ) >= 27.0 && automodeOfPjVehicleFdbPub.(int16) == 1 {
  39. return Label()
  40. }
  41. }
  42. return ""
  43. }