perceptionspeeddiffer.go 1.5 KB

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