TTC.go 819 B

1234567891011121314151617181920212223242526272829303132333435
  1. package main
  2. import (
  3. "cicv-data-closedloop/pjisuv_msgs"
  4. "math"
  5. )
  6. func Topic() string {
  7. return "/tpperception"
  8. }
  9. // Label todo 禁止存在下划线_
  10. func Label() string {
  11. return "TTC"
  12. }
  13. func Rule(data *pjisuv_msgs.PerceptionObjects, velocityX float64, velocityY float64, yaw float64) string {
  14. for _, obj := range data.Objs {
  15. if math.Abs(float64(obj.Y)) <= 2 && obj.X >= 8 {
  16. theta := DegreesToRadians(yaw)
  17. vxrel := (float64(obj.Vxabs)-velocityX)*math.Cos(theta) + (float64(obj.Vyabs)-velocityY)*math.Sin(theta)
  18. ttc := -((float64(obj.X) - 5.2) / (vxrel + 0.001))
  19. //fmt.Println("TTC值为:", ttc)
  20. if ttc >= 0 && ttc <= 5 {
  21. return "TTC"
  22. }
  23. }
  24. }
  25. return ""
  26. }
  27. // DegreesToRadians 计算角度转弧度
  28. func DegreesToRadians(degrees float64) float64 {
  29. return degrees * math.Pi / 180.0
  30. }