HeWang 7 ay önce
işleme
fd597b1284
100 değiştirilmiş dosya ile 11562 ekleme ve 0 silme
  1. 8 0
      .idea/.gitignore
  2. 9 0
      .idea/awesomeProject.iml
  3. 8 0
      .idea/modules.xml
  4. 6 0
      .idea/vcs.xml
  5. 12 0
      entity/callback.go
  6. 55 0
      entity/extend_param.go
  7. 35 0
      entity/http_result.go
  8. 96 0
      entity/time_window.go
  9. 11 0
      go.mod
  10. 16 0
      go.sum
  11. 69 0
      kinglong_msgs/common_msgs.go
  12. 54 0
      kinglong_msgs/control_msgs.go
  13. 104 0
      kinglong_msgs/perception_msgs.go
  14. 102 0
      main/Mann-Whitney-U_test/main/Mann-Whitney-U_test.go
  15. 64 0
      main/Test/main/temp.go
  16. 268 0
      main/kinglong/CutInDifference/main/CutInDifference.go
  17. 268 0
      main/kinglong/CutOutDifference/main/CutOutDifference.go
  18. 205 0
      main/kinglong/FollowDifference/main/FollowDifference.go
  19. 163 0
      main/pji_DGNC/AbnormalParking/main/AbnormalParking.go
  20. 149 0
      main/pji_DGNC/AbnormalStopOnCurve/main/AbnormalStopOnCurve.go
  21. 155 0
      main/pji_DGNC/AbnormalStopOnJunction/main/AbnormalStopOnJunction.go
  22. 93 0
      main/pji_DGNC/AuLongStop/main/AuLongStop.go
  23. 169 0
      main/pji_DGNC/BeOvertakenInCurve/main/BeOvertakenInCurve.go
  24. 125 0
      main/pji_DGNC/BeOvertakenWithHighSpeed/main/BeOvertakenWithHighSpeed.go
  25. 174 0
      main/pji_DGNC/CBFA/main/CBFA.go
  26. 81 0
      main/pji_DGNC/CBLA/main/CBLA.go
  27. 173 0
      main/pji_DGNC/CBNA/main/CBNA.go
  28. 173 0
      main/pji_DGNC/CBNAO/main/CBNAO.go
  29. 126 0
      main/pji_DGNC/CBTA_f/main/CBTA_f.go
  30. 129 0
      main/pji_DGNC/CBTA_n/main/CBTA_n.go
  31. 151 0
      main/pji_DGNC/CCCscp_f/main/CCCscp_f.go
  32. 149 0
      main/pji_DGNC/CCCscp_n/main/CCCscp_n.go
  33. 172 0
      main/pji_DGNC/CCCscpo/main/CCCscpo.go
  34. 146 0
      main/pji_DGNC/CCFhos/main/CCFhos.go
  35. 125 0
      main/pji_DGNC/CCFtap/main/CCFtap.go
  36. 145 0
      main/pji_DGNC/CCRH/main/CCRH.go
  37. 76 0
      main/pji_DGNC/CPLA/main/CPLA.go
  38. 173 0
      main/pji_DGNC/CPNCO/main/CPNCO.go
  39. 148 0
      main/pji_DGNC/CPRm_f/main/CPRm_f.go
  40. 148 0
      main/pji_DGNC/CPRm_n/main/CPRm_n.go
  41. 126 0
      main/pji_DGNC/CPTA_f/main/CPTA_f.go
  42. 126 0
      main/pji_DGNC/CPTA_n/main/CPTA_n.go
  43. 97 0
      main/pji_DGNC/Cadence/main/Cadence.go
  44. 126 0
      main/pji_DGNC/CannotBypassObstacles/main/CannotBypassObstacles.go
  45. 126 0
      main/pji_DGNC/CarFollowingTooCloseAtNight/main/CarFollowingTooCloseAtNight.go
  46. 113 0
      main/pji_DGNC/CarFollowingTooCloseHigh/main/CarFollowingTooCloseHigh.go
  47. 113 0
      main/pji_DGNC/CarFollowingTooCloseLow/main/CarFollowingTooCloseLow.go
  48. 104 0
      main/pji_DGNC/ClimbingSteepHill/main/ClimbingSteepHill.go
  49. 104 0
      main/pji_DGNC/CloseTargetDisappears/main/CloseTargetDisappears.go
  50. 80 0
      main/pji_DGNC/Creeping/main/Creeping.go
  51. 96 0
      main/pji_DGNC/CurveOverspeed/main/CurveOverspeed.go
  52. 152 0
      main/pji_DGNC/CutinWithSightBblock/main/CutinWithSightBblock.go
  53. 104 0
      main/pji_DGNC/DescendingSteepHill/main/DescendingSteepHill.go
  54. 81 0
      main/pji_DGNC/EgoReversing/main/EgoReversing.go
  55. 103 0
      main/pji_DGNC/EnterTjunction/main/EnterTjunction.go
  56. 87 0
      main/pji_DGNC/EnterTjunctionUTM/main/EnterTjunction.go
  57. 77 0
      main/pji_DGNC/ExcessiveSpeedWhenDownhill/main/ExcessiveSpeedWhenDownhill.go
  58. 77 0
      main/pji_DGNC/ExcessiveSpeedWhenUphill/main/ExcessiveSpeedWhenUphill.go
  59. 98 0
      main/pji_DGNC/FindLongCurve/main/FindLongCurve.go
  60. 101 0
      main/pji_DGNC/FindTrafficLight/main/FindTrafficLight.go
  61. 131 0
      main/pji_DGNC/Foggy/main/Foggy.go
  62. 99 0
      main/pji_DGNC/FrequentStartsAndStops/main/FrequentStartsAndStops.go
  63. 129 0
      main/pji_DGNC/FrontCarDrivingWrongDirection/main/FrontCarDrivingWrongDirection.go
  64. 179 0
      main/pji_DGNC/FrontCarRetrogradeOnJunction/main/FrontCarRetrogradeOnJunction.go
  65. 107 0
      main/pji_DGNC/FrontCarSideBySide/main/FrontCarSideBySide.go
  66. 119 0
      main/pji_DGNC/FrontCarStayAway/main/FrontCarStayAway.go
  67. 123 0
      main/pji_DGNC/FrontVehicleBrake/main/FrontVehicleBrake.go
  68. 164 0
      main/pji_DGNC/FrontVehicleBrakeInCurve/main/FrontVehicleBrakeInCurve.go
  69. 171 0
      main/pji_DGNC/FrontVehicleBrakeInJunction/main/FrontVehicleBrakeInJunction.go
  70. 120 0
      main/pji_DGNC/FrontVehicleCutInFar/main/FrontVehicleCutInFar.go
  71. 123 0
      main/pji_DGNC/FrontVehicleCutInNear/main/FrontVehicleCutInNear.go
  72. 120 0
      main/pji_DGNC/FrontVehicleCutOutFar/main/FrontVehicleCutOutFar.go
  73. 120 0
      main/pji_DGNC/FrontVehicleCutOutNear/main/FrontVehicleCutOutNear.go
  74. 136 0
      main/pji_DGNC/FrontVehicleFrequentBrake/main/FrontVehicleFrequentBrake.go
  75. 129 0
      main/pji_DGNC/FrontVehiclesFrequentChangeLane/main/FrontVehiclesFrequentChangeLane.go
  76. 84 0
      main/pji_DGNC/GearJump/main/GearJump.go
  77. 149 0
      main/pji_DGNC/GreenLightsNoPass/main/GreenLightsNoPass.go
  78. 131 0
      main/pji_DGNC/HeavyIntensityRain/main/HeavyIntensityRain.go
  79. 130 0
      main/pji_DGNC/HighSpeedOvertaking/main/HighSpeedOvertaking.go
  80. 131 0
      main/pji_DGNC/HighTemperature/main/HighTemperature.go
  81. 98 0
      main/pji_DGNC/HuaLong/main/HuaLong.go
  82. 111 0
      main/pji_DGNC/JunctionOverspeed/main/JunctionOverspeed.go
  83. 70 0
      main/pji_DGNC/LocationJump/main/LocationJump.go
  84. 123 0
      main/pji_DGNC/LongDownhill/main/LongDownhill.go
  85. 148 0
      main/pji_DGNC/LongTimeParallel/main/LongTimeParallel.go
  86. 122 0
      main/pji_DGNC/LongUphill/main/LongUphill.go
  87. 85 0
      main/pji_DGNC/NumTargetsExceedThreshold/main/NumTargetsExceedThreshold.go
  88. 143 0
      main/pji_DGNC/OutOfLane/main/OutOfLane.go
  89. 125 0
      main/pji_DGNC/OutOperationZone/main/OutOperationZone.go
  90. 80 0
      main/pji_DGNC/OverspeedAtNight/main/OverspeedAtNight.go
  91. 170 0
      main/pji_DGNC/OvertakingInCurve/main/OvertakingInCurve.go
  92. 129 0
      main/pji_DGNC/OvertakingRight/main/OvertakingRight.go
  93. 100 0
      main/pji_DGNC/PassManholeCover/main/PassManholeCover.go
  94. 120 0
      main/pji_DGNC/RearTruckApproach/main/RearTruckApproach.go
  95. 119 0
      main/pji_DGNC/RearVehicleApproach/main/RearVehicleApproach.go
  96. 122 0
      main/pji_DGNC/RearVehicleCutIn/main/RearVehicleCutIn.go
  97. 122 0
      main/pji_DGNC/RearVehicleCutOut/main/RearVehicleCutOut.go
  98. 113 0
      main/pji_DGNC/RearVehicleFollowingTooCloseHigh/main/RearVehicleFollowingTooCloseHigh.go
  99. 113 0
      main/pji_DGNC/RearVehicleFollowingTooCloseLow/main/RearVehicleFollowingTooCloseLow.go
  100. 130 0
      main/pji_DGNC/RearVehiclesFrequentChangeLane/main/RearVehiclesFrequentChangeLane.go

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 9 - 0
.idea/awesomeProject.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="Go" enabled="true" />
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/awesomeProject.iml" filepath="$PROJECT_DIR$/.idea/awesomeProject.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 12 - 0
entity/callback.go

@@ -0,0 +1,12 @@
+package entity
+
+type CallBack struct {
+	DataName    string   `json:"dataName"`
+	DataSize    string   `json:"dataSize"`
+	EquipmentNo string   `json:"equipmentNo"`
+	SecretKey   string   `json:"secretKey"`
+	RosBagPath  string   `json:"rosBagPath"`
+	FilePath    string   `json:"filePath"`
+	TaskId      string   `json:"taskId"`
+	TriggerId   []string `json:"triggerId"`
+}

+ 55 - 0
entity/extend_param.go

@@ -0,0 +1,55 @@
+package entity
+
+type PjisuvParam struct {
+	// /cicv_location
+	AbsSpeed                       float64
+	VelocityXOfCicvLocation        float64
+	VelocityYOfCicvLocation        float64
+	VelocityZOfCicvLocation        float64
+	YawOfCicvLocation              float64
+	AngularVelocityZOfCicvLocation float64
+	PositionXOfCicvLocation        float64
+	PositionYOfCicvLocation        float64
+	LatitudeOfCicvLocation         float64
+	LongitudeOfCicvLocation        float64
+	EnterJunctionFlag              bool
+
+	// /tpperception
+	ObjDicOfTpperception map[uint32][]float32
+
+	// /pji_control_pub
+	NumCountPjiControlCommandOfPjControlPub int
+	EgoSteeringCmdOfPjControlPub            []float64
+	EgoThrottleCmdOfPjControlPub            []float64
+	// /data_read
+	NumCountDataReadOfDataRead   int
+	EgoSteeringRealOfDataRead    []float64
+	EgoThrottleRealOfDataRead    []float64
+	StrgAngleRealValueOfDataRead float64
+	// /pj_vehicle_fdb_pub
+	AutomodeOfPjVehicleFdbPub int16
+	///cicv_amr_trajectory
+	DecisionType int8
+}
+
+type KinglongParam struct {
+	// /cicv_location
+	VelocityXOfCicvLocation        float64
+	VelocityYOfCicvLocation        float64
+	YawOfCicvLocation              float64
+	AngularVelocityZOfCicvLocation float64
+
+	// /tpperception
+	ObjDicOfTpperception map[uint32][]float32
+
+	// /pji_control_pub
+	NumCountJinlongControlCommandOfPjControlPub int
+	EgoSteeringCmdOfJinlongControlPub           []float64
+	EgoThrottleCmdOfJinlongControlPub           []float64
+	EgoBrakeCmdOfJinlongControlPub              []float64
+	// /data_read
+	NumCountDataReadOfDataRead int
+	EgoSteeringRealOfDataRead  []float64
+	EgoThrottleRealOfDataRead  []float64
+	EgoBrakeRealOfDataRead     []float64
+}

+ 35 - 0
entity/http_result.go

@@ -0,0 +1,35 @@
+package entity
+
+import "encoding/json"
+
+var DefaultSuccessHttpResult = &HttpResult{Status: true, Code: "1000", Message: "请求成功。"}
+var DefaultFailHttpResult = &HttpResult{Status: true, Code: "2000", Message: "请求失败。"}
+
+type HttpResult struct {
+	Status  bool   `json:"status"`
+	Code    string `json:"code"`
+	Message string `json:"message"`
+	Details string `json:"details"`
+}
+
+type Response struct {
+	Code  int         `json:"code"`  // 错误码
+	Msg   string      `json:"msg"`   // 错误描述
+	Data  interface{} `json:"data"`  // 返回数据
+	Total interface{} `json:"total"` // 分页的total数量
+}
+
+// ToString 返回 JSON 格式的错误详情
+func (res *Response) ToString() string {
+	err := &struct {
+		Code int         `json:"code"`
+		Msg  string      `json:"msg"`
+		Data interface{} `json:"data"`
+	}{
+		Code: res.Code,
+		Msg:  res.Msg,
+		Data: res.Data,
+	}
+	raw, _ := json.Marshal(err)
+	return string(raw)
+}

+ 96 - 0
entity/time_window.go

@@ -0,0 +1,96 @@
+package entity
+
+import (
+	"encoding/json"
+	"sync"
+	"time"
+)
+
+var (
+	TimeWindowProducerQueue      []TimeWindow
+	TimeWindowProducerQueueMutex sync.RWMutex
+
+	TimeWindowConsumerQueue      []TimeWindow
+	TimeWindowConsumerQueueMutex sync.RWMutex
+	Subscriber0Time              = time.Date(2023, time.November, 23, 10, 30, 0, 0, time.UTC)
+	Subscriber0TimeMutex         sync.Mutex
+	Subscriber1Time              = time.Date(2023, time.November, 23, 10, 30, 0, 0, time.UTC)
+	Subscriber1TimeMutex         sync.Mutex
+	Subscriber2Time              = time.Date(2023, time.November, 23, 10, 30, 0, 0, time.UTC)
+	Subscriber2TimeMutex         sync.Mutex
+	Subscriber3Time              = time.Date(2023, time.November, 23, 10, 30, 0, 0, time.UTC)
+	Subscriber3TimeMutex         sync.Mutex
+	Subscriber4Time              = time.Date(2023, time.November, 23, 10, 30, 0, 0, time.UTC)
+	Subscriber4TimeMutex         sync.Mutex
+	Subscriber5Time              = time.Date(2023, time.November, 23, 10, 30, 0, 0, time.UTC)
+	Subscriber5TimeMutex         sync.Mutex
+
+	TcpSendTime      = time.Date(2023, time.November, 23, 10, 30, 0, 0, time.UTC)
+	TcpSendTimeMutex sync.Mutex
+)
+
+type TimeWindow struct {
+	FaultTime       string   `json:"FaultTime"`
+	TimeWindowBegin string   `json:"TimeWindowBegin"`
+	TimeWindowEnd   string   `json:"TimeWindowEnd"`
+	Labels          []string `json:"Labels"`
+	TriggerIds      []string `json:"TriggerIds"`
+	Length          int      `json:"Length"`
+	CanUpload       string   `json:"CanUpload"`
+	MasterTopics    []string `json:"MasterTopics"`
+	SlaveTopics     []string `json:"SlaveTopics"`
+}
+
+func RefreshTcpSendTime() {
+	TcpSendTimeMutex.Lock()
+	TcpSendTime = time.Now()
+	TcpSendTimeMutex.Unlock()
+}
+
+func AddTimeWindowToTimeWindowProducerQueue(window TimeWindow) {
+	TimeWindowProducerQueueMutex.RLock()
+	{
+		TimeWindowProducerQueue = append(TimeWindowProducerQueue, window)
+	}
+	TimeWindowProducerQueueMutex.RUnlock()
+}
+
+func AddTimeWindowToTimeWindowConsumerQueue(window TimeWindow) {
+	TimeWindowConsumerQueueMutex.RLock()
+	{
+		TimeWindowConsumerQueue = append(TimeWindowConsumerQueue, window)
+	}
+	TimeWindowConsumerQueueMutex.RUnlock()
+}
+
+func RemoveHeadOfTimeWindowProducerQueue() {
+	TimeWindowProducerQueueMutex.RLock()
+	{
+		TimeWindowProducerQueue = TimeWindowProducerQueue[1:]
+	}
+	TimeWindowProducerQueueMutex.RUnlock()
+}
+
+func RemoveHeadOfTimeWindowConsumerQueue() {
+	TimeWindowConsumerQueueMutex.RLock()
+	{
+		TimeWindowConsumerQueue = TimeWindowConsumerQueue[1:]
+	}
+	TimeWindowConsumerQueueMutex.RUnlock()
+}
+
+// GetLastTimeWindow 获取最后一个时间窗口
+func GetLastTimeWindow() *TimeWindow {
+	var lastTimeWindow *TimeWindow // 获取最后一个时间窗口
+	if len(TimeWindowProducerQueue) > 0 {
+		lastTimeWindow = &TimeWindowProducerQueue[len(TimeWindowProducerQueue)-1]
+	}
+	return lastTimeWindow
+}
+func TimeWindowToJson(msg TimeWindow) (string, error) {
+	jsonData, err := json.Marshal(msg)
+	if err != nil {
+		return "", err
+	}
+	return string(jsonData), nil
+}

+ 11 - 0
go.mod

@@ -0,0 +1,11 @@
+module awesomeProject
+
+go 1.22.0
+
+require github.com/bluenviron/goroslib/v2 v2.1.5
+
+require (
+	github.com/gookit/color v1.5.4 // indirect
+	github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
+	golang.org/x/sys v0.18.0 // indirect
+)

+ 16 - 0
go.sum

@@ -0,0 +1,16 @@
+github.com/bluenviron/goroslib/v2 v2.1.5 h1:yI92Zqv/fQR+NePBuc36o4ORGVmxoEphM3Fn2UQWeEk=
+github.com/bluenviron/goroslib/v2 v2.1.5/go.mod h1:xiUY2i42sdkyPF3O0xznMAc4VcpsKUvtnPL3glwyMrY=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
+github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
+github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
+github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
+golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
+golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

+ 69 - 0
kinglong_msgs/common_msgs.go

@@ -0,0 +1,69 @@
+package kinglong_msgs
+
+import (
+	"github.com/bluenviron/goroslib/v2/pkg/msg"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/std_msgs"
+)
+
+type FaultInfo struct {
+	msg.Package  `ros:"common_msgs"`
+	TimestampSec float64
+	ModuleName   string
+	Version      string
+	ErrorCode    int32
+	Msg          string
+	FaultLevel   int8
+	FaultType    int8
+}
+
+type Header struct {
+	msg.Package    `ros:"common_msgs"`
+	SequenceNum    int32
+	TimeStamp      float64
+	ModuleName     string
+	Version        string
+	FaultVec       FaultVec
+	TimeStatistics TimeStatistics
+}
+
+type FaultVec struct {
+	msg.Package      `ros:"common_msgs"`
+	InfoVec          []FaultInfo
+	ModuleFaultLevel int32
+}
+
+type TimeStatistics struct {
+	msg.Package      `ros:"common_msgs"`
+	DevTimeStatusMsg []TimeStatus
+	SendingTimestamp float64
+}
+
+type TimeStatus struct {
+	msg.Package         `ros:"common_msgs"`
+	Dtime               float64
+	SourceNodeName      string
+	DestinationNodeName string
+}
+
+type Retrieval struct {
+	msg.Package            `ros:"common_msgs"`
+	Header                 std_msgs.Header `rosname:"header"`
+	AsVehAccelerationValue float64         `rosname:"AS_Veh_Acceleration_Value"` // 惯导采集到的加速度
+	AsDriverTakeoverReq    int16           `rosname:"AS_Driver_TakeOver_Req"`    // 驾驶员接管提醒(2B9)
+	VcuAccelPosValue       float64         `rosname:"VCU_Accel_Pos_Value"`       // 实际加速踏板位置
+	VcuBrkPelPosValue      float64         `rosname:"VCU_BrkPel_Pos_Value"`      // 实际制动踏板位置
+	VcuRealSpeed           float64         `rosname:"VCU_Real_Speed"`            // 当前车速
+	VcuCurrentGear         int16           `rosname:"VCU_Current_Gear"`          // 当前档位
+	VcuParkingSt           int16           `rosname:"VCU_Parking_St"`            // 当前P档位
+	AutoDLimitInReason     int16           `rosname:"AutoD_Limitin_Reason"`      // 限制进入自动驾驶原因
+	EmergencyStopReason    int16           `rosname:"Emergency_Stop_Reason"`     // 紧急停车激活原因
+	VcuDriverTakeoverReq   int16           `rosname:"VCU_Driver_TakeOver_Req"`   // 驾驶员接管提醒(2BA)
+	VcuVehicleDriveModeSt  int16           `rosname:"VCU_Vehicle_Drive_Mode_St"` // 车辆驾驶模式
+	AutoDOutReason         int16           `rosname:"AutoD_Out_Reason"`          // 退出自动驾驶原因
+	BrakeSysFaultSt        int16           `rosname:"Brak_Sys_Fault_St"`         // 制动系统故障
+	StrgAngleRealValue     float64         `rosname:"Strg_Angle_Real_Value"`     // 方向盘实际转角
+	StrgAngleSpdValue      float64         `rosname:"Strg_Angle_Spd_Value"`      // 方向盘当前实际速度反馈
+	StrgWorkmodeSt         int16           `rosname:"Strg_WorkMode_St"`          // 当前系统实际工作模式
+	BCHornSt               int16           `rosname:"BC_Horn_St"`                // 喇叭状态
+
+}

