CCCscpo.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package main
  2. import (
  3. "cicv-data-closedloop/pjisuv_msgs"
  4. "fmt"
  5. "sync"
  6. )
  7. var (
  8. Framenum int64 = 0
  9. YawofCicvLocation any
  10. ObjDicOfTpperception any
  11. objDic = make(map[uint32][][]float32)
  12. yaw float64
  13. objId uint32
  14. obj [][]float32
  15. ok1 bool
  16. ok2 bool
  17. ObjectSlice = make(map[uint32][][]float32)
  18. )
  19. func findIndex(lst []float32, target float32) int {
  20. for i, v := range lst {
  21. if v == target {
  22. return i
  23. }
  24. }
  25. return -1
  26. }
  27. func Topic() string {
  28. return "/tpperception"
  29. }
  30. // 禁止存在下划线_
  31. func Label() string {
  32. return "CCCscpo"
  33. }
  34. func isCrossAndOcclusion(id uint32, ObjectList [][]float32, ObjectSlice map[uint32][][]float32) bool {
  35. for i := 0; i < len(ObjectList[0]); i++ {
  36. xi := ObjectList[0][i]
  37. yi := ObjectList[1][i]
  38. diff_hi := ObjectList[7][i]
  39. Type := ObjectList[6][0]
  40. if xi >= 0 && yi <= -3 && diff_hi <= 120 && diff_hi >= 60 && Type != 1.0 {
  41. startFrame1 := ObjectList[5][i]
  42. for j := 0; j < len(ObjectList[0])-i-1; j++ {
  43. xj := ObjectList[0][j]
  44. yj := ObjectList[1][j]
  45. diff_hj := ObjectList[7][j]
  46. if xj >= 0 && yj >= 1 && diff_hj <= 120 && diff_hj >= 60 {
  47. startFrame2 := ObjectList[5][j]
  48. for this_id, objValue := range ObjectSlice {
  49. if this_id != id {
  50. this_startFrame_index1 := findIndex(objValue[5], startFrame1)
  51. this_startFrame_index2 := findIndex(objValue[5], startFrame2)
  52. this_type := objValue[6][0]
  53. //fmt.Println(objValue[0][this_startFrame_index2], xj)
  54. if this_startFrame_index1 != -1 && this_startFrame_index2 != -1 {
  55. if objValue[0][this_startFrame_index1] >= 2 && objValue[0][this_startFrame_index1] < xi-1 && objValue[1][this_startFrame_index1] < 0 && objValue[1][this_startFrame_index1] > yi && objValue[0][this_startFrame_index2] >= 1 && objValue[0][this_startFrame_index2] < xj-1 && objValue[1][this_startFrame_index2] < 0 && (this_type == 2.0 || this_type == 3.0) {
  56. return true
  57. }
  58. }
  59. } else {
  60. continue
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }
  67. return false
  68. }
  69. func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string {
  70. defer func() {
  71. if r := recover(); r != nil {
  72. fmt.Println("Recovered from panic:", r)
  73. }
  74. }()
  75. YawofCicvLocation, ok1 = shareVars.Load("YawOfCicvLocation")
  76. if !ok1 {
  77. return ""
  78. }
  79. yaw = YawofCicvLocation.(float64)
  80. Framenum += 1
  81. ObjDicOfTpperception, ok2 = shareVars.Load("ObjDicOfTpperception")
  82. if !ok2 {
  83. return ""
  84. }
  85. objDic = ObjDicOfTpperception.(map[uint32][][]float32)
  86. for id, objValue := range objDic {
  87. if len(objValue[0]) <= 10 || !isCrossAndOcclusion(id, objValue, ObjectSlice) {
  88. continue
  89. }
  90. return Label()
  91. }
  92. return ""
  93. }