OverSwing.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. OutsideWorkshopFlag, ok1 := shareVars.Load("OutsideWorkshopFlag")
  38. OutsideWorkshopFlag = OutsideWorkshopFlag.(bool)
  39. if ok && ok1 {
  40. if math.Abs(data.AngularVelocityZ) >= 27.0 && automodeOfPjVehicleFdbPub.(int16) == 1 && OutsideWorkshopFlag == true {
  41. return Label()
  42. }
  43. }
  44. return ""
  45. }