+ 54 - 0
kinglong_msgs/control_msgs.go

@@ -0,0 +1,54 @@
+package kinglong_msgs
+
+import (
+	"github.com/bluenviron/goroslib/v2/pkg/msg"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/std_msgs"
+)
+
+type JinlongControlCommand struct {
+	msg.Package                   `ros:"autoware_msgs"`
+	Header                        std_msgs.Header
+	ASStrgAngleReq                float64 `rosname:"AS_Strg_Angle_Req"`
+	ASStrgWorkModeReq             int16   `rosname:"AS_Strg_WorkMode_Req"`
+	ASStrg0Enable                 int16   `rosname:"AS_Strg0_Enable"`
+	ASSteeringTorqueSuperposition float64 `rosname:"AS_Steering_torque_superposition"`
+	ASStrgSpdReq                  float64 `rosname:"AS_Strg_Spd_Req"`
+	ASStrg1Enable                 int16   `rosname:"AS_Strg1_Enable"`
+	ASStrgLifeSignal              int16   `rosname:"AS_Strg_Life_Signal"`
+	ASAutoDReq                    int16   `rosname:"AS_AutoD_Req"`
+	ASLongitCtrlmode              int16   `rosname:"AS_Longit_Ctrlmode"`
+	ASAutoDEmergBrkRelease        int16   `rosname:"AS_AutoD_EmergBrk_Release"`
+	ASAutoDCollisionRelease       int16   `rosname:"AS_AutoD_Collision_Release"`
+	ASAutoDAccelPosReq            float64 `rosname:"AS_AutoD_Accel_Pos_Req"`
+	ASAutoDShiftReq               int16   `rosname:"AS_AutoD_Shift_Req"`
+	ASAutoDPShiftReq              int16   `rosname:"AS_AutoD_P_Shift_Req"`
+	ASAutoDBrkModeReq             int16   `rosname:"AS_AutoD_BrkMode_Req"`
+	ASAutoDBrkPelPosReq           float64 `rosname:"AS_AutoD_BrkPelPos_Req"`
+	ASAutoDSpdLimit               float64 `rosname:"AS_AutoD_Spd_Limit"`
+	ASAutoAccelerationReq         float64 `rosname:"AS_Auto_Acceleration_Req"`
+	ASAutoDLifeSignal             int16   `rosname:"AS_AutoD_Life_Signal"`
+	ASAutoDSpdReq                 float64 `rosname:"AS_AutoD_Spd_Req"`
+	ASSpdLifeSignal               int16   `rosname:"AS_Spd_Life_Signal"`
+	ASAlarmLampReq                int16   `rosname:"AS_AlarmLamp_Req"`
+	ASFrontDoorCtrlReq            int16   `rosname:"AS_Front_Door_Ctrl_Req"`
+	ASLowBeamStartReq             int16   `rosname:"AS_LowBeam_Start_Req"`
+	ASTurnLeftLightStartReq       int16   `rosname:"AS_TurnLeftLight_Start_Req"`
+	ASTurnRightLightStartReq      int16   `rosname:"AS_TurnRightLight_Start_Req"`
+	ASMiniLightStartReq           int16   `rosname:"AS_MiniLight_Start_Req"`
+	ASHornStartReq                int16   `rosname:"AS_Horn_Start_Req"`
+	ASTreadleOperatingReq         int16   `rosname:"AS_Treadle_Operating_Req"`
+	ASFDoorButtonLockReq          int16   `rosname:"AS_FDoorButtonLock_Req"`
+	ASMidDoorCtrlReq              int16   `rosname:"AS_Mid_Door_Ctrl_Req"`
+	ASMDoorButtonLockReq          int16   `rosname:"AS_MDoorButtonLock_Req"`
+	ASRearDoorCtrlReq             int16   `rosname:"AS_Rear_Door_Ctrl_Req"`
+	ASRDoorButtonLockReq          int16   `rosname:"AS_RDoorButtonLock_Req"`
+	ASFrontFogReq                 int16   `rosname:"AS_FrontFog_Req"`
+	ASRearFogReq                  int16   `rosname:"AS_RearFog_Req"`
+	ASWarninglightReq             int16   `rosname:"AS_Warninglight_Req"`
+	ASHighBeamStartReq            int16   `rosname:"AS_HighBeam_Start_Req"`
+	TargetX                       float64
+	TargetY                       float64
+	LateralError                  float64
+	Velocity                      float64
+	AutoMode                      int16
+}

+ 104 - 0
kinglong_msgs/perception_msgs.go

@@ -0,0 +1,104 @@
+package kinglong_msgs
+
+import (
+	"github.com/bluenviron/goroslib/v2/pkg/msg"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/std_msgs"
+)
+
+// PerceptionObjects v2304
+type PerceptionObjects struct {
+	msg.Package `ros:"perception_msgs"`
+	Header      Header
+	Objs        []Object
+	Cells       []ObstacleCell
+}
+
+type Object struct {
+	msg.Package    `ros:"perception_msgs"`
+	Id             uint32
+	X              float32
+	Y              float32
+	Z              float32
+	Vxrel          float32
+	Vyrel          float32
+	Xabs           float64
+	Yabs           float64
+	Vxabs          float32
+	Vyabs          float32
+	Width          float32
+	Length         float32
+	Height         float32
+	Speed          float32
+	Heading        float32
+	Type           uint8
+	Source         uint8
+	Confidence     float32
+	Age            uint32
+	Velocitystatus uint8
+	Cells          []ObstacleCell
+}
+
+type ObstacleCell struct {
+	msg.Package `ros:"perception_msgs"`
+	Idc         int32
+	X           float64
+	Y           float64
+	Xg          float64
+	Yg          float64
+}
+
+type PerceptionLocalization struct {
+	msg.Package `ros:"perception_msgs"`
+
+	Header      std_msgs.Header
+	FrameUnmber uint64
+	FusionLevel int8
+	Status      int8
+	Roll        float64
+	Pitch       float64
+	Yaw         float64
+	RollStd     float32
+	PitchStd    float32
+	YawStd      float32
+
+	Qw float64
+	Qx float64
+	Qy float64
+	Qz float64
+
+	AngularVelocityX float64
+	AngularVelocityY float64
+	AngularVelocityZ float64
+
+	Latitude     float64
+	Longitude    float64
+	Altitude     float64
+	LatitudeStd  float32
+	LongitudeStd float32
+	AltitudeStd  float32
+
+	PositionX    float64
+	PositionY    float64
+	PositionZ    float64
+	PositionXStd float32
+	PositionYStd float32
+	PositionZStd float32
+
+	VelocityX    float64
+	VelocityY    float64
+	VelocityZ    float64
+	VelocityXStd float32
+	VelocityYStd float32
+	VelocityZStd float32
+
+	VelocityRx    float64
+	VelocityRy    float64
+	VelocityRz    float64
+	VelocityRxStd float32
+	VelocityRyStd float32
+	VelocityRzStd float32
+
+	AccelX float64
+	AccelY float64
+	AccelZ float64
+}

+ 102 - 0
main/Mann-Whitney-U_test/main/Mann-Whitney-U_test.go

@@ -0,0 +1,102 @@
+package main
+
+import (
+	"encoding/csv"
+	"fmt"
+	"log"
+	"math"
+	"os"
+	"sort"
+	"strconv"
+)
+
+func mannWhitneyU(x, y []float64) (float64, float64) {
+	n1 := len(x)
+	n2 := len(y)
+
+	combined := append(x, y...)
+	sort.Float64s(combined)
+
+	ranks := make(map[float64]float64)
+	for i := 0; i < len(combined); {
+		j := i
+		for j < len(combined) && combined[i] == combined[j] {
+			j++
+		}
+		rank := float64(i+j+1) / 2
+		for k := i; k < j; k++ {
+			ranks[combined[k]] = rank
+		}
+		i = j
+	}
+
+	r1 := sumRanks(x, ranks)
+	r2 := sumRanks(y, ranks)
+
+	u1 := r1 - float64(n1*(n1+1))/2
+	u2 := r2 - float64(n2*(n2+1))/2
+
+	u := math.Min(u1, u2)
+	meanU := float64(n1*n2) / 2
+	sdU := math.Sqrt(float64(n1*n2*(n1+n2+1)) / 12)
+
+	z := (u - meanU) / sdU
+	p := 2 * (1 - normCdf(math.Abs(z)))
+
+	return u, p
+}
+
+func sumRanks(arr []float64, ranks map[float64]float64) float64 {
+	sum := 0.0
+	for _, v := range arr {
+		sum += ranks[v]
+	}
+	return sum
+}
+
+func normCdf(x float64) float64 {
+	return 0.5 * (1 + math.Erf(x/math.Sqrt2))
+}
+
+func main() {
+	file, err := os.Open("/media/dell/HIKSEMI/3.2切入切出数据包/cut_2024-04-03-14-06-25/testU.csv")
+	if err != nil {
+		log.Fatal(err)
+	}
+	defer file.Close()
+
+	reader := csv.NewReader(file)
+	records, err := reader.ReadAll()
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	col1Index := -1
+	col2Index := -1
+	for i, header := range records[0] {
+		if header == "col1" {
+			col1Index = i
+		} else if header == "col2" {
+			col2Index = i
+		}
+	}
+
+	if col1Index != -1 && col2Index != -1 {
+		Slice1 := make([]float64, len(records)-1)
+		Slice2 := make([]float64, len(records)-1)
+		for i, record := range records[1:] {
+			value1, err1 := strconv.ParseFloat(record[col1Index], 64)
+			value2, err2 := strconv.ParseFloat(record[col2Index], 64)
+			if err1 != nil || err2 != nil {
+				log.Fatal("数据转换错误")
+			}
+			Slice1[i] = value1
+			Slice2[i] = value2
+		}
+
+		u, p := mannWhitneyU(Slice1, Slice2)
+		fmt.Printf("U: %v, P-value: %v\n", u, p)
+	} else {
+		fmt.Println("未找到名为 'ego_Steering_real' 和 'ego_Steering_cmd' 的列")
+	}
+}

+ 64 - 0
main/Test/main/temp.go

