PerceptionSpeedDiffer.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package main
  2. import (
  3. "cicv-data-closedloop/pjisuv_msgs"
  4. "cicv-data-closedloop/pjisuv_param"
  5. "fmt"
  6. "math"
  7. )
  8. /*
  9. if obj_speed_dic is not {}: #相邻两帧对于同一目标物速度变化率超过设定阈值
  10. if obj.id in obj_speed_dic:
  11. objspeed=pow(pow(obj.vxabs,2)+pow(obj.vyabs,2),0.5)
  12. diff_rate=abs(objspeed-obj_speed_dic[obj.id])/(obj_speed_dic[obj.id]+0.0001)
  13. if diff_rate>0.1 and objspeed>0.5 and obj_speed_dic[obj.id]>0.5:
  14. event_label='perceptionspeeddiffer'
  15. print(event_label)
  16. print(objspeed," ",obj_speed_dic[obj.id]," ",diff_rate)
  17. else:
  18. print(objspeed," ",obj_speed_dic[obj.id]," ",diff_rate)
  19. */
  20. func Topic() string {
  21. return "/tpperception"
  22. }
  23. // Label todo 禁止存在下划线_
  24. func Label() string {
  25. return "PerceptionSpeedDiffer"
  26. }
  27. func Rule(data *pjisuv_msgs.PerceptionObjects, param *pjisuv_param.PjisuvParam) string {
  28. defer func() {
  29. if r := recover(); r != nil {
  30. fmt.Println("Recovered from panic:", r)
  31. }
  32. }()
  33. for _, obj := range data.Objs {
  34. if len(param.ObjSpeedDicOfTpperception) != 0 {
  35. if _, exist := param.ObjSpeedDicOfTpperception[obj.Id]; exist {
  36. objSpeed := math.Pow(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2), 0.5)
  37. diffRate := math.Abs(objSpeed-param.ObjSpeedDicOfTpperception[obj.Id]) / (param.ObjSpeedDicOfTpperception[obj.Id] + 0.0001)
  38. if diffRate > 0.1 && objSpeed > 0.5 && param.ObjSpeedDicOfTpperception[obj.Id] > 0.5 {
  39. return "PerceptionSpeedDiffer"
  40. }
  41. }
  42. }
  43. }
  44. return ""
  45. }