CCFhos.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package main
  2. import (
  3. "cicv-data-closedloop/pjisuv_msgs"
  4. "fmt"
  5. "math"
  6. "sync"
  7. )
  8. var (
  9. Framenum int64 = 0
  10. YawofCicvLocation any
  11. ObjDicOfTpperception any
  12. objDic = make(map[uint32][][]float32)
  13. yaw float64
  14. objId uint32
  15. obj [][]float32
  16. ok1 bool
  17. ok2 bool
  18. ObjectSlice = make(map[uint32][][]float32)
  19. )
  20. func isRetrograde(ObjectList [][]float32) bool {
  21. for i := 0; i < len(ObjectList[0]); i++ {
  22. xi := ObjectList[0][i]
  23. yi := math.Abs(float64(ObjectList[1][i]))
  24. diff_hi := ObjectList[7][i]
  25. Type := ObjectList[6][0]
  26. if xi >= 20 && yi <= 1.2 && diff_hi > 150 && Type != 1.0 {
  27. for j := 0; j < len(ObjectList[0])-i-1; j++ {
  28. xj := ObjectList[0][j]
  29. yj := math.Abs(float64(ObjectList[1][j]))
  30. diff_hj := ObjectList[7][j]
  31. if xj <= 8 && yj <= 1.2 && diff_hj > 150 {
  32. return true
  33. }
  34. }
  35. }
  36. }
  37. return false
  38. }
  39. func Topic() string {
  40. return "/tpperception"
  41. }
  42. // 禁止存在下划线_
  43. func Label() string {
  44. return "CCFhos"
  45. }
  46. func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string {
  47. defer func() {
  48. if r := recover(); r != nil {
  49. fmt.Println("Recovered from panic:", r)
  50. }
  51. }()
  52. YawofCicvLocation, ok1 = shareVars.Load("YawOfCicvLocation")
  53. if !ok1 {
  54. return ""
  55. }
  56. yaw = YawofCicvLocation.(float64)
  57. Framenum += 1
  58. ObjDicOfTpperception, ok2 = shareVars.Load("ObjDicOfTpperception")
  59. if !ok2 {
  60. return ""
  61. }
  62. objDic = ObjDicOfTpperception.(map[uint32][][]float32)
  63. for _, objValue := range objDic {
  64. if len(objValue[0]) <= 10 || !isRetrograde(objValue) {
  65. continue
  66. }
  67. return Label()
  68. }
  69. return ""
  70. }