@@ -0,0 +1,64 @@
+package main
+
+import (
+	"encoding/json"
+	"fmt"
+	"io/ioutil"
+	"net/http"
+	"time"
+)
+
+func main() {
+	weatherID := []int{}
+	apiKey := "f9d230f00d9ccdba49a97e043333d410"
+	latitude := 39.7283514
+	longitude := 116.4888702
+	maxRetries := 5
+	retryDelay := time.Second * 2
+
+	var data map[string]interface{}
+
+	for retries := 0; retries < maxRetries; retries++ {
+		url := fmt.Sprintf("https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=%s", latitude, longitude, apiKey)
+
+		resp, err := http.Get(url)
+		if err != nil {
+			fmt.Println("Error:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+		defer resp.Body.Close()
+
+		body, err := ioutil.ReadAll(resp.Body)
+		if err != nil {
+			fmt.Println("Error reading response:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+
+		if err := json.Unmarshal(body, &data); err != nil {
+			fmt.Println("Error parsing JSON:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+
+		// Successfully retrieved data
+		break
+	}
+
+	if data == nil {
+		fmt.Println("Failed to retrieve data after maximum retries.")
+		return
+	}
+
+	mainData := data["main"].(map[string]interface{})
+	temperature := mainData["temp"].(float64) - 273.15
+	humidity := mainData["humidity"].(float64)
+
+	for _, w := range data["weather"].([]interface{}) {
+		weather := w.(map[string]interface{})
+		weatherID = append(weatherID, int(weather["id"].(float64)))
+	}
+
+	fmt.Printf("当前位置的天气状况/温度/湿度:%v/%.2f/%.2f\n", weatherID, temperature, humidity)
+}

+ 268 - 0
main/kinglong/CutInDifference/main/CutInDifference.go

@@ -0,0 +1,268 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/kinglong_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"sort"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+	DriverSlice = [][]float64{{}, {}, {}}
+	AlgSlice    = [][]float64{{}, {}, {}}
+
+	CutInFlag  = false
+	CutOutFlag = false
+)
+
+func mannWhitneyU(x, y []float64) (float64, float64) {
+	n1 := len(x)
+	n2 := len(y)
+
+	combined := append(x, y...)
+	sort.Float64s(combined)
+
+	ranks := make(map[float64]float64)
+	for i := 0; i < len(combined); {
+		j := i
+		for j < len(combined) && combined[i] == combined[j] {
+			j++
+		}
+		rank := float64(i+j+1) / 2
+		for k := i; k < j; k++ {
+			ranks[combined[k]] = rank
+		}
+		i = j
+	}
+
+	r1 := sumRanks(x, ranks)
+	r2 := sumRanks(y, ranks)
+
+	u1 := r1 - float64(n1*(n1+1))/2
+	u2 := r2 - float64(n2*(n2+1))/2
+
+	u := math.Min(u1, u2)
+	meanU := float64(n1*n2) / 2
+	sdU := math.Sqrt(float64(n1*n2*(n1+n2+1)) / 12)
+
+	z := (u - meanU) / sdU
+	p := 2 * (1 - normCdf(math.Abs(z)))
+
+	return u, p
+}
+
+func sumRanks(arr []float64, ranks map[float64]float64) float64 {
+	sum := 0.0
+	for _, v := range arr {
+		sum += ranks[v]
+	}
+	return sum
+}
+
+func normCdf(x float64) float64 {
+	return 0.5 * (1 + math.Erf(x/math.Sqrt2))
+}
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingOut(ObjectSlice map[uint32][][]float32) {
+	CutOutFlag = false
+	for _, ObjectList := range ObjectSlice {
+		for i := 0; i < len(ObjectList[0]); i++ {
+			xi := ObjectList[0][i]
+			yi := math.Abs(float64(ObjectList[1][i]))
+			Type := ObjectList[4][0]
+			if xi >= 0 && yi <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.4 && (Type == 0.0 || Type == 1.0) { //简化条件
+
+				for j := 0; j < len(ObjectList[0])-i-1; j++ {
+					xj := ObjectList[0][j]
+					yj := math.Abs(float64(ObjectList[1][j]))
+
+					if xj >= 0 && yj >= 2.0 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.4 {
+						CutOutFlag = true
+					}
+				}
+			}
+		}
+	}
+
+}
+
+func isCuttingIn(ObjectSlice map[uint32][][]float32) {
+	CutInFlag = false
+	for _, ObjectList := range ObjectSlice {
+		for i := 0; i < len(ObjectList[0]); i++ {
+			xi := ObjectList[0][i]
+			yi := math.Abs(float64(ObjectList[1][i]))
+			Type := ObjectList[4][0]
+			if xi >= 0 && yi >= 2 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && (Type == 0.0 || Type == 1.0) { //简化条件
+
+				for j := 0; j < len(ObjectList[0])-i-1; j++ {
+					xj := ObjectList[0][j]
+					yj := math.Abs(float64(ObjectList[1][j]))
+
+					if xj >= 0 && yj <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+						CutInFlag = true
+					}
+				}
+			}
+		}
+	}
+
+}
+
+func FinalCallback() {
+	isCuttingOut(ObjectSlice)
+	isCuttingIn(ObjectSlice)
+	if CutInFlag == true {
+		ObjectSlice = make(map[uint32][][]float32)
+		_, p1 := mannWhitneyU(DriverSlice[0], AlgSlice[0])
+		_, p2 := mannWhitneyU(DriverSlice[1], AlgSlice[1])
+		_, p3 := mannWhitneyU(DriverSlice[2], AlgSlice[2])
+		if p1 < 0.05 || p2 < 0.05 || p3 < 0.05 {
+			event_lable := "CutInDifference"
+			fmt.Println(event_lable)
+			DriverSlice = [][]float64{{}, {}, {}}
+			AlgSlice = [][]float64{{}, {}, {}}
+
+		}
+
+	}
+
+}
+
+func CallbackCicvLocation(data *kinglong_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *kinglong_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 150 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+
+func CallbackDataRead(data *kinglong_msgs.Retrieval) {
+	DriverSlice[0] = append(DriverSlice[0], data.StrgAngleRealValue) //方向盘实际转角
+	DriverSlice[1] = append(DriverSlice[1], data.VcuAccelPosValue)   //实际加速踏板位置
+	DriverSlice[2] = append(DriverSlice[2], data.VcuBrkPelPosValue)  //实际制动踏板位置
+
+}
+
+func CallbackJinlongControlPub(data *kinglong_msgs.JinlongControlCommand) {
+	AlgSlice[0] = append(AlgSlice[0], data.ASStrgAngleReq)      //算法输出方向盘转角
+	AlgSlice[1] = append(AlgSlice[1], data.ASAutoDAccelPosReq)  //算法输出加速踏板位置
+	AlgSlice[2] = append(AlgSlice[2], data.ASAutoDBrkPelPosReq) //算法输出制动踏板位置
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subControl, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/jinlong_control_pub",
+		Callback: CallbackJinlongControlPub,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subControl.Close()
+
+	// create a subscriber
+	subDataRead, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/data_read",
+		Callback: CallbackDataRead,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subDataRead.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 268 - 0
main/kinglong/CutOutDifference/main/CutOutDifference.go

@@ -0,0 +1,268 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/kinglong_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"sort"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+	DriverSlice = [][]float64{{}, {}, {}}
+	AlgSlice    = [][]float64{{}, {}, {}}
+
+	CutInFlag  = false
+	CutOutFlag = false
+)
+
+func mannWhitneyU(x, y []float64) (float64, float64) {
+	n1 := len(x)
+	n2 := len(y)
+
+	combined := append(x, y...)
+	sort.Float64s(combined)
+
+	ranks := make(map[float64]float64)
+	for i := 0; i < len(combined); {
+		j := i
+		for j < len(combined) && combined[i] == combined[j] {
+			j++
+		}
+		rank := float64(i+j+1) / 2
+		for k := i; k < j; k++ {
+			ranks[combined[k]] = rank
+		}
+		i = j
+	}
+
+	r1 := sumRanks(x, ranks)
+	r2 := sumRanks(y, ranks)
+
+	u1 := r1 - float64(n1*(n1+1))/2
+	u2 := r2 - float64(n2*(n2+1))/2
+
+	u := math.Min(u1, u2)
+	meanU := float64(n1*n2) / 2
+	sdU := math.Sqrt(float64(n1*n2*(n1+n2+1)) / 12)
+
+	z := (u - meanU) / sdU
+	p := 2 * (1 - normCdf(math.Abs(z)))
+
+	return u, p
+}
+
+func sumRanks(arr []float64, ranks map[float64]float64) float64 {
+	sum := 0.0
+	for _, v := range arr {
+		sum += ranks[v]
+	}
+	return sum
+}
+
+func normCdf(x float64) float64 {
+	return 0.5 * (1 + math.Erf(x/math.Sqrt2))
+}
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingOut(ObjectSlice map[uint32][][]float32) {
+	CutOutFlag = false
+	for _, ObjectList := range ObjectSlice {
+		for i := 0; i < len(ObjectList[0]); i++ {
+			xi := ObjectList[0][i]
+			yi := math.Abs(float64(ObjectList[1][i]))
+			Type := ObjectList[4][0]
+			if xi >= 0 && yi <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.4 && (Type == 0.0 || Type == 1.0) { //简化条件
+
+				for j := 0; j < len(ObjectList[0])-i-1; j++ {
+					xj := ObjectList[0][j]
+					yj := math.Abs(float64(ObjectList[1][j]))
+
+					if xj >= 0 && yj >= 2.0 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.4 {
+						CutOutFlag = true
+					}
+				}
+			}
+		}
+	}
+
+}
+
+func isCuttingIn(ObjectSlice map[uint32][][]float32) {
+	CutInFlag = false
+	for _, ObjectList := range ObjectSlice {
+		for i := 0; i < len(ObjectList[0]); i++ {
+			xi := ObjectList[0][i]
+			yi := math.Abs(float64(ObjectList[1][i]))
+			Type := ObjectList[4][0]
+			if xi >= 0 && yi >= 2 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && (Type == 0.0 || Type == 1.0) { //简化条件
+
+				for j := 0; j < len(ObjectList[0])-i-1; j++ {
+					xj := ObjectList[0][j]
+					yj := math.Abs(float64(ObjectList[1][j]))
+
+					if xj >= 0 && yj <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+						CutInFlag = true
+					}
+				}
+			}
+		}
+	}
+
+}
+
+func FinalCallback() {
+	isCuttingOut(ObjectSlice)
+	isCuttingIn(ObjectSlice)
+	if CutOutFlag == true {
+		ObjectSlice = make(map[uint32][][]float32)
+		_, p1 := mannWhitneyU(DriverSlice[0], AlgSlice[0])
+		_, p2 := mannWhitneyU(DriverSlice[1], AlgSlice[1])
+		_, p3 := mannWhitneyU(DriverSlice[2], AlgSlice[2])
+		if p1 < 0.05 || p2 < 0.05 || p3 < 0.05 {
+			event_lable := "CutOutDifference"
+			fmt.Println(event_lable)
+			DriverSlice = [][]float64{{}, {}, {}}
+			AlgSlice = [][]float64{{}, {}, {}}
+
+		}
+
+	}
+
+}
+
+func CallbackCicvLocation(data *kinglong_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *kinglong_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 150 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+
+func CallbackDataRead(data *kinglong_msgs.Retrieval) {
+	DriverSlice[0] = append(DriverSlice[0], data.StrgAngleRealValue) //方向盘实际转角
+	DriverSlice[1] = append(DriverSlice[1], data.VcuAccelPosValue)   //实际加速踏板位置
+	DriverSlice[2] = append(DriverSlice[2], data.VcuBrkPelPosValue)  //实际制动踏板位置
+
+}
+
+func CallbackJinlongControlPub(data *kinglong_msgs.JinlongControlCommand) {
+	AlgSlice[0] = append(AlgSlice[0], data.ASStrgAngleReq)      //算法输出方向盘转角
+	AlgSlice[1] = append(AlgSlice[1], data.ASAutoDAccelPosReq)  //算法输出加速踏板位置
+	AlgSlice[2] = append(AlgSlice[2], data.ASAutoDBrkPelPosReq) //算法输出制动踏板位置
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subControl, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/jinlong_control_pub",
+		Callback: CallbackJinlongControlPub,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subControl.Close()
+
+	// create a subscriber
+	subDataRead, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/data_read",
+		Callback: CallbackDataRead,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subDataRead.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 205 - 0
main/kinglong/FollowDifference/main/FollowDifference.go

@@ -0,0 +1,205 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/kinglong_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"sort"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+	DriverSlice = [][]float64{{}, {}, {}}
+	AlgSlice    = [][]float64{{}, {}, {}}
+	StartTime   int64
+	FollowFlag  = false
+)
+
+func mannWhitneyU(x, y []float64) (float64, float64) {
+	n1 := len(x)
+	n2 := len(y)
+
+	combined := append(x, y...)
+	sort.Float64s(combined)
+
+	ranks := make(map[float64]float64)
+	for i := 0; i < len(combined); {
+		j := i
+		for j < len(combined) && combined[i] == combined[j] {
+			j++
+		}
+		rank := float64(i+j+1) / 2
+		for k := i; k < j; k++ {
+			ranks[combined[k]] = rank
+		}
+		i = j
+	}
+
+	r1 := sumRanks(x, ranks)
+	r2 := sumRanks(y, ranks)
+
+	u1 := r1 - float64(n1*(n1+1))/2
+	u2 := r2 - float64(n2*(n2+1))/2
+
+	u := math.Min(u1, u2)
+	meanU := float64(n1*n2) / 2
+	sdU := math.Sqrt(float64(n1*n2*(n1+n2+1)) / 12)
+
+	z := (u - meanU) / sdU
+	p := 2 * (1 - normCdf(math.Abs(z)))
+
+	return u, p
+}
+
+func sumRanks(arr []float64, ranks map[float64]float64) float64 {
+	sum := 0.0
+	for _, v := range arr {
+		sum += ranks[v]
+	}
+	return sum
+}
+
+func normCdf(x float64) float64 {
+	return 0.5 * (1 + math.Erf(x/math.Sqrt2))
+}
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func FinalCallback() {
+
+	if FollowFlag == true {
+		ObjectSlice = make(map[uint32][][]float32)
+		_, p1 := mannWhitneyU(DriverSlice[0], AlgSlice[0])
+		_, p2 := mannWhitneyU(DriverSlice[1], AlgSlice[1])
+		_, p3 := mannWhitneyU(DriverSlice[2], AlgSlice[2])
+		if p1 < 0.05 || p2 < 0.05 || p3 < 0.05 {
+			event_lable := "FollowDifference"
+			fmt.Println(event_lable)
+			DriverSlice = [][]float64{{}, {}, {}}
+			AlgSlice = [][]float64{{}, {}, {}}
+
+		}
+
+	}
+
+}
+
+func CallbackCicvLocation(data *kinglong_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *kinglong_msgs.PerceptionObjects) {
+	Framenum += 1
+	tempFlag := false
+	FollowFlag = false
+	for _, obj := range data.Objs {
+		if obj.X >= 5 && obj.X <= 50 && math.Abs(float64(obj.Y)) < 1.5 && (obj.Type == 1 || obj.Type == 0) {
+			tempFlag = true
+		}
+	}
+	if tempFlag {
+		if StartTime == 0 {
+			StartTime = time.Now().Unix()
+		}
+		if time.Now().Unix()-StartTime > 3 {
+			FollowFlag = true
+		}
+	} else {
+		StartTime = 0
+	}
+
+}
+
+func CallbackDataRead(data *kinglong_msgs.Retrieval) {
+	DriverSlice[0] = append(DriverSlice[0], data.StrgAngleRealValue) //方向盘实际转角
+	DriverSlice[1] = append(DriverSlice[1], data.VcuAccelPosValue)   //实际加速踏板位置
+	DriverSlice[2] = append(DriverSlice[2], data.VcuBrkPelPosValue)  //实际制动踏板位置
+
+}
+
+func CallbackJinlongControlPub(data *kinglong_msgs.JinlongControlCommand) {
+	AlgSlice[0] = append(AlgSlice[0], data.ASStrgAngleReq)      //算法输出方向盘转角
+	AlgSlice[1] = append(AlgSlice[1], data.ASAutoDAccelPosReq)  //算法输出加速踏板位置
+	AlgSlice[2] = append(AlgSlice[2], data.ASAutoDBrkPelPosReq) //算法输出制动踏板位置
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subControl, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/jinlong_control_pub",
+		Callback: CallbackJinlongControlPub,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subControl.Close()
+
+	// create a subscriber
+	subDataRead, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/data_read",
+		Callback: CallbackDataRead,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subDataRead.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 163 - 0
main/pji_DGNC/AbnormalParking/main/AbnormalParking.go

@@ -0,0 +1,163 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/geometry_msgs"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	param          entity.PjisuvParam
+	StartTime      int64
+	IsStopped      bool
+	IsEndPoint     bool
+	IsTrafficLight bool
+	count1         int64
+	//定义园区4个信号灯的坐标
+	point2 = Point{39.72975930689718, 116.48861102824081}
+	point3 = Point{39.7288805296616, 116.48812315228867}
+	point4 = Point{39.73061430369551, 116.49225103553502}
+	point5 = Point{39.73077491578002, 116.49060085035634}
+
+	EndPoint   = Point{0, 0}
+	pointlist1 = []Point{point2, point3, point4, point5}
+	pointlist2 = []Point{EndPoint}
+)
+
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//print(param.AutomodeOfPjVehicleFdbPub)
+	if count1%10 == 0 {
+		IsTrafficLight = IfEnter(pointlist1, 30.0, data.Latitude, data.Longitude)
+		IsEndPoint = IfEnter(pointlist2, 5.0, data.Latitude, data.Longitude)
+		if param.AutomodeOfPjVehicleFdbPub == 1 && !IsTrafficLight && !IsEndPoint {
+			if data.VelocityX < 0.5 {
+				// 如果之前没有记录开始时间,记录当前时间
+				if StartTime == 0 {
+					StartTime = time.Now().Unix()
+				}
+
+				// 判断是否持续超过一分钟
+				if time.Now().Unix()-StartTime > 3 {
+					if !IsStopped {
+						event_label := "AbnormalParking"
+						fmt.Println(event_label)
+						IsStopped = true
+					}
+				}
+			} else {
+				// 如果速度大于 0.1,重置开始时间和停止标志
+				StartTime = 0
+				IsStopped = false
+			}
+		}
+		count1 = 1
+	} else {
+		count1++
+	}
+}
+
+func CallbackPjVehicleFdbPub(data *pjisuv_msgs.VehicleFdb) {
+	param.AutomodeOfPjVehicleFdbPub = data.Automode
+}
+func CallbackEndPointMessage(data *geometry_msgs.Point) {
+	EndPoint.Longitude = data.X
+	EndPoint.Latitude = data.Y
+
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "pj_vehicle_fdb_pub",
+		Callback: CallbackPjVehicleFdbPub,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subEndPointMessage, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/end_point_message",
+		Callback: CallbackEndPointMessage,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subEndPointMessage.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 149 - 0
main/pji_DGNC/AbnormalStopOnCurve/main/AbnormalStopOnCurve.go

@@ -0,0 +1,149 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/geometry_msgs"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	IsStopped  bool
+	IsEndPoint bool
+	StartTime  int64
+	count      int   = 0
+	threshold  int64 = 3
+	//定义园区长弯道坐标点
+	EndPoint = Point{0, 0}
+	point3   = Point{39.73004426154644, 116.49248639463602}
+
+	pointlist  = []Point{point3}
+	pointlist2 = []Point{EndPoint}
+)
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+
+	if count%10 == 0 {
+		//fmt.Println(threshold)
+		enterflag := IfEnter(pointlist, 30, data.Latitude, data.Longitude)
+		if enterflag {
+			//fmt.Println("enterflag")
+			IsEndPoint = IfEnter(pointlist2, 5.0, data.Latitude, data.Longitude)
+			if !IsEndPoint {
+				//fmt.Println("!IsEndPoint")
+				AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+				if AbsSpeed < 0.5 {
+					// 如果之前没有记录开始时间,记录当前时间
+					if StartTime == 0 {
+						StartTime = time.Now().Unix()
+					}
+
+					// 判断是否持续超过一分钟
+					if time.Now().Unix()-StartTime > threshold {
+						if !IsStopped {
+							event_label := "AbnormalStopOnCurve"
+							fmt.Println(event_label)
+							IsStopped = true
+						}
+					}
+				} else {
+					// 如果速度大于 0.1,重置开始时间和停止标志
+					StartTime = 0
+					IsStopped = false
+				}
+			}
+
+		}
+		count = 0
+	}
+	count++
+
+}
+func IfEnter(pointlist []Point, radius float64, x, y float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: x, Longitude: y}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		//fmt.Println(d)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+func CallbackEndPointMessage(data *geometry_msgs.Point) {
+	EndPoint.Longitude = data.X
+	EndPoint.Latitude = data.Y
+
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subEndPointMessage, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/end_point_message",
+		Callback: CallbackEndPointMessage,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subEndPointMessage.Close()
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 155 - 0
main/pji_DGNC/AbnormalStopOnJunction/main/AbnormalStopOnJunction.go

@@ -0,0 +1,155 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/geometry_msgs"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	IsStopped  bool
+	IsEndPoint bool
+	StartTime  int64
+	count      int   = 0
+	threshold  int64 = 3
+	//定义园区T字路口的经纬度坐标值
+	point3 = Point{39.73040966605621, 116.48995329696209}
+	point4 = Point{39.73083727413453, 116.49079780188244}
+	point5 = Point{39.72976753711939, 116.49043130389033}
+	point6 = Point{39.73012466515933, 116.49128381717591}
+	point7 = Point{39.729251498328246, 116.49077484625299}
+	point8 = Point{39.72964529630643, 116.49164592200161}
+
+	PointJunctionList = []Point{point3, point4, point5, point6, point7, point8}
+	//定义园区长弯道坐标点
+	EndPoint   = Point{0, 0}
+	pointlist2 = []Point{EndPoint}
+)
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+
+	if count%10 == 0 {
+		//fmt.Println(threshold)
+		enterflag := IfEnter(PointJunctionList, 15, data.Latitude, data.Longitude)
+		if enterflag {
+			//fmt.Println("enterflag")
+			IsEndPoint = IfEnter(pointlist2, 5.0, data.Latitude, data.Longitude)
+			if !IsEndPoint {
+				//fmt.Println("!IsEndPoint")
+				AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+				if AbsSpeed < 0.5 {
+					// 如果之前没有记录开始时间,记录当前时间
+					if StartTime == 0 {
+						StartTime = time.Now().Unix()
+					}
+
+					// 判断是否持续超过一分钟
+					if time.Now().Unix()-StartTime > threshold {
+						if !IsStopped {
+							event_label := "AbnormalStopOnJunction"
+							fmt.Println(event_label)
+							IsStopped = true
+						}
+					}
+				} else {
+					// 如果速度大于 0.1,重置开始时间和停止标志
+					StartTime = 0
+					IsStopped = false
+				}
+			}
+
+		}
+		count = 0
+	}
+	count++
+
+}
+func IfEnter(pointlist []Point, radius float64, x, y float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: x, Longitude: y}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		//fmt.Println(d)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+func CallbackEndPointMessage(data *geometry_msgs.Point) {
+	EndPoint.Longitude = data.X
+	EndPoint.Latitude = data.Y
+
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subEndPointMessage, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/end_point_message",
+		Callback: CallbackEndPointMessage,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subEndPointMessage.Close()
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 93 - 0
main/pji_DGNC/AuLongStop/main/AuLongStop.go

@@ -0,0 +1,93 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param     entity.PjisuvParam
+	StartTime int64
+	IsStopped bool
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//print(param.AutomodeOfPjVehicleFdbPub)
+	if param.AutomodeOfPjVehicleFdbPub == 1 {
+		if data.VelocityX < 0.5 {
+			// 如果之前没有记录开始时间,记录当前时间
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+
+			// 判断是否持续超过一分钟
+			if time.Now().Unix()-StartTime > 10 {
+				if !IsStopped {
+					event_label := "AuLongStop"
+					fmt.Println(event_label)
+					IsStopped = true
+				}
+			}
+		} else {
+			// 如果速度大于 0.1,重置开始时间和停止标志
+			StartTime = 0
+			//is_stopped = false
+		}
+	}
+}
+
+func CallbackPjVehicleFdbPub(data *pjisuv_msgs.VehicleFdb) {
+	param.AutomodeOfPjVehicleFdbPub = data.Automode
+
+}
+
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "pj_vehicle_fdb_pub",
+		Callback: CallbackPjVehicleFdbPub,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 169 - 0
main/pji_DGNC/BeOvertakenInCurve/main/BeOvertakenInCurve.go

