CCRH.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. AngularVelocityZOfCicvLocation any
  13. AngularVelocity float64
  14. AngularVelocityZOfCicvLocation1 any
  15. AngularVelocity1 float64
  16. objDic = make(map[uint32][][]float32)
  17. yaw float64
  18. ok1 bool
  19. ok2 bool
  20. )
  21. func isCuttingOut(shareVars *sync.Map, ObjectList [][]float32) bool {
  22. for i := 0; i < len(ObjectList[0]); i++ {
  23. xi := ObjectList[0][i]
  24. yi := math.Abs(float64(ObjectList[1][i]))
  25. Type := ObjectList[6][0]
  26. AngularVelocityZOfCicvLocation, ok1 := shareVars.Load("AngularVelocityZOfCicvLocation")
  27. if !ok1 {
  28. return false
  29. }
  30. AngularVelocity = AngularVelocityZOfCicvLocation.(float64)
  31. if xi >= 0 && yi <= 0.7 && math.Abs(AngularVelocity) <= 0.6 && (Type != 100.0) { //简化条件
  32. //if xi >= 0 && yi <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && (Type == 2.0 || Type == 3.0) {//理论条件
  33. for j := 0; j < len(ObjectList[0])-i-1; j++ {
  34. xj := ObjectList[0][j]
  35. yj := math.Abs(float64(ObjectList[1][j]))
  36. if xj >= 0 && yj >= 2.0 && math.Abs(AngularVelocity) <= 0.6 {
  37. return true
  38. }
  39. }
  40. }
  41. }
  42. return false
  43. }
  44. func Topic() string {
  45. return "/tpperception"
  46. }
  47. // 禁止存在下划线_
  48. func Label() string {
  49. return "CCRH"
  50. }
  51. func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string {
  52. defer func() {
  53. if r := recover(); r != nil {
  54. fmt.Println("Recovered from panic:", r)
  55. }
  56. }()
  57. YawofCicvLocation, ok2 = shareVars.Load("YawOfCicvLocation")
  58. if !ok1 {
  59. return ""
  60. }
  61. yaw = YawofCicvLocation.(float64)
  62. Framenum += 1
  63. ObjDicOfTpperception, ok2 = shareVars.Load("ObjDicOfTpperception")
  64. if !ok2 {
  65. return ""
  66. }
  67. objDic = ObjDicOfTpperception.(map[uint32][][]float32)
  68. for _, objValue := range objDic {
  69. if len(objValue[0]) <= 10 || !isCuttingOut(shareVars, objValue) {
  70. continue
  71. }
  72. return Label()
  73. }
  74. return ""
  75. }