@@ -0,0 +1,169 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+	pointcurve  = Point{39.73004426154644, 116.49248639463602}
+	pointlist1  = []Point{pointcurve}
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func IsOvertaken(ObjectList [][]float32) bool {
+	if param.AbsSpeed > 0.2 {
+		//fmt.Println("yes")
+		//fmt.Println(ObjectList)
+		for i, objX := range ObjectList[0] {
+
+			if math.Abs(float64(ObjectList[1][i])) <= 8 && objX <= -2 {
+				for j := 0; j < len(ObjectList[0])-i-1; j++ {
+					if math.Abs(float64(ObjectList[1][1+i+j])) <= 8 && ObjectList[0][1+i+j] >= 2.5 {
+						return true
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+	if IfEnter(pointlist1, 50, param.LatitudeOfCicvLocation, param.LongitudeOfCicvLocation) {
+		//fmt.Println("here")
+		for _, objValue := range ObjectSlice {
+			//fmt.Println(ObjectSlice)
+			//fmt.Println(objValue)
+			//fmt.Println("------------------------------------------------")
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+			if len(objValue[0]) <= 5 || !IsOvertaken(objValue) {
+				continue
+			}
+			event_lable := "BeOvertakenInCurve"
+			fmt.Println(event_lable)
+		}
+	}
+	//fmt.Println(Maxlenobj)
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+func max(a, b int32) int32 {
+	if a > b {
+		return a
+	}
+	return b
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 50 || math.Abs(float64(obj.Y)) >= 60 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		//ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 125 - 0
main/pji_DGNC/BeOvertakenWithHighSpeed/main/BeOvertakenWithHighSpeed.go

@@ -0,0 +1,125 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	threshold   float64 = 5.55
+	Maxlenobj   int32   = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func IsOvertaken(ObjectList [][]float32) bool {
+	for i, objX := range ObjectList[0] {
+
+		if math.Abs(float64(ObjectList[1][i])) <= 4 && objX <= -2 {
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 4 && ObjectList[0][1+i+j] >= 2.5 {
+					return true
+				}
+			}
+		}
+	}
+
+	return false
+}
+func FinalCallback() {
+
+	if param.AbsSpeed >= threshold {
+		for _, objValue := range ObjectSlice {
+			//fmt.Println(ObjectSlice)
+			//fmt.Println(objValue)
+			//fmt.Println("------------------------------------------------")
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+			if len(objValue[0]) <= 5 || !IsOvertaken(objValue) {
+				continue
+			}
+			event_lable := "BeOvertakenWithHighSpeed"
+			fmt.Println(event_lable)
+		}
+	}
+	if Maxlenobj >= 120 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 50 || math.Abs(float64(obj.Y)) >= 60 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		//ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 174 - 0
main/pji_DGNC/CBFA/main/CBFA.go

@@ -0,0 +1,174 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func findIndex(lst []float32, target float32) int {
+	for i, v := range lst {
+		if v == target {
+			return i
+		}
+	}
+	return -1
+}
+
+func isCrossAndOcclusion(id uint32, ObjectList [][]float32, ObjectSlice map[uint32][][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+		Type := ObjectList[4][0]
+		//if xi >= 0 && yi >= 3 && diff_hi <= 120 && diff_hi >= 60 && Type == 4.0 { //理论条件
+		if xi >= 0 && yi >= 3 && diff_hi >= 0 && Type != 100.0 { //简化条件
+			startFrame1 := ObjectList[3][i]
+
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				//if xj >= 0 && xj >= 30 && xj <= 50 && yj <= -1 && diff_hj <= 120 && diff_hj >= 60 { //理论条件
+				if xj >= 0 && xj >= 20 && xj <= 50 && yj <= -1 && diff_hj >= 0 { //简化条件
+					startFrame2 := ObjectList[3][j]
+					for this_id, objValue := range ObjectSlice {
+						if this_id != id {
+							this_startFrame_index1 := findIndex(objValue[3], startFrame1)
+							this_startFrame_index2 := findIndex(objValue[3], startFrame2)
+							this_type := objValue[4][0]
+							if this_startFrame_index1 != -1 && this_startFrame_index2 != -1 {
+								//fmt.Println("this_startFrame_index1=", this_startFrame_index1, "this_startFrame_index2=", this_startFrame_index2, "len(objValue[0])=", len(objValue[0]))
+								//fmt.Println(objValue[0][this_startFrame_index2], xj)
+								//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) { //理论条件
+								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 != 100.0) { //简化条件
+									return true
+								}
+							}
+						} else {
+							continue
+						}
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for id, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCrossAndOcclusion(id, objValue, ObjectSlice) {
+			continue
+		}
+		event_lable := "CBFA"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 150 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)   // 创建一个带缓冲区的信号通道
+	signal.Notify(c, os.Interrupt) // 注册信号处理器
+	<-c                            // 阻塞等待信号
+}

+ 81 - 0
main/pji_DGNC/CBLA/main/CBLA.go

@@ -0,0 +1,81 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	param     entity.PjisuvParam
+	StartTime int64
+	IsFollow  bool
+)
+
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		fmt.Println("ID=", obj.Id, "Type=", obj.Type)
+		if obj.Type == 4 && obj.X >= 2 && obj.X <= 20 && math.Abs(float64(obj.Y)) <= 1.2 {
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+
+			// 判断是否持续超过5S
+			if time.Now().Unix()-StartTime > 5 {
+				if !IsFollow {
+					event_label := "CBLA"
+					fmt.Println(event_label)
+					IsFollow = true
+				}
+			}
+		} else {
+			StartTime = 0
+			IsFollow = false
+		}
+	}
+
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subEndPointMessage, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subEndPointMessage.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 173 - 0
main/pji_DGNC/CBNA/main/CBNA.go

@@ -0,0 +1,173 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func findIndex(lst []float32, target float32) int {
+	for i, v := range lst {
+		if v == target {
+			return i
+		}
+	}
+	return -1
+}
+
+func isCrossAndOcclusion(id uint32, ObjectList [][]float32, ObjectSlice map[uint32][][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+		Type := ObjectList[4][0]
+		//if xi >= 0 && yi <= -3 && diff_hi <= 120 && diff_hi >= 60 && Type == 4.0 {//理论条件
+		if xi >= 0 && yi <= -3 && diff_hi >= 0 && Type != 100.0 { //简化条件
+			startFrame1 := ObjectList[3][i]
+
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				//if xj >= 0 && xj <= 25 && yj >= 1 && diff_hj <= 120 && diff_hj >= 60 {//理论条件
+				if xj >= 0 && xj <= 25 && yj >= 1 && diff_hj >= 0 { //简化条件
+					startFrame2 := ObjectList[3][j]
+					for this_id, objValue := range ObjectSlice {
+						if this_id != id {
+							this_startFrame_index1 := findIndex(objValue[3], startFrame1)
+							this_startFrame_index2 := findIndex(objValue[3], startFrame2)
+							this_type := objValue[4][0]
+							//fmt.Println(objValue[0][this_startFrame_index2], xj)
+							if this_startFrame_index1 != -1 && this_startFrame_index2 != -1 {
+								//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) {//理论条件
+								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 != 100.0) { //简化条件
+									return true
+								}
+							}
+						} else {
+							continue
+						}
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for id, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCrossAndOcclusion(id, objValue, ObjectSlice) {
+			continue
+		}
+		event_lable := "CBNA"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 173 - 0
main/pji_DGNC/CBNAO/main/CBNAO.go

@@ -0,0 +1,173 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func findIndex(lst []float32, target float32) int {
+	for i, v := range lst {
+		if v == target {
+			return i
+		}
+	}
+	return -1
+}
+
+func isCrossAndOcclusion(id uint32, ObjectList [][]float32, ObjectSlice map[uint32][][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+		Type := ObjectList[4][0]
+		//if xi >= 0 && yi <= -3 && diff_hi <= 120 && diff_hi >= 60 && Type == 4.0 {//理论条件
+		if xi >= 0 && yi <= -3 && diff_hi >= 0 && Type != 100.0 { //简化条件
+			startFrame1 := ObjectList[3][i]
+
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				//if xj >= 0 && xj <= 25 && yj >= 1 && diff_hj <= 120 && diff_hj >= 60 { //理论条件
+				if xj >= 0 && xj <= 25 && yj >= 1 && diff_hj >= 0 { //简化条件
+					startFrame2 := ObjectList[3][j]
+					for this_id, objValue := range ObjectSlice {
+						if this_id != id {
+							this_startFrame_index1 := findIndex(objValue[3], startFrame1)
+							this_startFrame_index2 := findIndex(objValue[3], startFrame2)
+							this_type := objValue[4][0]
+							//fmt.Println(objValue[0][this_startFrame_index2], xj)
+							if this_startFrame_index1 != -1 && this_startFrame_index2 != -1 {
+								//if objValue[0][this_startFrame_index1] >= 2 && objValue[0][this_startFrame_index1] < xi-5 && objValue[1][this_startFrame_index1] < 0 && objValue[1][this_startFrame_index1] > yi && objValue[0][this_startFrame_index2] >= 1 && objValue[0][this_startFrame_index2] < xj-3 && objValue[1][this_startFrame_index2] < 0 && (this_type == 2.0 || this_type == 3.0) { //理论条件
+								if objValue[0][this_startFrame_index1] >= 2 && objValue[0][this_startFrame_index1] < xi-5 && objValue[1][this_startFrame_index1] < 0 && objValue[1][this_startFrame_index1] > yi && objValue[0][this_startFrame_index2] >= 1 && objValue[0][this_startFrame_index2] < xj-3 && objValue[1][this_startFrame_index2] < 0 && (this_type != 100.0) { //简化条件
+									return true
+								}
+							}
+						} else {
+							continue
+						}
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for id, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCrossAndOcclusion(id, objValue, ObjectSlice) {
+			continue
+		}
+		event_lable := "CBNAO"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 126 - 0
main/pji_DGNC/CBTA_f/main/CBTA_f.go

@@ -0,0 +1,126 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	LeftCurveFlag  = false
+	RightCurveFlag = false
+	param          entity.PjisuvParam
+)
+
+func main() {
+
+	go listener()
+	for {
+		select {}
+	}
+}
+
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	if LeftCurveFlag == true {
+		for _, obj := range data.Objs {
+			//if obj.Type == 4 {//理论条件
+			if obj.Type != 100 { //简化条件
+				Distance := math.Sqrt(math.Pow(param.PositionXOfCicvLocation-obj.Xabs, 2) + math.Pow(param.PositionYOfCicvLocation-obj.Yabs, 2))
+				Objspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2) + math.Pow(float64(obj.Vyabs), 2))
+
+				//fmt.Println("Distance:", Distance)
+				if obj.X >= 2.0 && obj.X <= 40.0 && Distance <= 40.0 && Objspeed > 0.5 {
+					event_lable := "CBTA_f"
+					fmt.Println(event_lable)
+					break
+				}
+			}
+		}
+	}
+}
+func CallbackTrajectory(data *pjisuv_msgs.Trajectory) {
+	Trajectorypoints := data.Trajectoryinfo.Trajectorypoints
+	if len(Trajectorypoints) > 2 {
+		StartHeading := Trajectorypoints[0].Heading
+		EndHeading := Trajectorypoints[len(Trajectorypoints)-1].Heading
+		diffHeading := StartHeading - EndHeading
+		//fmt.Println(diffHeading)
+
+		if diffHeading < -1.0 && diffHeading > -3.0 {
+			LeftCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			LeftCurveFlag = false
+		}
+		if diffHeading > 1.0 && diffHeading < 3.0 {
+			RightCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			RightCurveFlag = false
+		}
+
+	} else {
+		LeftCurveFlag = false
+		RightCurveFlag = false
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.PositionXOfCicvLocation = data.PositionX
+	param.PositionYOfCicvLocation = data.PositionY
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subTrajectory, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/cicv_amr_trajectory",
+		Callback: CallbackTrajectory,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTrajectory.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 129 - 0
main/pji_DGNC/CBTA_n/main/CBTA_n.go

@@ -0,0 +1,129 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	LeftCurveFlag  = false
+	RightCurveFlag = false
+	param          entity.PjisuvParam
+)
+
+func main() {
+
+	go listener()
+	for {
+		select {}
+	}
+}
+
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	if RightCurveFlag == true {
+		for _, obj := range data.Objs {
+			//if obj.Type == 4 {//理论条件
+			if obj.Type != 100 { //简化条件
+				Distance := math.Sqrt(math.Pow(param.PositionXOfCicvLocation-obj.Xabs, 2) + math.Pow(param.PositionYOfCicvLocation-obj.Yabs, 2))
+				Objspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2) + math.Pow(float64(obj.Vyabs), 2))
+
+				//fmt.Println("Distance:", Distance)
+
+				//fmt.Println("Objspeed:", Objspeed)
+
+				if obj.X >= 2.0 && Distance <= 35.0 && Objspeed > 0.7 {
+					event_lable := "CBTA_n"
+					fmt.Println(event_lable)
+					break
+				}
+			}
+		}
+	}
+}
+func CallbackTrajectory(data *pjisuv_msgs.Trajectory) {
+	Trajectorypoints := data.Trajectoryinfo.Trajectorypoints
+	if len(Trajectorypoints) > 2 {
+		StartHeading := Trajectorypoints[0].Heading
+		EndHeading := Trajectorypoints[len(Trajectorypoints)-1].Heading
+		diffHeading := StartHeading - EndHeading
+		//fmt.Println(diffHeading)
+
+		if diffHeading < -1.0 && diffHeading > -3.0 {
+			LeftCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			LeftCurveFlag = false
+		}
+		if diffHeading > 1.0 && diffHeading < 3.0 {
+			RightCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			RightCurveFlag = false
+		}
+
+	} else {
+		LeftCurveFlag = false
+		RightCurveFlag = false
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.PositionXOfCicvLocation = data.PositionX
+	param.PositionYOfCicvLocation = data.PositionY
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subTrajectory, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/cicv_amr_trajectory",
+		Callback: CallbackTrajectory,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTrajectory.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 151 - 0
main/pji_DGNC/CCCscp_f/main/CCCscp_f.go

@@ -0,0 +1,151 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCross(ObjectList [][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		Type := ObjectList[4][0]
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+		if xi >= 0 && yi >= 2 && diff_hi > 0 && Type != 100.0 { //简化条件
+			//if xi >= 0 && yi >= 2 && diff_hi <= 120 && diff_hi >= 60 && Type != 1.0 {//理论条件
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				if xj >= 0 && yj <= -2 && diff_hj > 0 { //简化条件
+					//if xj >= 0 && yj <= -2 && diff_hj <= 120 && diff_hj >= 60 {//理论条件
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCross(objValue) {
+			continue
+		}
+		event_lable := "CCCscp_f"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	//fmt.Println(len(data.Objs))
+	for _, obj := range data.Objs {
+		//fmt.Println("ID", obj.Id, "Type", obj.Type)
+
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		//fmt.Println(diffh)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 149 - 0
main/pji_DGNC/CCCscp_n/main/CCCscp_n.go

@@ -0,0 +1,149 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCross(ObjectList [][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		Type := ObjectList[4][0]
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+
+		if xi >= 0 && yi <= -2 && diff_hi >= 0 && Type != 100.0 { //简化条件
+			//if xi >= 0 && yi <= -2 && diff_hi <= 120 && diff_hi >= 60 && Type != 1.0 {//理论条件
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				//if xj >= 0 && yj >= 2 && diff_hj <= 120 && diff_hj >= 60{//理论条件
+				if xj >= 0 && yj >= 0 && diff_hj >= 0 { //简化条件
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCross(objValue) {
+			continue
+		}
+		event_lable := "CCCscp_n"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 150 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 172 - 0
main/pji_DGNC/CCCscpo/main/CCCscpo.go

@@ -0,0 +1,172 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func findIndex(lst []float32, target float32) int {
+	for i, v := range lst {
+		if v == target {
+			return i
+		}
+	}
+	return -1
+}
+
+func isCrossAndOcclusion(id uint32, ObjectList [][]float32, ObjectSlice map[uint32][][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+		Type := ObjectList[4][0]
+
+		if xi >= 0 && yi <= -3 && diff_hi <= 120 && diff_hi >= 60 && Type != 1.0 {
+			startFrame1 := ObjectList[3][i]
+
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				if xj >= 0 && yj >= 1 && diff_hj <= 120 && diff_hj >= 60 {
+					startFrame2 := ObjectList[3][j]
+					for this_id, objValue := range ObjectSlice {
+						if this_id != id {
+
+							this_startFrame_index1 := findIndex(objValue[3], startFrame1)
+							this_startFrame_index2 := findIndex(objValue[3], startFrame2)
+							this_type := objValue[4][0]
+							//fmt.Println(objValue[0][this_startFrame_index2], xj)
+							if this_startFrame_index1 != -1 && this_startFrame_index2 != -1 {
+								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) {
+									return true
+								}
+							}
+						} else {
+							continue
+						}
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for id, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCrossAndOcclusion(id, objValue, ObjectSlice) {
+			continue
+		}
+		event_lable := "CCCscp_n"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 146 - 0
main/pji_DGNC/CCFhos/main/CCFhos.go

@@ -0,0 +1,146 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isRetrograde(ObjectList [][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		xi := ObjectList[0][i]
+		yi := math.Abs(float64(ObjectList[1][i]))
+		diff_hi := ObjectList[2][i]
+		Type := ObjectList[4][0]
+
+		if xi >= 20 && yi <= 1.2 && diff_hi > 150 && Type != 1.0 {
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := math.Abs(float64(ObjectList[1][j]))
+				diff_hj := ObjectList[2][j]
+
+				if xj <= 8 && yj <= 1.2 && diff_hj > 150 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isRetrograde(objValue) {
+			continue
+		}
+		event_lable := "CCFhos"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 125 - 0
main/pji_DGNC/CCFtap/main/CCFtap.go

@@ -0,0 +1,125 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	LeftCurveFlag  = false
+	RightCurveFlag = false
+	param          entity.PjisuvParam
+)
+
+func main() {
+
+	go listener()
+	for {
+		select {}
+	}
+}
+
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	if LeftCurveFlag == true {
+		for _, obj := range data.Objs {
+			if obj.Type != 100 { //简化条件
+				//if obj.Type == 2 || obj.Type == 3 {//理论条件
+				absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2) + math.Pow(float64(obj.Vyabs), 2))
+				Distance := math.Sqrt(math.Pow(param.PositionXOfCicvLocation-obj.Xabs, 2) + math.Pow(param.PositionYOfCicvLocation-obj.Yabs, 2))
+				//fmt.Println("Distance:", Distance)
+				if obj.X >= 2.0 && obj.X <= 15.0 && (math.Abs(float64(obj.Y)) <= 4.0 || Distance <= 15.0) && absspeed > 1.5 {
+					event_lable := "CCFtap"
+					fmt.Println(event_lable)
+					break
+				}
+			}
+		}
+	}
+}
+func CallbackTrajectory(data *pjisuv_msgs.Trajectory) {
+	Trajectorypoints := data.Trajectoryinfo.Trajectorypoints
+	if len(Trajectorypoints) > 2 {
+		StartHeading := Trajectorypoints[0].Heading
+		EndHeading := Trajectorypoints[len(Trajectorypoints)-1].Heading
+		diffHeading := StartHeading - EndHeading
+		//fmt.Println(diffHeading)
+
+		if diffHeading < -1.0 && diffHeading > -3.0 {
+			LeftCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			LeftCurveFlag = false
+		}
+		if diffHeading > 1.0 && diffHeading < 3.0 {
+			RightCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			RightCurveFlag = false
+		}
+
+	} else {
+		LeftCurveFlag = false
+		RightCurveFlag = false
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.PositionXOfCicvLocation = data.PositionX
+	param.PositionYOfCicvLocation = data.PositionY
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subTrajectory, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/cicv_amr_trajectory",
+		Callback: CallbackTrajectory,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTrajectory.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 145 - 0
main/pji_DGNC/CCRH/main/CCRH.go

@@ -0,0 +1,145 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingOut(ObjectList [][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		xi := ObjectList[0][i]
+		yi := math.Abs(float64(ObjectList[1][i]))
+		Type := ObjectList[4][0]
+		if xi >= 0 && yi <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && (Type != 100.0) { //简化条件
+			//if xi >= 0 && yi <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && (Type == 2.0 || Type == 3.0) {//理论条件
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := math.Abs(float64(ObjectList[1][j]))
+
+				if xj >= 0 && yj >= 2.0 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCuttingOut(objValue) {
+			continue
+		}
+		event_lable := "CCRH"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 76 - 0
main/pji_DGNC/CPLA/main/CPLA.go

@@ -0,0 +1,76 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param     entity.PjisuvParam
+	StartTime int64
+	IsFollow  bool
+)
+
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		//if obj.Type == 1 && obj.X >= 2 && obj.X <= 20 && math.Abs(float64(obj.Y)) <= 1.2 {//理论条件
+		if obj.Type != 100 && obj.X >= 2 && obj.X <= 20 && math.Abs(float64(obj.Y)) <= 1.2 { //简化条件
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+
+			// 判断是否持续超过一分钟
+			if time.Now().Unix()-StartTime > 5 {
+				if !IsFollow {
+					event_label := "CPLA"
+					fmt.Println(event_label)
+					IsFollow = true
+				}
+			}
+		} else {
+			StartTime = 0
+			IsFollow = false
+		}
+	}
+
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subEndPointMessage, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subEndPointMessage.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 173 - 0
main/pji_DGNC/CPNCO/main/CPNCO.go

@@ -0,0 +1,173 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func findIndex(lst []float32, target float32) int {
+	for i, v := range lst {
+		if v == target {
+			return i
+		}
+	}
+	return -1
+}
+
+func isCrossAndOcclusion(id uint32, ObjectList [][]float32, ObjectSlice map[uint32][][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+		Type := ObjectList[4][0]
+		//if xi >= 0 && yi <= -3 && diff_hi <= 120 && diff_hi >= 60 && Type == 1.0 { //理论条件
+		if xi >= 0 && yi <= -2 && diff_hi >= 0 && Type != 100.0 { //简化条件
+			startFrame1 := ObjectList[3][i]
+
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				//if xj >= 0 && yj >= 1 && diff_hj <= 120 && diff_hj >= 60 {//理论条件
+				if xj >= 0 && yj >= 1 && diff_hj >= 0 { //简化条件
+					startFrame2 := ObjectList[3][j]
+					for this_id, objValue := range ObjectSlice {
+						if this_id != id {
+							this_startFrame_index1 := findIndex(objValue[3], startFrame1)
+							this_startFrame_index2 := findIndex(objValue[3], startFrame2)
+							this_type := objValue[4][0]
+							if this_startFrame_index1 != -1 && this_startFrame_index2 != -1 {
+								//fmt.Println(objValue[0][this_startFrame_index2], xj)
+								//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) {//理论条件
+								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 != 100) { // 简化条件
+									return true
+								}
+							}
+						} else {
+							continue
+						}
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for id, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCrossAndOcclusion(id, objValue, ObjectSlice) {
+			continue
+		}
+		event_lable := "CPNCO"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 148 - 0
main/pji_DGNC/CPRm_f/main/CPRm_f.go

@@ -0,0 +1,148 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice         = make(map[uint32][][]float32)
+	threshold   float32 = 20
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCross(ObjectList [][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		Type := ObjectList[4][0]
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+		if xi >= threshold && yi >= 1 && diff_hi >= 0 && Type != 100.0 { //简化条件
+			//if xi >= threshold && yi >= 2 && diff_hi <= 120 && diff_hi >= 60 && Type == 1.0 {//理论条件
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				//if xj >= threshold && yj <= -2 && diff_hj <= 120 && diff_hj >= 60 { //理论条件
+				if xj >= threshold && yj <= -1 && diff_hj >= 0 { //简化条件
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCross(objValue) {
+			continue
+		}
+		event_lable := "CPRm_f"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 148 - 0
main/pji_DGNC/CPRm_n/main/CPRm_n.go

@@ -0,0 +1,148 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Framenum    int64 = 0
+	param       entity.PjisuvParam
+	ObjectSlice         = make(map[uint32][][]float32)
+	threshold   float32 = 35
+)
+
+func main() {
+	ticker := time.NewTicker(5 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCross(ObjectList [][]float32) bool {
+	for i := 0; i < len(ObjectList[0]); i++ {
+		Type := ObjectList[4][0]
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		diff_hi := ObjectList[2][i]
+		//if xi >= 0 && xi <= threshold && yi <= -2 && diff_hi <= 120 && diff_hi >= 60 && Type == 1.0 {理论条件
+		if xi >= 0 && xi <= threshold && yi <= -1.0 && diff_hi >= 0 && Type != 100.0 { //简化条件
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				xj := ObjectList[0][j]
+				yj := ObjectList[1][j]
+				diff_hj := ObjectList[2][j]
+				// if xj >= 0 && xj <= threshold && yj >= 2 && diff_hj <= 120 && diff_hj >= 60{ 理论条件
+				if xj >= 0 && xj <= threshold && yj >= 1 && diff_hj >= 0 {
+					return true
+				} //简化条件
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+
+		if len(objValue[0]) <= 10 || !isCross(objValue) {
+			continue
+		}
+		event_lable := "CPRm_n"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	Framenum += 1
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 80 || math.Abs(float64(obj.Y)) >= 30 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}, {}}
+		}
+		//absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		diffh := (float64(obj.Heading - float32(param.YawOfCicvLocation)))
+		if diffh < -180.0 {
+			diffh = 360.0 + diffh
+		} else if diffh > 180.0 {
+			diffh = 360.0 - diffh
+		} else {
+			diffh = math.Abs(diffh)
+		}
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], float32(diffh))
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(Framenum))
+		ObjectSlice[obj.Id][4] = append(ObjectSlice[obj.Id][4], float32(obj.Type))
+
+		//ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+		if len(ObjectSlice[obj.Id][0]) >= 200 {
+			ObjectSlice[obj.Id][0] = ObjectSlice[obj.Id][0][1:]
+			ObjectSlice[obj.Id][1] = ObjectSlice[obj.Id][1][1:]
+			ObjectSlice[obj.Id][2] = ObjectSlice[obj.Id][2][1:]
+			ObjectSlice[obj.Id][3] = ObjectSlice[obj.Id][3][1:]
+			ObjectSlice[obj.Id][4] = ObjectSlice[obj.Id][4][1:]
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 126 - 0
main/pji_DGNC/CPTA_f/main/CPTA_f.go

@@ -0,0 +1,126 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	LeftCurveFlag  = false
+	RightCurveFlag = false
+	param          entity.PjisuvParam
+)
+
+func main() {
+
+	go listener()
+	for {
+		select {}
+	}
+}
+
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	if LeftCurveFlag == true {
+		for _, obj := range data.Objs {
+			//if obj.Type == 1 { //理论条件
+			if obj.Type != 100 { //简化条件
+				Distance := math.Sqrt(math.Pow(param.PositionXOfCicvLocation-obj.Xabs, 2) + math.Pow(param.PositionYOfCicvLocation-obj.Yabs, 2))
+				Objspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2) + math.Pow(float64(obj.Vyabs), 2))
+
+				//fmt.Println("Distance:", Distance)
+				if obj.X >= 2.0 && obj.X <= 30.0 && Distance <= 25.0 && Objspeed >= 0.7 {
+					event_lable := "CPTA_f"
+					fmt.Println(event_lable)
+					break
+				}
+			}
+		}
+	}
+}
+func CallbackTrajectory(data *pjisuv_msgs.Trajectory) {
+	Trajectorypoints := data.Trajectoryinfo.Trajectorypoints
+	if len(Trajectorypoints) > 2 {
+		StartHeading := Trajectorypoints[0].Heading
+		EndHeading := Trajectorypoints[len(Trajectorypoints)-1].Heading
+		diffHeading := StartHeading - EndHeading
+		//fmt.Println(diffHeading)
+
+		if diffHeading < -1.0 && diffHeading > -3.0 {
+			LeftCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			LeftCurveFlag = false
+		}
+		if diffHeading > 1.0 && diffHeading < 3.0 {
+			RightCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			RightCurveFlag = false
+		}
+
+	} else {
+		LeftCurveFlag = false
+		RightCurveFlag = false
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.PositionXOfCicvLocation = data.PositionX
+	param.PositionYOfCicvLocation = data.PositionY
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subTrajectory, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/cicv_amr_trajectory",
+		Callback: CallbackTrajectory,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTrajectory.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 126 - 0
main/pji_DGNC/CPTA_n/main/CPTA_n.go

@@ -0,0 +1,126 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	LeftCurveFlag  = false
+	RightCurveFlag = false
+	param          entity.PjisuvParam
+)
+
+func main() {
+
+	go listener()
+	for {
+		select {}
+	}
+}
+
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	if RightCurveFlag == true {
+		for _, obj := range data.Objs {
+			//if obj.Type == 1 { //理论条件
+			if obj.Type != 100 { //简化条件
+				Distance := math.Sqrt(math.Pow(param.PositionXOfCicvLocation-obj.Xabs, 2) + math.Pow(param.PositionYOfCicvLocation-obj.Yabs, 2))
+				Objspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2) + math.Pow(float64(obj.Vyabs), 2))
+
+				//fmt.Println("Distance:", Distance)
+				if obj.X >= 2.0 && obj.X <= 30.0 && Distance <= 20.0 && Objspeed >= 0.5 {
+					event_lable := "CPTA_n"
+					fmt.Println(event_lable)
+					break
+				}
+			}
+		}
+	}
+}
+func CallbackTrajectory(data *pjisuv_msgs.Trajectory) {
+	Trajectorypoints := data.Trajectoryinfo.Trajectorypoints
+	if len(Trajectorypoints) > 2 {
+		StartHeading := Trajectorypoints[0].Heading
+		EndHeading := Trajectorypoints[len(Trajectorypoints)-1].Heading
+		diffHeading := StartHeading - EndHeading
+		//fmt.Println(diffHeading)
+
+		if diffHeading < -1.0 && diffHeading > -3.0 {
+			LeftCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			LeftCurveFlag = false
+		}
+		if diffHeading > 1.0 && diffHeading < 3.0 {
+			RightCurveFlag = true
+			//fmt.Println(diffHeading)
+		} else {
+			RightCurveFlag = false
+		}
+
+	} else {
+		LeftCurveFlag = false
+		RightCurveFlag = false
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.PositionXOfCicvLocation = data.PositionX
+	param.PositionYOfCicvLocation = data.PositionY
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// create a subscriber
+	subTrajectory, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/cicv_amr_trajectory",
+		Callback: CallbackTrajectory,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTrajectory.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 97 - 0
main/pji_DGNC/Cadence/main/Cadence.go

@@ -0,0 +1,97 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"os"
+	"os/signal"
+	"time"
+)
+
+// 触发器名称是顿挫
+var (
+	param       entity.PjisuvParam
+	threshold   = 0.04
+	AccelXSlice = []float64{}
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func countChanges(slice []float64) int {
+	count := 0
+lable1:
+	for i := 0; i < len(slice); {
+		if slice[i] <= -threshold || slice[i] > threshold {
+			for j := 0; j < len(slice)-i-1; j++ {
+				if (slice[i] <= -threshold && slice[1+i+j] >= threshold) || (slice[i] >= threshold && slice[1+i+j] <= -threshold) {
+					count++
+					i = i + j + 1
+					continue lable1
+				}
+			}
+			break lable1
+		} else {
+			i++
+		}
+
+	}
+	return count
+}
+
+func FinalCallback() {
+	count := countChanges(AccelXSlice)
+	//fmt.Println(AccelXSlice)
+	if count >= 3 {
+
+		event_lable := "Cadence"
+		fmt.Println(event_lable)
+	}
+	if len(AccelXSlice) >= 600 {
+		AccelXSlice = []float64{}
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//AbsAccel := math.Sqrt(math.Pow(data.AccelX, 2) + math.Pow(data.AccelY, 2))
+	AccelXSlice = append(AccelXSlice, data.AccelX)
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 126 - 0
main/pji_DGNC/CannotBypassObstacles/main/CannotBypassObstacles.go

@@ -0,0 +1,126 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	param          entity.PjisuvParam
+	StartTime      int64
+	IsStopped      bool
+	IsEndPoint     bool
+	IsTrafficLight bool
+	count1         int64
+	ObjectSlice    = make(map[uint32][][]float32)
+)
+
+func IfObstaclesNearby() bool {
+	for _, obj := range ObjectSlice {
+		if obj[0][len(obj[0])-1] <= 13 && obj[0][len(obj[0])-1] >= 3 && (math.Abs(float64(obj[1][len(obj[1])-1]))) <= 6 {
+			return true
+
+		}
+	}
+	return false
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//print(param.AutomodeOfPjVehicleFdbPub)
+
+	if count1%10 == 0 {
+		AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+		flag := IfObstaclesNearby()
+		//fmt.Println(ObjectSlice)
+		if AbsSpeed < 0.5 && flag {
+			// 如果之前没有记录开始时间,记录当前时间
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+
+			// 判断是否持续超过一分钟
+			if time.Now().Unix()-StartTime > 3 {
+				if !IsStopped {
+					event_label := "CannotBypassObstacles "
+					fmt.Println(event_label)
+					IsStopped = true
+				}
+			}
+		} else {
+			// 如果速度大于 0.1,重置开始时间和停止标志
+			StartTime = 0
+			IsStopped = false
+		}
+
+		count1 = 1
+	} else {
+		count1++
+	}
+}
+
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= -2 || math.Abs(float64(obj.Y)) >= 90 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 126 - 0
main/pji_DGNC/CarFollowingTooCloseAtNight/main/CarFollowingTooCloseAtNight.go

@@ -0,0 +1,126 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param       entity.PjisuvParam
+	StartTime   int64
+	count1      int64
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func Ifatnight() bool {
+	// 获取当前时间
+	now := time.Now()
+	later := now.Add(0 * time.Hour)
+	// 获取当前小时
+	hour := later.Hour()
+	// 判断当前时间是白天还是夜晚
+	if hour >= 0 && hour < 5 || hour >= 20 && hour <= 23 {
+		return true
+	} else {
+		return false
+	}
+}
+func IfObstaclesNearby() bool {
+	for _, obj := range ObjectSlice {
+		if obj[0][len(obj[0])-1] <= 13 && obj[0][len(obj[0])-1] >= 3 && (math.Abs(float64(obj[1][len(obj[1])-1]))) <= 6 {
+			return true
+
+		}
+	}
+	return false
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//print(param.AutomodeOfPjVehicleFdbPub)
+
+	if count1%10 == 0 && Ifatnight() {
+		AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+		flag := IfObstaclesNearby()
+		//fmt.Println(ObjectSlice)
+		if AbsSpeed >= 1 && flag {
+			// 如果之前没有记录开始时间,记录当前时间
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+			// 判断是否持续超过一分钟
+			if time.Now().Unix()-StartTime > 3 {
+				event_label := "CarFollowingTooCloseAtNight"
+				fmt.Println(event_label)
+			}
+		} else {
+			// 如果速度大于 0.1,重置开始时间和停止标志
+			StartTime = 0
+		}
+		count1 = 1
+	} else {
+		count1++
+	}
+}
+
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= -2 || math.Abs(float64(obj.Y)) >= 90 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 113 - 0
main/pji_DGNC/CarFollowingTooCloseHigh/main/CarFollowingTooCloseHigh.go

@@ -0,0 +1,113 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param       entity.PjisuvParam
+	StartTime   int64
+	count1      int64
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func IfObstaclesNearby() bool {
+	for _, obj := range ObjectSlice {
+		if obj[0][len(obj[0])-1] <= 13 && obj[0][len(obj[0])-1] >= 3 && (math.Abs(float64(obj[1][len(obj[1])-1]))) <= 6 {
+			return true
+
+		}
+	}
+	return false
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//print(param.AutomodeOfPjVehicleFdbPub)
+
+	if count1%10 == 0 {
+		AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+		flag := IfObstaclesNearby()
+		//fmt.Println(ObjectSlice)
+		if AbsSpeed >= 4 && flag {
+			// 如果之前没有记录开始时间,记录当前时间
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+			// 判断是否持续超过一分钟
+			if time.Now().Unix()-StartTime > 3 {
+				event_label := "CarFollowingTooCloseHigh"
+				fmt.Println(event_label)
+			}
+		} else {
+			// 如果速度大于 0.1,重置开始时间和停止标志
+			StartTime = 0
+		}
+		count1 = 1
+	} else {
+		count1++
+	}
+}
+
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= -2 || math.Abs(float64(obj.Y)) >= 90 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 113 - 0
main/pji_DGNC/CarFollowingTooCloseLow/main/CarFollowingTooCloseLow.go

@@ -0,0 +1,113 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param       entity.PjisuvParam
+	StartTime   int64
+	count1      int64
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func IfObstaclesNearby() bool {
+	for _, obj := range ObjectSlice {
+		if obj[0][len(obj[0])-1] <= 13 && obj[0][len(obj[0])-1] >= 3 && (math.Abs(float64(obj[1][len(obj[1])-1]))) <= 6 {
+			return true
+
+		}
+	}
+	return false
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//print(param.AutomodeOfPjVehicleFdbPub)
+
+	if count1%10 == 0 {
+		AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+		flag := IfObstaclesNearby()
+		//fmt.Println(ObjectSlice)
+		if AbsSpeed >= 1 && AbsSpeed <= 4 && flag {
+			// 如果之前没有记录开始时间,记录当前时间
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+			// 判断是否持续超过一分钟
+			if time.Now().Unix()-StartTime > 3 {
+				event_label := "CarFollowingTooCloseLow"
+				fmt.Println(event_label)
+			}
+		} else {
+			// 如果速度大于 0.1,重置开始时间和停止标志
+			StartTime = 0
+		}
+		count1 = 1
+	} else {
+		count1++
+	}
+}
+
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= -2 || math.Abs(float64(obj.Y)) >= 90 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 104 - 0
main/pji_DGNC/ClimbingSteepHill/main/ClimbingSteepHill.go

@@ -0,0 +1,104 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+// //道路坡度大于6%就可以被认为是陡坡
+var (
+	param      entity.PjisuvParam
+	threshold  = 0.05
+	AngleSlice = [][]float64{{}, {}, {}, {}}
+	count1     = 0
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+// QuaternionToEuler 将四元数转换为欧拉角
+func QuaternionToEuler(x, y, z, w float64) float64 {
+	// 归一化四元数
+	length := math.Sqrt(x*x + y*y + z*z + w*w)
+	x /= length
+	y /= length
+	z /= length
+	w /= length
+	// 计算欧拉角
+	pitch := math.Asin(2 * (w*y - z*x))
+	return pitch
+}
+func countChanges(AngleSlice [][]float64) int {
+	num := 0
+	for i := 0; i < len(AngleSlice[1]); i++ {
+		pitch := QuaternionToEuler(AngleSlice[0][i], AngleSlice[1][i], AngleSlice[2][i], AngleSlice[3][i])
+		if pitch > threshold {
+			num++
+		}
+	}
+	return num
+}
+
+func FinalCallback() {
+	count := countChanges(AngleSlice)
+	if count >= 5 {
+		event_lable := "ClimbingSteepHill"
+		fmt.Println(event_lable)
+	}
+	AngleSlice = [][]float64{{}, {}, {}, {}}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+		AngleSlice[0] = append(AngleSlice[0], data.Qx)
+		AngleSlice[1] = append(AngleSlice[1], data.Qy)
+		AngleSlice[2] = append(AngleSlice[2], data.Qz)
+		AngleSlice[3] = append(AngleSlice[3], data.Qw)
+		count1 = 1
+	}
+	count1++
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 104 - 0
main/pji_DGNC/CloseTargetDisappears/main/CloseTargetDisappears.go

@@ -0,0 +1,104 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	Maxlenobj           int32 = 0
+	param               entity.PjisuvParam
+	PreCloseTargetSlice = []uint32{}
+)
+
+func main() {
+
+	go listener()
+	for {
+		select {}
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+
+}
+func IsDisappears(PreCloseTargetSlice []uint32, perceptionslice []uint32) bool {
+	flag := false
+	if len(PreCloseTargetSlice) > 0 {
+	lable1:
+		for i := 0; i <= len(PreCloseTargetSlice)-1; i++ {
+			PreID := PreCloseTargetSlice[i]
+			for _, perceptionID := range perceptionslice {
+				if PreID == perceptionID {
+					continue lable1
+				}
+			}
+			//fmt.Println("CloseTargetDisappears")
+			return true
+		}
+	}
+	return flag
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	NowCloseTargetSlice := []uint32{}
+	perceptionslice := []uint32{}
+	for _, obj := range data.Objs {
+		perceptionslice = append(perceptionslice, obj.Id)
+		if math.Abs(float64(obj.X)) <= 10 && math.Abs(float64(obj.Y)) <= 10 {
+			NowCloseTargetSlice = append(NowCloseTargetSlice, obj.Id)
+		}
+	}
+	//fmt.Println("PreCloseTargetSlice=", PreCloseTargetSlice)
+	//fmt.Println("perceptionslice=", perceptionslice)
+	if IsDisappears(PreCloseTargetSlice, perceptionslice) {
+		eventLabel := "CloseTargetDisappears"
+		fmt.Println(eventLabel)
+	}
+	PreCloseTargetSlice = NowCloseTargetSlice
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 80 - 0
main/pji_DGNC/Creeping/main/Creeping.go

@@ -0,0 +1,80 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	param entity.PjisuvParam
+	count int = 0
+)
+
+func main() {
+	go listener()
+	for {
+		select {}
+	}
+}
+
+func CallbackDataRead(data *pjisuv_msgs.Retrieval) {
+	if data.GearPos == 2 {
+		if param.AbsSpeed >= 0.5 {
+			event_lable := "Creeping"
+			fmt.Println(event_lable)
+		}
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+
+	if count%10 == 0 {
+		param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+	}
+	count++
+
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subDataRead, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/data_read",
+		Callback: CallbackDataRead,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subDataRead.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 96 - 0
main/pji_DGNC/CurveOverspeed/main/CurveOverspeed.go

@@ -0,0 +1,96 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+type Point struct {
+	X float64
+	Y float64
+}
+
+var (
+	count     int     = 0
+	threshold float64 = 23.0 / 3.6
+	//定义园区长弯道坐标点
+	point3 = Point{456508.573, 4397918.59}
+
+	pointlist = []Point{point3}
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+
+	if count%10 == 0 {
+		//print(threshold)
+		enterflag := IfEnter(pointlist, 30, data.PositionX, data.PositionY)
+		if enterflag {
+			absspeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+			if absspeed >= threshold {
+				eventLabel := "CurveOverspeed"
+				fmt.Println(eventLabel)
+			}
+
+		}
+		count = 0
+	}
+	count++
+
+}
+func IfEnter(pointlist []Point, radius float64, x, y float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{X: x, Y: y}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		//fmt.Println(d)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+
+	d := math.Sqrt((point2.X-point1.X)*(point2.X-point1.X) + (point2.Y-point1.Y)*(point2.Y-point1.Y))
+
+	return d
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 152 - 0
main/pji_DGNC/CutinWithSightBblock/main/CutinWithSightBblock.go

@@ -0,0 +1,152 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Frame       float32 = 0.0
+	Maxlenobj   int32   = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingIn(ObjectList [][]float32) (bool, float32, float32, float64) {
+	for i, objY := range ObjectList[1] {
+
+		if math.Abs(float64(objY)) >= 1.8 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objX := ObjectList[0][1+i+j]
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objX >= 1 {
+					//fmt.Println(objX)
+					return true, ObjectList[2][1+i+j], ObjectList[0][1+i+j], math.Abs(float64(ObjectList[1][1+i+j]))
+				}
+			}
+		}
+	}
+	return false, 0.0, 0.0, 0.0
+}
+func SightBlock(cutobjx float32, cutobjy float64, objId uint32, cutinframe float32) bool {
+
+	for Id, objValue := range ObjectSlice {
+		if Id != objId {
+			for i := 0; i < len(objValue[1]); i++ {
+				if objValue[2][i] == cutinframe {
+					//fmt.Println("yes")
+					objx := objValue[0][i]
+					objy := math.Abs(float64(objValue[1][i]))
+					//fmt.Println(objx)
+					//fmt.Println(objy)
+					diffx := cutobjx - objx
+					diffy := math.Abs(cutobjy - objy)
+					if diffx >= 0 && diffx <= 6 && diffy <= 4.0 {
+						return true
+					}
+				}
+
+			}
+
+		}
+	}
+	return false
+}
+func FinalCallback() {
+	for objId, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		cutinflag, cutinframe, cutobjx, cutobjy := isCuttingIn(objValue)
+		if cutinflag {
+			//fmt.Println(cutinflag, cutinframe, cutobjx, cutobjy)
+			if SightBlock(cutobjx, cutobjy, objId, cutinframe) {
+				event_lable := "CutinWithSightBblock"
+				fmt.Println(event_lable)
+				//ObjectSlice = make(map[uint32][][]float32)
+			}
+		}
+
+	}
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 50 || math.Abs(float64(obj.Y)) >= 20 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], Frame)
+	}
+	Frame++
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 104 - 0
main/pji_DGNC/DescendingSteepHill/main/DescendingSteepHill.go

@@ -0,0 +1,104 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+// //道路坡度大于6%就可以被认为是陡坡
+var (
+	param      entity.PjisuvParam
+	threshold  = -0.05
+	AngleSlice = [][]float64{{}, {}, {}, {}}
+	count1     = 0
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+// QuaternionToEuler 将四元数转换为欧拉角
+func QuaternionToEuler(x, y, z, w float64) float64 {
+	// 归一化四元数
+	length := math.Sqrt(x*x + y*y + z*z + w*w)
+	x /= length
+	y /= length
+	z /= length
+	w /= length
+	// 计算欧拉角
+	pitch := math.Asin(2 * (w*y - z*x))
+	return pitch
+}
+func countChanges(AngleSlice [][]float64) int {
+	num := 0
+	for i := 0; i < len(AngleSlice[1]); i++ {
+		pitch := QuaternionToEuler(AngleSlice[0][i], AngleSlice[1][i], AngleSlice[2][i], AngleSlice[3][i])
+		if pitch < threshold {
+			num++
+		}
+	}
+	return num
+}
+
+func FinalCallback() {
+	count := countChanges(AngleSlice)
+	if count >= 5 {
+		event_lable := "DescendingSteepHill"
+		fmt.Println(event_lable)
+	}
+	AngleSlice = [][]float64{{}, {}, {}, {}}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+		AngleSlice[0] = append(AngleSlice[0], data.Qx)
+		AngleSlice[1] = append(AngleSlice[1], data.Qy)
+		AngleSlice[2] = append(AngleSlice[2], data.Qz)
+		AngleSlice[3] = append(AngleSlice[3], data.Qw)
+		count1 = 1
+	}
+	count1++
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 81 - 0
main/pji_DGNC/EgoReversing/main/EgoReversing.go

@@ -0,0 +1,81 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	count1 int = 0
+)
+
+func calculateDirectionAngle(speedX, speedY float64) float64 {
+	// 使用反正切函数计算方向角
+	angle := math.Atan2(speedY, speedX)
+
+	// 将角度转换为度数
+	angleDegree := angle * (180 / math.Pi)
+
+	// 将角度限定在 0~360 范围内
+	if angleDegree < 0 {
+		angleDegree += 360
+	} else if angleDegree > 360 {
+		angleDegree -= 360
+	}
+
+	return angleDegree
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+
+		directionAngle := calculateDirectionAngle(data.VelocityX, data.VelocityY)
+		AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+		diffAngle := math.Abs(float64(directionAngle - data.Yaw))
+		//fmt.Println(diffAngle)
+		if AbsSpeed >= 1 && diffAngle >= 160 && diffAngle <= 200 {
+			eventLabel := "EgoReversing"
+			fmt.Println(eventLabel)
+			count1 = 1
+		}
+	}
+	count1++
+}
+
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 103 - 0
main/pji_DGNC/EnterTjunction/main/EnterTjunction.go

@@ -0,0 +1,103 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	count2 int = 0
+
+	//定义园区T字路口的经纬度坐标值
+	point3 = Point{39.73040966605621, 116.48995329696209}
+	point4 = Point{39.73083727413453, 116.49079780188244}
+	point5 = Point{39.72976753711939, 116.49043130389033}
+	point6 = Point{39.73012466515933, 116.49128381717591}
+	point7 = Point{39.729251498328246, 116.49077484625299}
+	point8 = Point{39.72964529630643, 116.49164592200161}
+
+	pointlist = []Point{point3, point4, point5, point6, point7, point8}
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count2%10 == 0 {
+
+		enterflag := IfEnter(pointlist, 12, data.Latitude, data.Longitude)
+		if enterflag {
+			eventLabel := "EnterTjunction"
+			fmt.Println(eventLabel)
+		}
+	}
+	count2++
+}
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 87 - 0
main/pji_DGNC/EnterTjunctionUTM/main/EnterTjunction.go

@@ -0,0 +1,87 @@
+package main
+
+import (
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/geometry_msgs"
+	"math"
+	"os"
+	"os/signal"
+)
+
+type Point struct {
+	X float64
+	Y float64
+}
+
+var (
+	count2 int = 0
+
+	//定义园区部门T字路口的经纬度坐标值
+	point3 = Point{-708.854, -2039.86}
+
+	pointlist = []Point{point3}
+)
+
+func CallbackRobotPose(data *geometry_msgs.Point) {
+
+	enterflag := IfEnter(pointlist, 15, data.X, data.Y)
+	if enterflag {
+		eventLabel := "EnterTjunction"
+		fmt.Println(eventLabel)
+	}
+
+}
+func IfEnter(pointlist []Point, radius float64, x, y float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{X: x, Y: y}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		fmt.Println(d)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+
+	d := math.Sqrt((point2.X-point1.X)*(point2.X-point1.X) + (point2.Y-point1.Y)*(point2.Y-point1.Y))
+
+	return d
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subRobotPose, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/end_point_message",
+		Callback: CallbackRobotPose,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subRobotPose.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 77 - 0
main/pji_DGNC/ExcessiveSpeedWhenDownhill/main/ExcessiveSpeedWhenDownhill.go

@@ -0,0 +1,77 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+// //道路坡度大于6%就可以被认为是陡坡
+var (
+	param     entity.PjisuvParam
+	threshold = -0.05
+	count1    = 0
+)
+
+func main() {
+	go listener()
+	for {
+		select {}
+	}
+}
+
+// QuaternionToEuler 将四元数转换为欧拉角
+func QuaternionToEuler(x, y, z, w float64) float64 {
+	// 归一化四元数
+	length := math.Sqrt(x*x + y*y + z*z + w*w)
+	x /= length
+	y /= length
+	z /= length
+	w /= length
+	// 计算欧拉角
+	pitch := math.Asin(2 * (w*y - z*x))
+	return pitch
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+		if math.Abs(data.AngularVelocityZ) >= 17.0 && QuaternionToEuler(data.Qx, data.Qy, data.Qz, data.Qw) <= threshold {
+			count1 = 1
+			event_lable := "ExcessiveSpeedWhenDownhill"
+			fmt.Println(event_lable)
+		}
+	}
+	count1++
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 77 - 0
main/pji_DGNC/ExcessiveSpeedWhenUphill/main/ExcessiveSpeedWhenUphill.go

@@ -0,0 +1,77 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+// //道路坡度大于6%就可以被认为是陡坡
+var (
+	param     entity.PjisuvParam
+	threshold = 0.05
+	count1    = 0
+)
+
+func main() {
+	go listener()
+	for {
+		select {}
+	}
+}
+
+// QuaternionToEuler 将四元数转换为欧拉角
+func QuaternionToEuler(x, y, z, w float64) float64 {
+	// 归一化四元数
+	length := math.Sqrt(x*x + y*y + z*z + w*w)
+	x /= length
+	y /= length
+	z /= length
+	w /= length
+	// 计算欧拉角
+	pitch := math.Asin(2 * (w*y - z*x))
+	return pitch
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+		if math.Abs(data.AngularVelocityZ) >= 17.0 && QuaternionToEuler(data.Qx, data.Qy, data.Qz, data.Qw) >= threshold {
+			count1 = 1
+			event_lable := "ExcessiveSpeedWhenUphill"
+			fmt.Println(event_lable)
+		}
+	}
+	count1++
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 98 - 0
main/pji_DGNC/FindLongCurve/main/FindLongCurve.go

@@ -0,0 +1,98 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	count1 int = 0
+
+	//定义园区弯道
+	point2 = Point{39.73004426154644, 116.49248639463602}
+
+	pointlist = []Point{point2}
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+
+		enterflag := IfEnter(pointlist, 18.0, data.Latitude, data.Longitude)
+		if enterflag {
+			eventLabel := "FindLongCurve"
+			fmt.Println(eventLabel)
+		}
+	}
+	count1++
+}
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 101 - 0
main/pji_DGNC/FindTrafficLight/main/FindTrafficLight.go

@@ -0,0 +1,101 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	count1 int = 0
+
+	//定义园区4个信号灯的坐标
+	point2 = Point{39.72975930689718, 116.48861102824081}
+	point3 = Point{39.7288805296616, 116.48812315228867}
+	point4 = Point{39.73061430369551, 116.49225103553502}
+	point5 = Point{39.73077491578002, 116.49060085035634}
+
+	pointlist = []Point{point2, point3, point4, point5}
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+
+		enterflag := IfEnter(pointlist, 15.0, data.Latitude, data.Longitude)
+		if enterflag {
+			eventLabel := "FindTrafficLight"
+			fmt.Println(eventLabel)
+		}
+	}
+	count1++
+}
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 131 - 0
main/pji_DGNC/Foggy/main/Foggy.go

@@ -0,0 +1,131 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"encoding/json"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"io/ioutil"
+	"net/http"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Weather struct {
+	WeatherID   []int
+	temperature float64
+	humidity    float64
+}
+
+var (
+	param entity.PjisuvParam
+	//weatherID  = []int{}
+	apiKey     = "f9d230f00d9ccdba49a97e043333d410"
+	maxRetries = 5
+	retryDelay = time.Second * 2
+	data       map[string]interface{}
+)
+
+func OpenWeatherAPI() Weather {
+	var weather = Weather{}
+	latitude := param.LatitudeOfCicvLocation
+	longitude := param.LongitudeOfCicvLocation
+	for retries := 0; retries < maxRetries; retries++ {
+		url := fmt.Sprintf("https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=%s", latitude, longitude, apiKey)
+
+		resp, err := http.Get(url)
+		if err != nil {
+			fmt.Println("Error:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+		defer resp.Body.Close()
+
+		body, err := ioutil.ReadAll(resp.Body)
+		if err != nil {
+			fmt.Println("Error reading response:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+
+		if err := json.Unmarshal(body, &data); err != nil {
+			fmt.Println("Error parsing JSON:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+		// Successfully retrieved data
+		break
+	}
+	if data == nil {
+		fmt.Println("Failed to retrieve data after maximum retries.")
+		return weather
+	}
+	mainData := data["main"].(map[string]interface{})
+	weather.temperature = mainData["temp"].(float64) - 273.15
+	weather.humidity = mainData["humidity"].(float64)
+	for _, w := range data["weather"].([]interface{}) {
+		tianqi := w.(map[string]interface{})
+		weather.WeatherID = append(weather.WeatherID, int(tianqi["id"].(float64)))
+	}
+	fmt.Printf("当前位置的天气状况/温度/湿度:%v/%.2f/%.2f\n", weather.WeatherID, weather.temperature, weather.humidity)
+	return weather
+}
+
+func FinalCallback() {
+	NOwWeather := OpenWeatherAPI()
+	if NOwWeather.WeatherID != nil {
+		for _, weatherid := range NOwWeather.WeatherID {
+			if weatherid == 701 || weatherid == 711 || weatherid == 741 || weatherid == 721 {
+				eventLabel := "Foggy"
+				fmt.Println(eventLabel)
+				break
+			}
+		}
+	}
+}
+
+func main() {
+	ticker := time.NewTicker(80 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 99 - 0
main/pji_DGNC/FrequentStartsAndStops/main/FrequentStartsAndStops.go

@@ -0,0 +1,99 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param      entity.PjisuvParam
+	threshold  int = 1500
+	SpeedSlice     = []float64{}
+)
+
+func main() {
+	ticker := time.NewTicker(6 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func countChanges(slice []float64) int {
+	count := 0
+lable1:
+	for i := 0; i < len(slice); {
+		if slice[i] >= 2 {
+			for j := 0; j < len(slice)-i-1; j++ {
+				if slice[1+i+j] <= 0.5 {
+					count++
+					//fmt.Println("stop!!")
+					i = i + j + 1
+					continue lable1
+				}
+			}
+			break lable1
+		} else {
+			i++
+		}
+
+	}
+	return count
+}
+
+func FinalCallback() {
+	count := countChanges(SpeedSlice)
+	//fmt.Println(AccelXSlice)
+	if count >= 3 {
+		event_lable := "FrequentStartsAndStops"
+		fmt.Println(event_lable)
+		SpeedSlice = []float64{}
+
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	Aspeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+	SpeedSlice = append(SpeedSlice, Aspeed)
+	if len(SpeedSlice) > threshold {
+		SpeedSlice = SpeedSlice[1:]
+	}
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 129 - 0
main/pji_DGNC/FrontCarDrivingWrongDirection/main/FrontCarDrivingWrongDirection.go

@@ -0,0 +1,129 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isWrongDirection(ObjectList [][]float32) bool {
+	//fmt.Println("-------------------------------------------------------------------------------------------------------------")
+	//fmt.Println(ObjectList)
+	for i, heading := range ObjectList[2] {
+		objXi := ObjectList[0][i]
+		objYi := ObjectList[1][i]
+		Anglei := math.Abs(float64(heading - float32(param.YawOfCicvLocation)))
+		//fmt.Println("objXi=", objXi)
+		if math.Abs(float64(objYi)) <= 1.5 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objXi >= 15 && Anglei <= 200 && Anglei >= 160 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objXij := ObjectList[0][1+i+j]
+				objYij := ObjectList[1][1+i+j]
+				//fmt.Println("objXij=", objXij)
+				if math.Abs(float64(objYij)) <= 1.5 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objXij <= 10 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isWrongDirection(objValue) {
+			continue
+		}
+		event_lable := "FrontCarDrivingWrongDirection"
+		ObjectSlice = make(map[uint32][][]float32)
+		fmt.Println(event_lable)
+	}
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+	param.YawOfCicvLocation = data.Yaw
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 80 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Heading)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 179 - 0
main/pji_DGNC/FrontCarRetrogradeOnJunction/main/FrontCarRetrogradeOnJunction.go

@@ -0,0 +1,179 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	count2            = 0
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+	//定义园区T字路口的经纬度坐标值
+	point3 = Point{39.73040966605621, 116.48995329696209}
+	point4 = Point{39.73083727413453, 116.49079780188244}
+	point5 = Point{39.72976753711939, 116.49043130389033}
+	point6 = Point{39.73012466515933, 116.49128381717591}
+	point7 = Point{39.729251498328246, 116.49077484625299}
+	point8 = Point{39.72964529630643, 116.49164592200161}
+
+	pointlist = []Point{point3, point4, point5, point6, point7, point8}
+)
+
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isWrongDirection(ObjectList [][]float32) bool {
+	//fmt.Println("-------------------------------------------------------------------------------------------------------------")
+	//fmt.Println(ObjectList)
+	for i, heading := range ObjectList[2] {
+		objXi := ObjectList[0][i]
+		objYi := ObjectList[1][i]
+		Anglei := math.Abs(float64(heading - float32(param.YawOfCicvLocation)))
+		//fmt.Println("objXi=", objXi)
+		if math.Abs(float64(objYi)) <= 1.5 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objXi >= 15 && Anglei <= 200 && Anglei >= 160 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objXij := ObjectList[0][1+i+j]
+				objYij := ObjectList[1][1+i+j]
+				//fmt.Println("objXij=", objXij)
+				if math.Abs(float64(objYij)) <= 1.5 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objXij <= 10 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isWrongDirection(objValue) || param.EnterJunctionFlag {
+			continue
+		}
+		event_lable := "FrontCarRetrogradeOnJunction"
+		ObjectSlice = make(map[uint32][][]float32)
+		fmt.Println(event_lable)
+	}
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count2%10 == 0 {
+		param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+		param.YawOfCicvLocation = data.Yaw
+		param.EnterJunctionFlag = IfEnter(pointlist, 16, data.Latitude, data.Longitude)
+		//fmt.Println(param.EnterJunctionFlag)
+
+	}
+	count2++
+}
+
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 80 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Heading)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 107 - 0
main/pji_DGNC/FrontCarSideBySide/main/FrontCarSideBySide.go

@@ -0,0 +1,107 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	countSideBySide = 0
+	param           entity.PjisuvParam
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func FinalCallback() {
+	if countSideBySide >= 60 {
+		event_lable := "FrontCarSideBySide"
+		fmt.Println(event_lable)
+	}
+	countSideBySide = 0
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+lable1:
+	for _, obj := range data.Objs {
+		//if !(obj.Type != 2 || obj.Type != 3 || obj.Type != 4 || !(obj.X >= 3 && obj.X <= 17) || math.Abs(float64(obj.Y)) > 10)
+		if !(!(obj.X >= 3 && obj.X <= 17) || math.Abs(float64(obj.Y)) > 10) {
+			//fmt.Println("here")
+			obj1ID := obj.Id
+			obj1x := obj.X
+			obj1y := obj.Y
+			//fmt.Println(obj1ID, obj1x, obj1y)
+			for _, obj1 := range data.Objs {
+				//if !(obj1.Type != 2 || obj1.Type != 3 || obj1.Type != 4 || !(obj1.X >= 3 && obj1.X <= 17) || math.Abs(float64(obj1.Y)) > 10)
+				if !(!(obj1.X >= 3 && obj1.X <= 17) || math.Abs(float64(obj1.Y)) > 10) {
+					obj2ID := obj1.Id
+					obj2x := obj1.X
+					obj2y := obj1.Y
+					if obj2ID != obj1ID && math.Abs(float64(obj2x-obj1x)) <= 2.2 && math.Abs(float64(obj2y-obj1y)) >= 2 && math.Abs(float64(obj2y-obj1y)) <= 4.0 && param.AbsSpeed > 2 {
+						countSideBySide++
+						break lable1
+					}
+				}
+
+			}
+
+		}
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 119 - 0
main/pji_DGNC/FrontCarStayAway/main/FrontCarStayAway.go

@@ -0,0 +1,119 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isApproach(ObjectList [][]float32) bool {
+	for i, objX := range ObjectList[0] {
+
+		if math.Abs(float64(ObjectList[1][i])) <= 1.5 && objX <= 6 {
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 1.5 && ObjectList[0][1+i+j] >= 12 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isApproach(objValue) {
+			continue
+		}
+		event_lable := "FrontCarStayAway"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 50 || math.Abs(float64(obj.Y)) >= 10 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 123 - 0
main/pji_DGNC/FrontVehicleBrake/main/FrontVehicleBrake.go

@@ -0,0 +1,123 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isBrake(ObjectList [][]float32) bool {
+	for i, speed := range ObjectList[3] {
+		//fmt.Println(speed)
+
+		if math.Abs(float64(ObjectList[1][i])) <= 1.5 && speed >= 3 && ObjectList[0][i] >= 1.3 {
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 1.5 && ObjectList[3][1+i+j] <= 1 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isBrake(objValue) {
+			continue
+		}
+		event_lable := "FrontVehicleBrake"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 3 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}}
+		}
+		absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 164 - 0
main/pji_DGNC/FrontVehicleBrakeInCurve/main/FrontVehicleBrakeInCurve.go

@@ -0,0 +1,164 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	Maxlenobj      int32 = 0
+	param          entity.PjisuvParam
+	ObjectSlice    = make(map[uint32][][]float32)
+	pointcurve     = Point{39.73004426154644, 116.49248639463602}
+	pointcurvelist = []Point{pointcurve}
+)
+
+func IfEnter(pointlist []Point, radius float64, x, y float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: x, Longitude: y}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		//fmt.Println(d)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isBrake(ObjectList [][]float32) bool {
+	for i, speed := range ObjectList[3] {
+		//fmt.Println(speed)
+
+		if math.Abs(float64(ObjectList[1][i])) <= 6.5 && speed >= 6/3.6 && ObjectList[0][i] >= 1.3 {
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 6.5 && ObjectList[3][1+i+j] <= 1/3.6 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+	enterflag := IfEnter(pointcurvelist, 30, param.LatitudeOfCicvLocation, param.LongitudeOfCicvLocation)
+	if enterflag {
+		for _, objValue := range ObjectSlice {
+			//fmt.Println(objValue)
+			//fmt.Println("------------------------------------------------")
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+			if len(objValue[0]) <= 10 || !isBrake(objValue) {
+				continue
+			}
+			event_lable := "FrontVehicleBrakeInCurve"
+			fmt.Println(event_lable)
+			ObjectSlice = make(map[uint32][][]float32)
+		}
+	}
+	if Maxlenobj >= 60 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 3 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}}
+		}
+		absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2) + math.Pow(float64(obj.Vyabs), 2))
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 171 - 0
main/pji_DGNC/FrontVehicleBrakeInJunction/main/FrontVehicleBrakeInJunction.go

@@ -0,0 +1,171 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+	//定义园区T字路口的经纬度坐标值
+	point3 = Point{39.73040966605621, 116.48995329696209}
+	point4 = Point{39.73083727413453, 116.49079780188244}
+	point5 = Point{39.72976753711939, 116.49043130389033}
+	point6 = Point{39.73012466515933, 116.49128381717591}
+	point7 = Point{39.729251498328246, 116.49077484625299}
+	point8 = Point{39.72964529630643, 116.49164592200161}
+
+	PointJunctionList = []Point{point3, point4, point5, point6, point7, point8}
+)
+
+func IfEnter(pointlist []Point, radius float64, x, y float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: x, Longitude: y}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		//fmt.Println(d)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isBrake(ObjectList [][]float32) bool {
+	for i, speed := range ObjectList[3] {
+		//fmt.Println(speed)
+
+		if math.Abs(float64(ObjectList[1][i])) <= 6.5 && speed >= 6/3.6 && ObjectList[0][i] >= 1.3 {
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 6.5 && ObjectList[3][1+i+j] <= 1/3.6 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+	enterflag := IfEnter(PointJunctionList, 20, param.LatitudeOfCicvLocation, param.LongitudeOfCicvLocation)
+	if enterflag {
+		for _, objValue := range ObjectSlice {
+			//fmt.Println(objValue)
+			//fmt.Println("------------------------------------------------")
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+			if len(objValue[0]) <= 10 || !isBrake(objValue) {
+				continue
+			}
+			event_lable := "FrontVehicleBrakeInJunction"
+			fmt.Println(event_lable)
+			ObjectSlice = make(map[uint32][][]float32)
+		}
+	}
+	if Maxlenobj >= 60 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 3 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}}
+		}
+		absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2) + math.Pow(float64(obj.Vyabs), 2))
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 120 - 0
main/pji_DGNC/FrontVehicleCutInFar/main/FrontVehicleCutInFar.go

@@ -0,0 +1,120 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingIn(ObjectList [][]float32) bool {
+	for i, objY := range ObjectList[1] {
+
+		if math.Abs(float64(objY)) >= 1.8 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objX := ObjectList[0][1+i+j]
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objX >= 16 && objX <= 50 {
+					//fmt.Println(objX)
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isCuttingIn(objValue) {
+			continue
+		}
+		event_lable := "FrontVehicleCutInFar"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 10 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 123 - 0
main/pji_DGNC/FrontVehicleCutInNear/main/FrontVehicleCutInNear.go

@@ -0,0 +1,123 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingIn(ObjectList [][]float32) bool {
+	for i, objY := range ObjectList[1] {
+		if math.Abs(float64(objY)) >= 1.3 {
+			//fmt.Println(math.Abs(float64(objY)))
+		}
+
+		if math.Abs(float64(objY)) >= 1.8 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objX := ObjectList[0][1+i+j]
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 0.7 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objX >= 1 && objX <= 16 {
+					//fmt.Println(objX)
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isCuttingIn(objValue) {
+			continue
+		}
+		event_lable := "FrontVehicleCutInNear"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 10 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 120 - 0
main/pji_DGNC/FrontVehicleCutOutFar/main/FrontVehicleCutOutFar.go

@@ -0,0 +1,120 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingOut(ObjectList [][]float32) bool {
+	for i, objY := range ObjectList[1] {
+
+		if math.Abs(float64(objY)) <= 0.9 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objX := ObjectList[0][1+i+j]
+				if math.Abs(float64(ObjectList[1][1+i+j])) >= 2.1 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objX >= 20 && objX <= 50 {
+					//fmt.Println(objX)
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isCuttingOut(objValue) {
+			continue
+		}
+		event_lable := "FrontVehicleCutOutFar"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 10 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 120 - 0
main/pji_DGNC/FrontVehicleCutOutNear/main/FrontVehicleCutOutNear.go

@@ -0,0 +1,120 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingOut(ObjectList [][]float32) bool {
+	for i, objY := range ObjectList[1] {
+
+		if math.Abs(float64(objY)) <= 0.9 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objX := ObjectList[0][1+i+j]
+				if math.Abs(float64(ObjectList[1][1+i+j])) >= 1.9 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 && objX >= 1 && objX <= 19 {
+					//fmt.Println(objX)
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isCuttingOut(objValue) {
+			continue
+		}
+		event_lable := "FrontVehicleCutOutNear"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= -2 || math.Abs(float64(obj.Y)) >= 90 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 136 - 0
main/pji_DGNC/FrontVehicleFrequentBrake/main/FrontVehicleFrequentBrake.go

@@ -0,0 +1,136 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func countChanges(slice [][]float32) int {
+	count := 0
+lable1:
+	for i := 0; i < len(slice[3]); {
+		xi := slice[0][i]
+		yi := slice[1][i]
+		speedi := slice[3][i]
+		if math.Abs(float64(yi)) <= 1.5 && speedi >= 3 && xi >= 1.5 {
+			for j := 0; j < len(slice[1])-i-1; j++ {
+				xij := slice[0][1+i+j]
+				yij := slice[1][1+i+j]
+				speedij := slice[3][1+i+j]
+				if math.Abs(float64(yij)) <= 1.5 && speedij <= 1 && xij >= 1.5 {
+					count++
+					//fmt.Println("here!!")
+					i = i + j + 1
+					continue lable1
+				}
+			}
+			break lable1
+		} else {
+			i++
+		}
+
+	}
+	return count
+}
+
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || countChanges(objValue) < 2 {
+			continue
+		}
+		event_lable := "FrontVehicleFrequentBrake"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 3 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}}
+		}
+		absspeed := math.Sqrt(math.Pow(float64(obj.Vxabs), 2)+math.Pow(float64(obj.Vyabs), 2)) * 3.6
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(absspeed))
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 129 - 0
main/pji_DGNC/FrontVehiclesFrequentChangeLane/main/FrontVehiclesFrequentChangeLane.go

@@ -0,0 +1,129 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(4 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func countChanges(slice [][]float32) int {
+	count := 0
+lable1:
+	for i := 0; i < len(slice[1]); {
+		xi := slice[0][i]
+		yi := math.Abs(float64(slice[1][i]))
+		if (yi >= 1.8 || yi < 0.7) && xi >= 2 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 1.6 {
+			for j := 0; j < len(slice[1])-i-1; j++ {
+				xij := slice[0][1+i+j]
+				yij := math.Abs(float64(slice[1][1+i+j]))
+				if ((yi >= 1.8 && yij <= 0.7) || (yi < 0.7 && yij >= 1.8)) && xij >= 2 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 1.6 {
+					count++
+					//fmt.Println("here!!")
+					i = i + j + 1
+					continue lable1
+				}
+			}
+			break lable1
+		} else {
+			i++
+		}
+
+	}
+	return count
+}
+
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || countChanges(objValue) < 2 {
+			continue
+		}
+		event_lable := "FrontVehiclesFrequentChangeLane"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X <= 2 || math.Abs(float64(obj.Y)) >= 10 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 84 - 0
main/pji_DGNC/GearJump/main/GearJump.go

@@ -0,0 +1,84 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param        entity.PjisuvParam
+	threshold    = 0.04
+	GearPosSlice = []int16{}
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func countChanges(slice []int16) int {
+	count := 0
+	for i := 0; i < len(slice)-1; i++ {
+		if slice[i] != slice[i+1] {
+			count++
+		}
+	}
+	return count
+}
+
+func FinalCallback() {
+	count := countChanges(GearPosSlice)
+	//fmt.Println(AccelXSlice)
+	if count >= 2 {
+
+		event_lable := "GearJump"
+		fmt.Println(event_lable)
+	}
+	GearPosSlice = []int16{}
+
+}
+
+func CallbackDataRead(data *pjisuv_msgs.Retrieval) {
+	//AbsAccel := math.Sqrt(math.Pow(data.AccelX, 2) + math.Pow(data.AccelY, 2))
+	GearPosSlice = append(GearPosSlice, data.GearPos)
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subDataRead, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/data_read",
+		Callback: CallbackDataRead,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subDataRead.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 149 - 0
main/pji_DGNC/GreenLightsNoPass/main/GreenLightsNoPass.go

@@ -0,0 +1,149 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+	Id        string
+}
+
+var (
+	IsStopped  bool
+	StartTime  int64
+	param      entity.PjisuvParam
+	count1     int = 0
+	DicofLight     = make(map[string]int8)
+	//定义园区4个信号灯的坐标
+	point2 = Point{39.72998222922185, 116.49307473274646, "25174113"}
+
+	pointlightlist = []Point{point2}
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+		param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+		enterlightid := IfEnter(pointlightlist, 13.0, data.Latitude, data.Longitude)
+		//fmt.Println(enterlightid)
+		if enterlightid != "0" {
+			if DicofLight[enterlightid] == 1 && param.AbsSpeed < 0.3 {
+				if StartTime == 0 {
+					StartTime = time.Now().Unix()
+				}
+				// 判断是否持续超过一分钟
+				if time.Now().Unix()-StartTime > 5 {
+					if !IsStopped {
+						event_label := "GreenLightsNoPass"
+						fmt.Println(event_label)
+						IsStopped = true
+					}
+				}
+
+			} else {
+				StartTime = 0
+				IsStopped = false
+			}
+
+		}
+	}
+	count1++
+}
+func Callbacktftrafficlight(data *pjisuv_msgs.TrafficLightDetection) {
+	//fmt.Println("yes")
+	for _, light := range data.TrafficLight {
+		//fmt.Println(light.Id)
+		//fmt.Println(light.Color)
+
+		/*
+			if _, ok := DicofLight[light.Id]; !ok {
+				DicofLight[light.Id] = 9
+			}
+
+		*/
+		DicofLight[light.Id] = light.Color
+	}
+	//fmt.Println(DicofLight)
+
+}
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) string {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return point.Id
+		}
+	}
+	return "0"
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subtftrafficlight, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/tftrafficlight",
+		Callback: Callbacktftrafficlight,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subtftrafficlight.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 131 - 0
main/pji_DGNC/HeavyIntensityRain/main/HeavyIntensityRain.go

@@ -0,0 +1,131 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"encoding/json"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"io/ioutil"
+	"net/http"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Weather struct {
+	WeatherID   []int
+	temperature float64
+	humidity    float64
+}
+
+var (
+	param entity.PjisuvParam
+	//weatherID  = []int{}
+	apiKey     = "f9d230f00d9ccdba49a97e043333d410"
+	maxRetries = 5
+	retryDelay = time.Second * 2
+	data       map[string]interface{}
+)
+
+func OpenWeatherAPI() Weather {
+	var weather = Weather{}
+	latitude := param.LatitudeOfCicvLocation
+	longitude := param.LongitudeOfCicvLocation
+	for retries := 0; retries < maxRetries; retries++ {
+		url := fmt.Sprintf("https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=%s", latitude, longitude, apiKey)
+
+		resp, err := http.Get(url)
+		if err != nil {
+			fmt.Println("Error:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+		defer resp.Body.Close()
+
+		body, err := ioutil.ReadAll(resp.Body)
+		if err != nil {
+			fmt.Println("Error reading response:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+
+		if err := json.Unmarshal(body, &data); err != nil {
+			fmt.Println("Error parsing JSON:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+		// Successfully retrieved data
+		break
+	}
+	if data == nil {
+		fmt.Println("Failed to retrieve data after maximum retries.")
+		return weather
+	}
+	mainData := data["main"].(map[string]interface{})
+	weather.temperature = mainData["temp"].(float64) - 273.15
+	weather.humidity = mainData["humidity"].(float64)
+	for _, w := range data["weather"].([]interface{}) {
+		tianqi := w.(map[string]interface{})
+		weather.WeatherID = append(weather.WeatherID, int(tianqi["id"].(float64)))
+	}
+	fmt.Printf("当前位置的天气状况/温度/湿度:%v/%.2f/%.2f\n", weather.WeatherID, weather.temperature, weather.humidity)
+	return weather
+}
+
+func FinalCallback() {
+	NOwWeather := OpenWeatherAPI()
+	if NOwWeather.WeatherID != nil {
+		for _, weatherid := range NOwWeather.WeatherID {
+			if weatherid == 502 || weatherid == 503 || weatherid == 504 || weatherid == 511 || weatherid == 522 {
+				eventLabel := "HeavyIntensityRain"
+				fmt.Println(eventLabel)
+				break
+			}
+		}
+	}
+}
+
+func main() {
+	ticker := time.NewTicker(80 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 130 - 0
main/pji_DGNC/HighSpeedOvertaking/main/HighSpeedOvertaking.go

@@ -0,0 +1,130 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	threshold   float64 = 15 / 3.6
+	Maxlenobj   int32   = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func IsOvertaken(ObjectList [][]float32) bool {
+	if param.AbsSpeed > threshold {
+		//fmt.Println("yes")
+		//fmt.Println(ObjectList)
+		for i, objX := range ObjectList[0] {
+			diffangle := math.Abs(param.YawOfCicvLocation - float64(ObjectList[2][i]))
+
+			if math.Abs(float64(ObjectList[1][i])) <= 4 && objX >= 2.5 && diffangle <= 30.0 {
+				for j := 0; j < len(ObjectList[0])-i-1; j++ {
+					if math.Abs(float64(ObjectList[1][1+i+j])) <= 4 && ObjectList[0][1+i+j] <= -1.5 {
+						return true
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+	//fmt.Println("here")
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(ObjectSlice)
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 5 || !IsOvertaken(objValue) {
+			continue
+		}
+		event_lable := "HighSpeedOvertaking"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+	//fmt.Println(Maxlenobj)
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+	param.YawOfCicvLocation = data.Yaw
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 50 || math.Abs(float64(obj.Y)) >= 60 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Heading)
+		//ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 131 - 0
main/pji_DGNC/HighTemperature/main/HighTemperature.go

@@ -0,0 +1,131 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"encoding/json"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"io/ioutil"
+	"net/http"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Weather struct {
+	WeatherID   []int
+	temperature float64
+	humidity    float64
+}
+
+var (
+	param      entity.PjisuvParam
+	threshold  float64 = 40.0
+	apiKey             = "f9d230f00d9ccdba49a97e043333d410"
+	maxRetries         = 5
+	retryDelay         = time.Second * 2
+	data       map[string]interface{}
+)
+
+func OpenWeatherAPI() Weather {
+	var weather = Weather{}
+	latitude := param.LatitudeOfCicvLocation
+	longitude := param.LongitudeOfCicvLocation
+	for retries := 0; retries < maxRetries; retries++ {
+		url := fmt.Sprintf("https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=%s", latitude, longitude, apiKey)
+
+		resp, err := http.Get(url)
+		if err != nil {
+			fmt.Println("Error:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+		defer resp.Body.Close()
+
+		body, err := ioutil.ReadAll(resp.Body)
+		if err != nil {
+			fmt.Println("Error reading response:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+
+		if err := json.Unmarshal(body, &data); err != nil {
+			fmt.Println("Error parsing JSON:", err)
+			time.Sleep(retryDelay)
+			continue
+		}
+		// Successfully retrieved data
+		break
+	}
+	if data == nil {
+		fmt.Println("Failed to retrieve data after maximum retries.")
+		return weather
+	}
+	mainData := data["main"].(map[string]interface{})
+	weather.temperature = mainData["temp"].(float64) - 273.15
+	weather.humidity = mainData["humidity"].(float64)
+	for _, w := range data["weather"].([]interface{}) {
+		tianqi := w.(map[string]interface{})
+		weather.WeatherID = append(weather.WeatherID, int(tianqi["id"].(float64)))
+	}
+	fmt.Printf("当前位置的天气状况/温度/湿度:%v/%.2f/%.2f\n", weather.WeatherID, weather.temperature, weather.humidity)
+	return weather
+}
+
+func FinalCallback() {
+	NOwWeather := OpenWeatherAPI()
+	if NOwWeather.WeatherID != nil {
+
+		if NOwWeather.temperature > threshold {
+			eventLabel := "HighTemperature"
+			fmt.Println(eventLabel)
+
+		}
+
+	}
+}
+
+func main() {
+	ticker := time.NewTicker(80 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 98 - 0
main/pji_DGNC/HuaLong/main/HuaLong.go

@@ -0,0 +1,98 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"os"
+	"os/signal"
+	"time"
+)
+
+// 触发器名称是顿挫
+var (
+	param            entity.PjisuvParam
+	threshold        float64 = 60.0
+	ActStrWhAngSlice         = []float64{}
+	numcount                 = 0
+)
+
+func main() {
+	ticker := time.NewTicker(6 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func countChanges(slice []float64) int {
+	count := 0
+lable1:
+	for i := 0; i < len(slice); {
+		if slice[i] <= -threshold || slice[i] > threshold {
+			for j := 0; j < len(slice)-i-1; j++ {
+				if (slice[i] <= -threshold && slice[1+i+j] >= threshold) || (slice[i] >= threshold && slice[1+i+j] <= -threshold) {
+					count++
+					i = i + j + 1
+					continue lable1
+				}
+			}
+			break lable1
+		} else {
+			i++
+		}
+
+	}
+	return count
+}
+
+func FinalCallback() {
+	count := countChanges(ActStrWhAngSlice)
+	//fmt.Println(AccelXSlice)
+	if count >= 3 {
+
+		event_lable := "HuaLong"
+		fmt.Println(event_lable)
+	}
+	ActStrWhAngSlice = []float64{}
+}
+
+func CallbackDataRead(data *pjisuv_msgs.Retrieval) {
+	if numcount%10 == 0 {
+		ActStrWhAngSlice = append(ActStrWhAngSlice, data.ActStrWhAng)
+		numcount = 0
+	}
+	numcount++
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/data_read",
+		Callback: CallbackDataRead,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 111 - 0
main/pji_DGNC/JunctionOverspeed/main/JunctionOverspeed.go

@@ -0,0 +1,111 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	count     int     = 0
+	threshold float64 = 23.0 / 3.6
+	//定义园区T字路口的经纬度坐标值
+	point3 = Point{39.73040966605621, 116.48995329696209}
+	point4 = Point{39.73083727413453, 116.49079780188244}
+	point5 = Point{39.72976753711939, 116.49043130389033}
+	point6 = Point{39.73012466515933, 116.49128381717591}
+	point7 = Point{39.729251498328246, 116.49077484625299}
+	point8 = Point{39.72964529630643, 116.49164592200161}
+
+	PointJunctionList = []Point{point3, point4, point5, point6, point7, point8}
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+
+	if count%10 == 0 {
+		//print(threshold)
+		enterflag := IfEnter(PointJunctionList, 15, data.Latitude, data.Longitude)
+		if enterflag {
+			absspeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+			if absspeed >= threshold {
+				eventLabel := "JunctionOverspeed"
+				fmt.Println(eventLabel)
+			}
+
+		}
+		count = 0
+	}
+	count++
+
+}
+func IfEnter(pointlist []Point, radius float64, x, y float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: x, Longitude: y}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		//fmt.Println(d)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 70 - 0
main/pji_DGNC/LocationJump/main/LocationJump.go

@@ -0,0 +1,70 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	PrePositionX float64 = 0
+	PrePositionY float64 = 0
+	//numbers              = make([]float64, 0)
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if PrePositionX != 0 && PrePositionY != 0 {
+		d := math.Sqrt((PrePositionX-data.PositionX)*(PrePositionX-data.PositionX) + (PrePositionY-data.PositionY)*(PrePositionY-data.PositionY))
+		if d >= 2 {
+			eventLabel := "LocationJump"
+			fmt.Println(eventLabel)
+		}
+		//fmt.Println(d)
+		//numbers = append(numbers, d)
+		//sort.Float64s(numbers)
+		//max := numbers[len(numbers)-1]
+		//fmt.Println("最大值为:", max)
+	}
+	PrePositionX = data.PositionX
+	PrePositionY = data.PositionY
+
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	//sort.Float64s(numbers)
+	//max := numbers[len(numbers)-1]
+	//fmt.Println("最大值为:", max)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 123 - 0
main/pji_DGNC/LongDownhill/main/LongDownhill.go

@@ -0,0 +1,123 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+// //道路坡度大于6%就可以被认为是陡坡
+var (
+	param            entity.PjisuvParam
+	threshold        = -0.05
+	count1           = 0
+	UphillPointSlice = [][]float64{{}, {}}
+	CountNoneUphill  = 0
+)
+
+type Point struct {
+	X float64
+	Y float64
+}
+
+func main() {
+	go listener()
+	for {
+		select {}
+	}
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+
+	d := math.Sqrt((point2.X-point1.X)*(point2.X-point1.X) + (point2.Y-point1.Y)*(point2.Y-point1.Y))
+
+	return d
+}
+
+// QuaternionToEuler 将四元数转换为欧拉角
+func QuaternionToEuler(x, y, z, w float64) float64 {
+	// 归一化四元数
+	length := math.Sqrt(x*x + y*y + z*z + w*w)
+	x /= length
+	y /= length
+	z /= length
+	w /= length
+	// 计算欧拉角
+	pitch := math.Asin(2 * (w*y - z*x))
+	if math.IsNaN(pitch) {
+		return 0.0
+	}
+	return pitch
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%1 == 0 {
+		pitch := QuaternionToEuler(data.Qx, data.Qy, data.Qz, data.Qw)
+		//fmt.Println(pitch)
+		if pitch <= threshold {
+			UphillPointSlice[0] = append(UphillPointSlice[0], data.PositionX)
+			UphillPointSlice[1] = append(UphillPointSlice[1], data.PositionY)
+			if len(UphillPointSlice[0]) > 250 {
+
+				P1 := Point{UphillPointSlice[0][0], UphillPointSlice[1][0]}
+				P2 := Point{UphillPointSlice[0][len(UphillPointSlice[0])-1], UphillPointSlice[1][len(UphillPointSlice[1])-1]}
+				distance := distance(P1, P2)
+				if distance >= 100 {
+					event_lable := "LongDownhill"
+					fmt.Println(event_lable)
+				}
+				CountNoneUphill = 0
+				UphillPointSlice = [][]float64{{}, {}}
+			}
+		} else {
+			CountNoneUphill++
+			if CountNoneUphill == 3 {
+				if len(UphillPointSlice[0]) > 1 {
+					P1 := Point{UphillPointSlice[0][0], UphillPointSlice[1][0]}
+					P2 := Point{UphillPointSlice[0][len(UphillPointSlice[0])-1], UphillPointSlice[1][len(UphillPointSlice[1])-1]}
+					distance := distance(P1, P2)
+					if distance >= 100 {
+						event_lable := "LongDownhill"
+						fmt.Println(event_lable)
+					}
+
+					UphillPointSlice = [][]float64{{}, {}}
+				}
+				CountNoneUphill = 0
+			}
+		}
+	}
+	count1++
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 148 - 0
main/pji_DGNC/LongTimeParallel/main/LongTimeParallel.go

@@ -0,0 +1,148 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func getMaxValue(slice []int) int {
+	max := slice[0]
+	for _, value := range slice {
+		if value > max {
+			max = value
+		}
+	}
+	return max
+}
+func isParallel(ObjectList [][]float32) bool {
+	numParallelslice := []int{0}
+	numParallel := 0
+lable1:
+	for i := 0; i < len(ObjectList[1]); i++ {
+		objx := ObjectList[0][i]
+		objy := ObjectList[1][i]
+		if math.Abs(float64(objx)) <= 2 && math.Abs(float64(objy)) <= 4.5 {
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objxj := ObjectList[0][1+i+j]
+				objyj := ObjectList[1][1+i+j]
+				if math.Abs(float64(objxj)) <= 2 && math.Abs(float64(objyj)) <= 4.5 {
+					numParallel++
+				} else {
+					i = i + j + 1
+					numParallelslice = append(numParallelslice, numParallel)
+					numParallel = 0
+					continue lable1
+				}
+			}
+			numParallelslice = append(numParallelslice, numParallel)
+			break lable1
+		} else {
+			i++
+		}
+	}
+	maxValue := getMaxValue(numParallelslice)
+	fmt.Println(maxValue)
+	if maxValue >= 100 {
+		return true
+	} else {
+		return false
+	}
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isParallel(objValue) || param.AbsSpeed <= 1 {
+			continue
+		}
+		event_lable := "LongTimeParallel"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 52 || math.Abs(float64(obj.Y)) >= 10 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 122 - 0
main/pji_DGNC/LongUphill/main/LongUphill.go

@@ -0,0 +1,122 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+// //道路坡度大于6%就可以被认为是陡坡
+var (
+	param            entity.PjisuvParam
+	threshold        = 0.05
+	count1           = 0
+	UphillPointSlice = [][]float64{{}, {}}
+	CountNoneUphill  = 0
+)
+
+type Point struct {
+	X float64
+	Y float64
+}
+
+func main() {
+	go listener()
+	for {
+		select {}
+	}
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+
+	d := math.Sqrt((point2.X-point1.X)*(point2.X-point1.X) + (point2.Y-point1.Y)*(point2.Y-point1.Y))
+
+	return d
+}
+
+// QuaternionToEuler 将四元数转换为欧拉角
+func QuaternionToEuler(x, y, z, w float64) float64 {
+	// 归一化四元数
+	length := math.Sqrt(x*x + y*y + z*z + w*w)
+	x /= length
+	y /= length
+	z /= length
+	w /= length
+	// 计算欧拉角
+	pitch := math.Asin(2 * (w*y - z*x))
+	if math.IsNaN(pitch) {
+		return 0.0
+	}
+	return pitch
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%1 == 0 {
+		pitch := QuaternionToEuler(data.Qx, data.Qy, data.Qz, data.Qw)
+		//fmt.Println(pitch)
+		if pitch >= threshold {
+			UphillPointSlice[0] = append(UphillPointSlice[0], data.PositionX)
+			UphillPointSlice[1] = append(UphillPointSlice[1], data.PositionY)
+			if len(UphillPointSlice[0]) > 250 {
+
+				P1 := Point{UphillPointSlice[0][0], UphillPointSlice[1][0]}
+				P2 := Point{UphillPointSlice[0][len(UphillPointSlice[0])-1], UphillPointSlice[1][len(UphillPointSlice[1])-1]}
+				distance := distance(P1, P2)
+				if distance >= 100 {
+					event_lable := "LongUphill"
+					fmt.Println(event_lable)
+				}
+				CountNoneUphill = 0
+				UphillPointSlice = [][]float64{{}, {}}
+			}
+		} else {
+			CountNoneUphill++
+			if CountNoneUphill == 4 {
+				if len(UphillPointSlice[0]) > 1 {
+					P1 := Point{UphillPointSlice[0][0], UphillPointSlice[1][0]}
+					P2 := Point{UphillPointSlice[0][len(UphillPointSlice[0])-1], UphillPointSlice[1][len(UphillPointSlice[1])-1]}
+					distance := distance(P1, P2)
+					if distance >= 100 {
+						event_lable := "LongUphill"
+						fmt.Println(event_lable)
+					}
+					UphillPointSlice = [][]float64{{}, {}}
+				}
+				CountNoneUphill = 0
+			}
+		}
+	}
+	count1++
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 85 - 0
main/pji_DGNC/NumTargetsExceedThreshold/main/NumTargetsExceedThreshold.go

@@ -0,0 +1,85 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"os"
+	"os/signal"
+)
+
+var param entity.PjisuvParam
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.VelocityXOfCicvLocation = data.VelocityX
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	NumTargets := 0
+	defer func() {
+		if r := recover(); r != nil {
+			fmt.Println("Recovered from panic:", r)
+		}
+	}()
+
+	if param.VelocityXOfCicvLocation > 0.5 && len(data.Objs) > 5 {
+		for _, obj := range data.Objs {
+			if obj.Type == 0 && obj.X >= 2 {
+				NumTargets++
+			}
+		}
+		//fmt.Println(NumTargets)
+		if NumTargets >= 5 {
+			//event_lable := "NumTargetsExceedThreshold"
+			fmt.Printf("NumTargetsExceedThreshold,%d Targets were found\n", NumTargets)
+		}
+	}
+
+}
+
+func main() {
+
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 143 - 0
main/pji_DGNC/OutOfLane/main/OutOfLane.go

@@ -0,0 +1,143 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+var (
+	param entity.PjisuvParam
+	//D1, D2, D3 = 3.813, 0.952, 1.086  真实数据
+	D1, D2, D3 = 1.0, 0.4, 0.4 //缩小后数据
+)
+
+type Point struct {
+	X, Y float64
+}
+
+func main() {
+
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+func getVehicleCorners(x0, y0, D1, D2, D3, h0 float64) []pjisuv_msgs.Point64 {
+	h0Rad := h0 * math.Pi / 180 // 转换角度到弧度
+	cosH0, sinH0 := math.Cos(h0Rad), math.Sin(h0Rad)
+
+	// 车辆四个角点相对于后轴中心点的坐标(局部坐标系)
+	cornersLocal := []Point{
+		{D1, D3},   // 前左角
+		{D1, -D3},  // 前右角
+		{-D2, D3},  // 后左角
+		{-D2, -D3}, // 后右角
+	}
+
+	// 旋转矩阵并计算全局坐标
+	rotationMatrix := [2][2]float64{{cosH0, -sinH0}, {sinH0, cosH0}}
+	cornersGlobal := make([]pjisuv_msgs.Point64, len(cornersLocal))
+	for i, corner := range cornersLocal {
+		cornersGlobal[i].X = corner.X*rotationMatrix[0][0] + corner.Y*rotationMatrix[1][0] + x0
+		cornersGlobal[i].Y = corner.X*rotationMatrix[0][1] + corner.Y*rotationMatrix[1][1] + y0
+	}
+	return cornersGlobal
+}
+
+func ccw(A, B, C pjisuv_msgs.Point64) bool {
+	return (C.Y-A.Y)*(B.X-A.X) > (C.X-A.X)*(B.Y-A.Y)
+}
+
+func lineIntersect(A, B, C, D pjisuv_msgs.Point64) bool {
+	return ccw(A, C, D) != ccw(B, C, D) && ccw(A, B, C) != ccw(A, B, D)
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.PositionXOfCicvLocation = data.PositionX
+	param.PositionYOfCicvLocation = data.PositionY
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+	param.YawOfCicvLocation = data.Yaw
+}
+func polygonLineIntersect(polygon []pjisuv_msgs.Point64, A, B pjisuv_msgs.Point64) bool {
+	for i := 0; i < len(polygon)-1; i++ {
+		C := polygon[i]
+		D := polygon[(i+1)%len(polygon)]
+		if lineIntersect(A, B, C, D) {
+			return true
+		}
+	}
+
+	return false
+}
+func CallbackMapPolygon(data *pjisuv_msgs.PolygonStamped) {
+	defer func() {
+		if r := recover(); r != nil {
+			fmt.Println("Recovered from panic:", r)
+		}
+	}()
+	Points := data.Polygon.Points
+	corners := getVehicleCorners(param.PositionXOfCicvLocation, param.PositionYOfCicvLocation, D1, D2, D3, param.YawOfCicvLocation)
+
+	for i := 0; i < len(Points)-1; i++ {
+		A := Points[i]
+		B := Points[i+1]
+		if polygonLineIntersect(corners, A, B) {
+			event_lable := "out_of_lane"
+			fmt.Printf("PositionX= %f\n", param.PositionXOfCicvLocation-457000.0)
+			fmt.Printf("PositionY= %f\n", param.PositionYOfCicvLocation-4400000.0)
+			//fmt.Printf("Latitude= %f\n", param.LatitudeOfCicvLocation)
+			//fmt.Printf("Longitude= %f\n", param.LongitudeOfCicvLocation)
+			fmt.Printf("Yow= %f\n", param.YawOfCicvLocation)
+			for i, corner := range corners {
+				fmt.Printf("corners %d ,X=%f ,Y=%f\n", i, corner.X-457000.0, corner.Y-4400000.0)
+			}
+			fmt.Printf(event_lable)
+			fmt.Println()
+
+		}
+	}
+
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subMapPolygon, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/map_polygon",
+		Callback: CallbackMapPolygon,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subMapPolygon.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 125 - 0
main/pji_DGNC/OutOperationZone/main/OutOperationZone.go

@@ -0,0 +1,125 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	x, y float64
+}
+
+var (
+	param    entity.PjisuvParam
+	vertices = []Point{
+		{x: 456095.447, y: 4397845.34},
+		{x: 456445.083, y: 4398067.52},
+		{x: 456536.143, y: 4397909.14},
+		{x: 456168.902, y: 4397709.52},
+	}
+)
+
+func isPointInPolygon(p Point, vertices []Point) bool {
+	intersections := 0
+	for i := 0; i < len(vertices); i++ {
+		j := (i + 1) % len(vertices)
+		if rayIntersectsSegment(p, vertices[i], vertices[j]) {
+			intersections++
+		}
+	}
+	return intersections%2 == 1
+}
+
+func rayIntersectsSegment(p, p1, p2 Point) bool {
+	if p1.y > p2.y {
+		p1, p2 = p2, p1
+	}
+	if p.y == p1.y || p.y == p2.y {
+		p.y += 0.0001
+	}
+
+	if p.y < p1.y || p.y > p2.y {
+		return false
+	}
+
+	if p.x > max(p1.x, p2.x) {
+		return false
+	}
+
+	if p.x < min(p1.x, p2.x) {
+		return true
+	}
+
+	blueSlope := (p.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y) + p1.x
+	return p.x < blueSlope
+}
+
+func min(a, b float64) float64 {
+	if a < b {
+		return a
+	}
+	return b
+}
+
+func max(a, b float64) float64 {
+	if a > b {
+		return a
+	}
+	return b
+}
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func FinalCallback() {
+
+	p := Point{x: param.PositionXOfCicvLocation, y: param.PositionYOfCicvLocation}
+	if !isPointInPolygon(p, vertices) {
+		eventLabel := "OutOperationZone"
+		fmt.Println(eventLabel)
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.PositionXOfCicvLocation = data.PositionX
+	param.PositionYOfCicvLocation = data.PositionY
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 80 - 0
main/pji_DGNC/OverspeedAtNight/main/OverspeedAtNight.go

@@ -0,0 +1,80 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	count     int64   = 0
+	threshold float64 = 25 / 3.6
+)
+
+func Ifatnight() bool {
+	// 获取当前时间
+	now := time.Now()
+	later := now.Add(0 * time.Hour)
+	// 获取当前小时
+	hour := later.Hour()
+	// 判断当前时间是白天还是夜晚
+	if hour >= 0 && hour < 5 || hour >= 20 && hour <= 23 {
+		return true
+	} else {
+		return false
+	}
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count%100 == 0 {
+		if Ifatnight() {
+			AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+			if AbsSpeed >= threshold {
+				eventLabel := "OverspeedAtNight"
+				fmt.Println(eventLabel)
+			}
+		}
+		count = 1
+	}
+	count++
+
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	//sort.Float64s(numbers)
+	//max := numbers[len(numbers)-1]
+	//fmt.Println("最大值为:", max)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 170 - 0
main/pji_DGNC/OvertakingInCurve/main/OvertakingInCurve.go

@@ -0,0 +1,170 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+	pointcurve  = Point{39.73004426154644, 116.49248639463602}
+	pointlist1  = []Point{pointcurve}
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func IsOvertaken(ObjectList [][]float32) bool {
+	if param.AbsSpeed > 0.2 {
+		//fmt.Println("yes")
+		//fmt.Println(ObjectList)
+		for i, objX := range ObjectList[0] {
+
+			if math.Abs(float64(ObjectList[1][i])) <= 8 && objX >= 2.5 {
+				for j := 0; j < len(ObjectList[0])-i-1; j++ {
+					if math.Abs(float64(ObjectList[1][1+i+j])) <= 8 && ObjectList[0][1+i+j] <= -1.5 {
+						return true
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+	if IfEnter(pointlist1, 50, param.LatitudeOfCicvLocation, param.LongitudeOfCicvLocation) {
+		//fmt.Println("here")
+		for _, objValue := range ObjectSlice {
+			//fmt.Println(ObjectSlice)
+			//fmt.Println(objValue)
+			//fmt.Println("------------------------------------------------")
+			Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+			if len(objValue[0]) <= 5 || !IsOvertaken(objValue) {
+				continue
+			}
+			event_lable := "OvertakingInCurve"
+			fmt.Println(event_lable)
+			ObjectSlice = make(map[uint32][][]float32)
+		}
+	}
+	//fmt.Println(Maxlenobj)
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+func max(a, b int32) int32 {
+	if a > b {
+		return a
+	}
+	return b
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+	param.LatitudeOfCicvLocation = data.Latitude
+	param.LongitudeOfCicvLocation = data.Longitude
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 50 || math.Abs(float64(obj.Y)) >= 60 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		//ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 129 - 0
main/pji_DGNC/OvertakingRight/main/OvertakingRight.go

@@ -0,0 +1,129 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	threshold   float64 = 3 / 3.6
+	Maxlenobj   int32   = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func IsOvertaken(ObjectList [][]float32) bool {
+	if param.AbsSpeed > threshold {
+		//fmt.Println("yes")
+		//fmt.Println(ObjectList)
+		for i, objX := range ObjectList[0] {
+			diffangle := math.Abs(param.YawOfCicvLocation - float64(ObjectList[2][i]))
+
+			if ObjectList[1][i] >= -0.6 && ObjectList[1][i] <= 4 && objX >= 2.5 && diffangle <= 90.0 {
+				for j := 0; j < len(ObjectList[0])-i-1; j++ {
+					if ObjectList[1][1+i+j] >= -0.6 && ObjectList[1][1+i+j] <= 4 && ObjectList[0][1+i+j] <= -1.0 {
+						return true
+					}
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+	//fmt.Println("here")
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(ObjectSlice)
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 5 || !IsOvertaken(objValue) {
+			continue
+		}
+		event_lable := "OvertakingRight"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+
+	//fmt.Println(Maxlenobj)
+	if Maxlenobj >= 120 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AbsSpeed = math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+	param.YawOfCicvLocation = data.Yaw
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 50 || math.Abs(float64(obj.Y)) >= 60 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Heading)
+		//ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 100 - 0
main/pji_DGNC/PassManholeCover/main/PassManholeCover.go

@@ -0,0 +1,100 @@
+package main
+
+import (
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+)
+
+type Point struct {
+	Latitude  float64
+	Longitude float64
+}
+
+var (
+	count1 int = 0
+
+	point2    = Point{39.73060110579319, 116.49026327601909}
+	point3    = Point{39.73095787789228, 116.49198510213326}
+	point4    = Point{39.72871897975558, 116.48974365387218}
+	point5    = Point{39.72837411970706, 116.48892518119638}
+	point6    = Point{39.729601922859594, 116.48834171309953}
+	pointlist = []Point{point2, point3, point4, point5, point6}
+)
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	if count1%10 == 0 {
+
+		enterflag := IfEnter(pointlist, 1.5, data.Latitude, data.Longitude)
+		if enterflag {
+			eventLabel := "EnterCover"
+			fmt.Println(eventLabel)
+		}
+	}
+	count1++
+}
+func IfEnter(pointlist []Point, radius float64, lat, lon float64) bool {
+	// 判断是否进入点列表中的区域
+	point1 := Point{Latitude: lat, Longitude: lon}
+	for _, point := range pointlist {
+		d := distance(point1, point)
+		if d <= radius {
+			return true
+		}
+	}
+	return false
+}
+
+// 计算两点之间的距离(米)
+func distance(point1, point2 Point) float64 {
+	// 经纬度转弧度
+	lat1 := point1.Latitude * math.Pi / 180
+	lon1 := point1.Longitude * math.Pi / 180
+	lat2 := point2.Latitude * math.Pi / 180
+	lon2 := point2.Longitude * math.Pi / 180
+
+	// 计算距离
+	dlon := lon2 - lon1
+	dlat := lat2 - lat1
+	a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Sin(dlon/2)*math.Sin(dlon/2)*math.Cos(lat1)*math.Cos(lat2)
+	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
+	d := 6371000 * c
+
+	return d
+}
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 120 - 0
main/pji_DGNC/RearTruckApproach/main/RearTruckApproach.go

@@ -0,0 +1,120 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isApproach(ObjectList [][]float32) bool {
+	for i, objX := range ObjectList[0] {
+
+		if ObjectList[3][i] == float32(3) && math.Abs(float64(ObjectList[1][i])) <= 1.5 && objX <= -9 {
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 1.5 && ObjectList[0][1+i+j] >= -4 && ObjectList[2][1+i+j] >= 1 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isApproach(objValue) {
+			continue
+		}
+		event_lable := "RearTruckApproach"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X >= 2 || math.Abs(float64(obj.Y)) >= 3 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+		ObjectSlice[obj.Id][3] = append(ObjectSlice[obj.Id][3], float32(obj.Type))
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 119 - 0
main/pji_DGNC/RearVehicleApproach/main/RearVehicleApproach.go

@@ -0,0 +1,119 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(3 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isApproach(ObjectList [][]float32) bool {
+	for i, objX := range ObjectList[0] {
+
+		if math.Abs(float64(ObjectList[1][i])) <= 1.5 && objX <= -9 {
+			for j := 0; j < len(ObjectList[0])-i-1; j++ {
+				if math.Abs(float64(ObjectList[1][1+i+j])) <= 1.5 && ObjectList[0][1+i+j] >= -4 && ObjectList[2][1+i+j] >= 1 {
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isApproach(objValue) {
+			continue
+		}
+		event_lable := "RearVehicleApproach"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 100 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if obj.X >= 2 || math.Abs(float64(obj.Y)) >= 3 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+		ObjectSlice[obj.Id][2] = append(ObjectSlice[obj.Id][2], obj.Vxrel)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 122 - 0
main/pji_DGNC/RearVehicleCutIn/main/RearVehicleCutIn.go

@@ -0,0 +1,122 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingIn(ObjectList [][]float32) bool {
+	for i := 0; i < len(ObjectList[1]); i++ {
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		if math.Abs(float64(yi)) >= 1.8 && xi < (-2.0) && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objxj := ObjectList[0][1+i+j]
+				objyj := ObjectList[1][1+i+j]
+				if math.Abs(float64(objyj)) <= 0.7 && objxj < (-2.0) && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+					//fmt.Println(objX)
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isCuttingIn(objValue) {
+			continue
+		}
+		event_lable := "RearVehicleCutIn"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 60 || math.Abs(float64(obj.Y)) >= 15 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 122 - 0
main/pji_DGNC/RearVehicleCutOut/main/RearVehicleCutOut.go

@@ -0,0 +1,122 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(2 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+
+func isCuttingIn(ObjectList [][]float32) bool {
+	for i := 0; i < len(ObjectList[1]); i++ {
+		xi := ObjectList[0][i]
+		yi := ObjectList[1][i]
+		if math.Abs(float64(yi)) <= 0.9 && xi < (-2.0) && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+			//fmt.Println(objY)
+			for j := 0; j < len(ObjectList[1])-i-1; j++ {
+				objxj := ObjectList[0][1+i+j]
+				objyj := ObjectList[1][1+i+j]
+				if math.Abs(float64(objyj)) >= 1.8 && objxj < (-2.0) && math.Abs(param.AngularVelocityZOfCicvLocation) <= 0.6 {
+					//fmt.Println(objX)
+					return true
+				}
+			}
+		}
+	}
+	return false
+}
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || !isCuttingIn(objValue) {
+			continue
+		}
+		event_lable := "RearVehicleCutOut"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 60 || math.Abs(float64(obj.Y)) >= 15 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 113 - 0
main/pji_DGNC/RearVehicleFollowingTooCloseHigh/main/RearVehicleFollowingTooCloseHigh.go

@@ -0,0 +1,113 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param       entity.PjisuvParam
+	StartTime   int64
+	count1      int64
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func IfObstaclesNearby() bool {
+	for _, obj := range ObjectSlice {
+		if obj[0][len(obj[0])-1] >= -13 && obj[0][len(obj[0])-1] <= -1 && (math.Abs(float64(obj[1][len(obj[1])-1]))) <= 2 {
+			return true
+
+		}
+	}
+	return false
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//print(param.AutomodeOfPjVehicleFdbPub)
+
+	if count1%10 == 0 {
+		AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+		flag := IfObstaclesNearby()
+		//fmt.Println(ObjectSlice)
+		if AbsSpeed >= 5 && flag {
+			// 如果之前没有记录开始时间,记录当前时间
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+			// 判断是否持续超过一分钟
+			if time.Now().Unix()-StartTime > 3 {
+				event_label := "RearVehicleFollowingTooCloseHigh"
+				fmt.Println(event_label)
+			}
+		} else {
+			// 如果速度大于 0.1,重置开始时间和停止标志
+			StartTime = 0
+		}
+		count1 = 1
+	} else {
+		count1++
+	}
+}
+
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.Y)) >= 90 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 113 - 0
main/pji_DGNC/RearVehicleFollowingTooCloseLow/main/RearVehicleFollowingTooCloseLow.go

@@ -0,0 +1,113 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	param       entity.PjisuvParam
+	StartTime   int64
+	count1      int64
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func IfObstaclesNearby() bool {
+	for _, obj := range ObjectSlice {
+		if obj[0][len(obj[0])-1] >= -13 && obj[0][len(obj[0])-1] <= -1 && (math.Abs(float64(obj[1][len(obj[1])-1]))) <= 2 {
+			return true
+
+		}
+	}
+	return false
+}
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	//print(param.AutomodeOfPjVehicleFdbPub)
+
+	if count1%10 == 0 {
+		AbsSpeed := math.Sqrt(math.Pow(data.VelocityX, 2) + math.Pow(data.VelocityY, 2))
+		flag := IfObstaclesNearby()
+		//fmt.Println(ObjectSlice)
+		if AbsSpeed >= 1 && AbsSpeed <= 4 && flag {
+			// 如果之前没有记录开始时间,记录当前时间
+			if StartTime == 0 {
+				StartTime = time.Now().Unix()
+			}
+			// 判断是否持续超过一分钟
+			if time.Now().Unix()-StartTime > 3 {
+				event_label := "RearVehicleFollowingTooCloseLow"
+				fmt.Println(event_label)
+			}
+		} else {
+			// 如果速度大于 0.1,重置开始时间和停止标志
+			StartTime = 0
+		}
+		count1 = 1
+	} else {
+		count1++
+	}
+}
+
+func main() {
+	go listener()
+	select {}
+	//time.Sleep(10000)
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.Y)) >= 90 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "/tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

+ 130 - 0
main/pji_DGNC/RearVehiclesFrequentChangeLane/main/RearVehiclesFrequentChangeLane.go

@@ -0,0 +1,130 @@
+package main
+
+import (
+	"awesomeProject/entity"
+	"awesomeProject/pjisuv_msgs"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2"
+	"math"
+	"os"
+	"os/signal"
+	"time"
+)
+
+var (
+	Maxlenobj   int32 = 0
+	param       entity.PjisuvParam
+	ObjectSlice = make(map[uint32][][]float32)
+)
+
+func main() {
+	ticker := time.NewTicker(4 * time.Second)
+	defer ticker.Stop()
+	go listener()
+	for {
+		select {
+		case <-ticker.C:
+			FinalCallback()
+		}
+	}
+}
+func countChanges(slice [][]float32) int {
+	//fmt.Println(slice)
+	count := 0
+lable1:
+	for i := 0; i < len(slice[1]); {
+		xi := slice[0][i]
+		yi := math.Abs(float64(slice[1][i]))
+		if (yi >= 1.8 || yi < 0.7) && xi <= -2 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 1.6 {
+			for j := 0; j < len(slice[1])-i-1; j++ {
+				xij := slice[0][1+i+j]
+				yij := math.Abs(float64(slice[1][1+i+j]))
+				if ((yi >= 1.8 && yij <= 0.7) || (yi < 0.7 && yij >= 1.8)) && xij <= -2 && math.Abs(param.AngularVelocityZOfCicvLocation) <= 1.6 {
+					count++
+					fmt.Println("here!!")
+					i = i + j + 1
+					continue lable1
+				}
+			}
+			break lable1
+		} else {
+			i++
+		}
+
+	}
+	return count
+}
+
+func FinalCallback() {
+
+	for _, objValue := range ObjectSlice {
+		//fmt.Println(objValue)
+		//fmt.Println("------------------------------------------------")
+		Maxlenobj = max(Maxlenobj, int32(len(objValue[0])))
+		if len(objValue[0]) <= 10 || countChanges(objValue) < 2 {
+			continue
+		}
+		event_lable := "RearVehiclesFrequentChangeLane"
+		fmt.Println(event_lable)
+		ObjectSlice = make(map[uint32][][]float32)
+	}
+	if Maxlenobj >= 250 {
+		ObjectSlice = make(map[uint32][][]float32)
+		Maxlenobj = 0
+	}
+}
+
+func CallbackCicvLocation(data *pjisuv_msgs.PerceptionLocalization) {
+	param.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
+}
+func CallbackTpperception(data *pjisuv_msgs.PerceptionObjects) {
+	for _, obj := range data.Objs {
+		if math.Abs(float64(obj.X)) >= 60 || math.Abs(float64(obj.Y)) >= 10 {
+			continue
+		}
+		if _, ok := ObjectSlice[obj.Id]; !ok {
+			ObjectSlice[obj.Id] = [][]float32{{}, {}}
+		}
+		ObjectSlice[obj.Id][0] = append(ObjectSlice[obj.Id][0], obj.X)
+		ObjectSlice[obj.Id][1] = append(ObjectSlice[obj.Id][1], obj.Y)
+	}
+}
+func listener() {
+	// create a node and connect to the master
+	n, err := goroslib.NewNode(goroslib.NodeConf{
+		Name:          "goroslib_sub",
+		MasterAddress: "127.0.0.1:11311",
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer n.Close()
+
+	// create a subscriber
+	subCicvLocation, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+		Node:     n,
+		Topic:    "/cicv_location",
+		Callback: CallbackCicvLocation,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subCicvLocation.Close()
+
+	// create a subscriber
+	subTpperception, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
+
+		Node:     n,
+		Topic:    "tpperception",
+		Callback: CallbackTpperception,
+	})
+	if err != nil {
+		panic(err)
+	}
+	defer subTpperception.Close()
+
+	// wait for CTRL-C
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt)
+	<-c
+}

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor