trigger_init.go 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. package config
  2. import (
  3. "cicv-data-closedloop/aarch64/pjisuv/common/config"
  4. "cicv-data-closedloop/common/config/c_log"
  5. "cicv-data-closedloop/common/util"
  6. "cicv-data-closedloop/pjisuv_msgs"
  7. entity "cicv-data-closedloop/pjisuv_param"
  8. "github.com/bluenviron/goroslib/v2/pkg/msgs/geometry_msgs"
  9. "github.com/bluenviron/goroslib/v2/pkg/msgs/nav_msgs"
  10. "github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
  11. "github.com/bluenviron/goroslib/v2/pkg/msgs/tf2_msgs"
  12. "github.com/bluenviron/goroslib/v2/pkg/msgs/visualization_msgs"
  13. "plugin"
  14. "slices"
  15. "sync"
  16. )
  17. func InitTriggerConfig() {
  18. config.OssMutex.Lock()
  19. defer config.OssMutex.Unlock()
  20. triggerLocalPathsMapTriggerId := make(map[string]string)
  21. c_log.GlobalLogger.Info("主节点加载触发器插件 - 开始。")
  22. // 1 获取数采任务的触发器列表
  23. cloudTriggers := &config.PlatformConfig.TaskTriggers
  24. // 2 获取本地触发器列表(触发器目录的一级子目录为【触发器ID_触发器Label】)
  25. localTriggerIds := util.GetFirstLevelSubdirectories(config.CloudConfig.TriggersDir)
  26. // 3 对比触发器列表,本地没有的则下载
  27. for _, trigger := range *cloudTriggers {
  28. id := util.ToString(trigger.TriggerId)
  29. hasIdDir := slices.Contains(localTriggerIds, id) // 改成了 slices 工具库
  30. triggerLocalDir := config.CloudConfig.TriggersDir + id + "/"
  31. hasLabelSo, soPaths := util.CheckSoFilesInDirectory(triggerLocalDir)
  32. var triggerLocalPath string
  33. if hasIdDir && hasLabelSo { // 已存在的触发器需要判断是否大小一致
  34. triggerLocalPath = soPaths[0]
  35. ossSize, _ := util.GetOSSFileSize(config.OssBucket, trigger.TriggerScriptPath)
  36. localSize, _ := util.GetFileSize(triggerLocalPath)
  37. if ossSize == localSize {
  38. c_log.GlobalLogger.Info("触发器插件 ", triggerLocalPath, " 存在且与云端触发器大小一致。")
  39. triggerLocalPathsMapTriggerId[triggerLocalPath] = id
  40. continue
  41. }
  42. }
  43. label := util.GetFileNameWithoutExtension(config.CloudConfig.TriggersDir + trigger.TriggerScriptPath)
  44. triggerLocalPath = config.CloudConfig.TriggersDir + id + "/" + label + ".so"
  45. c_log.GlobalLogger.Info("开始下载触发器插件从 ", trigger.TriggerScriptPath, " 到 ", triggerLocalPath)
  46. _ = util.CreateParentDir(triggerLocalPath)
  47. for {
  48. if err := config.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath); err != nil {
  49. c_log.GlobalLogger.Error("下载触发器插件失败,再次尝试:", err)
  50. continue
  51. }
  52. break
  53. }
  54. triggerLocalPathsMapTriggerId[triggerLocalPath] = id
  55. }
  56. success := 0
  57. // 加载所有触发器的文件
  58. for triggerLocalPath, triggerId := range triggerLocalPathsMapTriggerId {
  59. // 载入插件到数组
  60. open, err := plugin.Open(triggerLocalPath)
  61. if err != nil {
  62. c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "失败。", err)
  63. continue
  64. }
  65. topic0, err := open.Lookup("Topic")
  66. if err != nil {
  67. c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Topic方法失败。", err)
  68. continue
  69. }
  70. topic1, ok := topic0.(func() string)
  71. if ok != true {
  72. c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func() string):", err)
  73. continue
  74. }
  75. topic2 := topic1()
  76. rule, err := open.Lookup("Rule")
  77. if err != nil {
  78. c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Rule方法失败。", err)
  79. continue
  80. }
  81. if TopicOfCicvExtend == topic2 { // 自定义扩展
  82. if f, ok1 := rule.(func(param entity.PjisuvParam) string); ok1 {
  83. RuleOfCicvExtend = append(RuleOfCicvExtend, f)
  84. goto JudgeDone
  85. }
  86. continue
  87. } else if TopicOfAmrPose == topic2 { //1
  88. if f, ok1 := rule.(func(data *visualization_msgs.MarkerArray) string); ok1 {
  89. RuleOfAmrPose1 = append(RuleOfAmrPose1, f)
  90. goto JudgeDone
  91. }
  92. if f, ok2 := rule.(func(data *visualization_msgs.MarkerArray, param *entity.PjisuvParam) string); ok2 {
  93. RuleOfAmrPose2 = append(RuleOfAmrPose2, f)
  94. goto JudgeDone
  95. }
  96. if f, ok3 := rule.(func(shareVars *sync.Map, data *visualization_msgs.MarkerArray) string); ok3 {
  97. RuleOfAmrPose3 = append(RuleOfAmrPose3, f)
  98. goto JudgeDone
  99. }
  100. log(triggerLocalPath)
  101. continue
  102. } else if TopicOfBoundingBoxesFast == topic2 { //2
  103. if f, ok1 := rule.(func(data *pjisuv_msgs.BoundingBoxArray) string); ok1 {
  104. RuleOfBoundingBoxesFast1 = append(RuleOfBoundingBoxesFast1, f)
  105. goto JudgeDone
  106. }
  107. if f, ok2 := rule.(func(data *pjisuv_msgs.BoundingBoxArray, param *entity.PjisuvParam) string); ok2 {
  108. RuleOfBoundingBoxesFast2 = append(RuleOfBoundingBoxesFast2, f)
  109. goto JudgeDone
  110. }
  111. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.BoundingBoxArray) string); ok3 {
  112. RuleOfBoundingBoxesFast3 = append(RuleOfBoundingBoxesFast3, f)
  113. goto JudgeDone
  114. }
  115. log(triggerLocalPath)
  116. continue
  117. } else if TopicOfCameraFault == topic2 { //3
  118. if f, ok1 := rule.(func(data *pjisuv_msgs.FaultVec) string); ok1 {
  119. RuleOfCameraFault1 = append(RuleOfCameraFault1, f)
  120. goto JudgeDone
  121. }
  122. if f, ok2 := rule.(func(data *pjisuv_msgs.FaultVec, param *entity.PjisuvParam) string); ok2 {
  123. RuleOfCameraFault2 = append(RuleOfCameraFault2, f)
  124. goto JudgeDone
  125. }
  126. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.FaultVec) string); ok3 {
  127. RuleOfCameraFault3 = append(RuleOfCameraFault3, f)
  128. goto JudgeDone
  129. }
  130. log(triggerLocalPath)
  131. continue
  132. } else if TopicOfCanData == topic2 { //4
  133. if f, ok1 := rule.(func(data *pjisuv_msgs.Frame) string); ok1 {
  134. RuleOfCanData1 = append(RuleOfCanData1, f)
  135. goto JudgeDone
  136. }
  137. if f, ok2 := rule.(func(data *pjisuv_msgs.Frame, param *entity.PjisuvParam) string); ok2 {
  138. RuleOfCanData2 = append(RuleOfCanData2, f)
  139. goto JudgeDone
  140. }
  141. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.Frame) string); ok3 {
  142. RuleOfCanData3 = append(RuleOfCanData3, f)
  143. goto JudgeDone
  144. }
  145. log(triggerLocalPath)
  146. continue
  147. } else if TopicOfCh128x1LslidarPointCloud == topic2 { //5
  148. if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
  149. RuleOfCh128x1LslidarPointCloud1 = append(RuleOfCh128x1LslidarPointCloud1, f)
  150. goto JudgeDone
  151. }
  152. if f, ok2 := rule.(func(data *sensor_msgs.PointCloud2, param *entity.PjisuvParam) string); ok2 {
  153. RuleOfCh128x1LslidarPointCloud2 = append(RuleOfCh128x1LslidarPointCloud2, f)
  154. goto JudgeDone
  155. }
  156. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
  157. RuleOfCh128x1LslidarPointCloud3 = append(RuleOfCh128x1LslidarPointCloud3, f)
  158. goto JudgeDone
  159. }
  160. log(triggerLocalPath)
  161. continue
  162. } else if TopicOfCh64wLLslidarPointCloud == topic2 { //6
  163. if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
  164. RuleOfCh64wLLslidarPointCloud1 = append(RuleOfCh64wLLslidarPointCloud1, f)
  165. goto JudgeDone
  166. }
  167. if f, ok2 := rule.(func(data *sensor_msgs.PointCloud2, param *entity.PjisuvParam) string); ok2 {
  168. RuleOfCh64wLLslidarPointCloud2 = append(RuleOfCh64wLLslidarPointCloud2, f)
  169. goto JudgeDone
  170. }
  171. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
  172. RuleOfCh64wLLslidarPointCloud3 = append(RuleOfCh64wLLslidarPointCloud3, f)
  173. goto JudgeDone
  174. }
  175. log(triggerLocalPath)
  176. continue
  177. } else if TopicOfCh64wLScan == topic2 { //7
  178. if f, ok1 := rule.(func(data *sensor_msgs.LaserScan) string); ok1 {
  179. RuleOfCh64wLScan1 = append(RuleOfCh64wLScan1, f)
  180. goto JudgeDone
  181. }
  182. if f, ok2 := rule.(func(data *sensor_msgs.LaserScan, param *entity.PjisuvParam) string); ok2 {
  183. RuleOfCh64wLScan2 = append(RuleOfCh64wLScan2, f)
  184. goto JudgeDone
  185. }
  186. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.LaserScan) string); ok3 {
  187. RuleOfCh64wLScan3 = append(RuleOfCh64wLScan3, f)
  188. goto JudgeDone
  189. }
  190. log(triggerLocalPath)
  191. continue
  192. } else if TopicOfCh64wRLslidarPointCloud == topic2 { //8
  193. if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
  194. RuleOfCh64wRLslidarPointCloud1 = append(RuleOfCh64wRLslidarPointCloud1, f)
  195. goto JudgeDone
  196. }
  197. if f, ok2 := rule.(func(data *sensor_msgs.PointCloud2, param *entity.PjisuvParam) string); ok2 {
  198. RuleOfCh64wRLslidarPointCloud2 = append(RuleOfCh64wRLslidarPointCloud2, f)
  199. goto JudgeDone
  200. }
  201. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
  202. RuleOfCh64wRLslidarPointCloud3 = append(RuleOfCh64wRLslidarPointCloud3, f)
  203. goto JudgeDone
  204. }
  205. log(triggerLocalPath)
  206. continue
  207. } else if TopicOfCh64wRScan == topic2 { //9
  208. if f, ok1 := rule.(func(data *sensor_msgs.LaserScan) string); ok1 {
  209. RuleOfCh64wRScan1 = append(RuleOfCh64wRScan1, f)
  210. goto JudgeDone
  211. }
  212. if f, ok2 := rule.(func(data *sensor_msgs.LaserScan, param *entity.PjisuvParam) string); ok2 {
  213. RuleOfCh64wRScan2 = append(RuleOfCh64wRScan2, f)
  214. goto JudgeDone
  215. }
  216. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.LaserScan) string); ok3 {
  217. RuleOfCh64wRScan3 = append(RuleOfCh64wRScan3, f)
  218. goto JudgeDone
  219. }
  220. log(triggerLocalPath)
  221. continue
  222. } else if TopicOfCicvLidarclusterMovingObjects == topic2 { //10
  223. if f, ok1 := rule.(func(data *pjisuv_msgs.PerceptionCicvMovingObjects) string); ok1 {
  224. RuleOfCicvLidarclusterMovingObjects1 = append(RuleOfCicvLidarclusterMovingObjects1, f)
  225. goto JudgeDone
  226. }
  227. if f, ok2 := rule.(func(data *pjisuv_msgs.PerceptionCicvMovingObjects, param *entity.PjisuvParam) string); ok2 {
  228. RuleOfCicvLidarclusterMovingObjects2 = append(RuleOfCicvLidarclusterMovingObjects2, f)
  229. goto JudgeDone
  230. }
  231. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PerceptionCicvMovingObjects) string); ok3 {
  232. RuleOfCicvLidarclusterMovingObjects3 = append(RuleOfCicvLidarclusterMovingObjects3, f)
  233. goto JudgeDone
  234. }
  235. log(triggerLocalPath)
  236. continue
  237. } else if TopicOfCicvAmrTrajectory == topic2 { //11
  238. if f, ok1 := rule.(func(data *pjisuv_msgs.Trajectory) string); ok1 {
  239. RuleOfCicvAmrTrajectory1 = append(RuleOfCicvAmrTrajectory1, f)
  240. goto JudgeDone
  241. }
  242. if f, ok2 := rule.(func(data *pjisuv_msgs.Trajectory, param *entity.PjisuvParam) string); ok2 {
  243. RuleOfCicvAmrTrajectory2 = append(RuleOfCicvAmrTrajectory2, f)
  244. goto JudgeDone
  245. }
  246. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.Trajectory) string); ok3 {
  247. RuleOfCicvAmrTrajectory3 = append(RuleOfCicvAmrTrajectory3, f)
  248. goto JudgeDone
  249. }
  250. log(triggerLocalPath)
  251. continue
  252. } else if TopicOfCicvLocation == topic2 { //12
  253. if f, ok1 := rule.(func(data *pjisuv_msgs.PerceptionLocalization) string); ok1 {
  254. RuleOfCicvLocation1 = append(RuleOfCicvLocation1, f)
  255. goto JudgeDone
  256. }
  257. if f, ok2 := rule.(func(data *pjisuv_msgs.PerceptionLocalization, param *entity.PjisuvParam) string); ok2 {
  258. RuleOfCicvLocation2 = append(RuleOfCicvLocation2, f)
  259. goto JudgeDone
  260. }
  261. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string); ok3 {
  262. RuleOfCicvLocation3 = append(RuleOfCicvLocation3, f)
  263. goto JudgeDone
  264. }
  265. log(triggerLocalPath)
  266. continue
  267. } else if TopicOfCloudClusters == topic2 { //13
  268. if f, ok1 := rule.(func(data *pjisuv_msgs.AutowareCloudClusterArray) string); ok1 {
  269. RuleOfCloudClusters1 = append(RuleOfCloudClusters1, f)
  270. goto JudgeDone
  271. }
  272. if f, ok2 := rule.(func(data *pjisuv_msgs.AutowareCloudClusterArray, param *entity.PjisuvParam) string); ok2 {
  273. RuleOfCloudClusters2 = append(RuleOfCloudClusters2, f)
  274. goto JudgeDone
  275. }
  276. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.AutowareCloudClusterArray) string); ok3 {
  277. RuleOfCloudClusters3 = append(RuleOfCloudClusters3, f)
  278. goto JudgeDone
  279. }
  280. log(triggerLocalPath)
  281. continue
  282. } else if TopicOfHeartbeatInfo == topic2 { //14
  283. if f, ok1 := rule.(func(data *pjisuv_msgs.HeartBeatInfo) string); ok1 {
  284. RuleOfHeartbeatInfo1 = append(RuleOfHeartbeatInfo1, f)
  285. goto JudgeDone
  286. }
  287. if f, ok2 := rule.(func(data *pjisuv_msgs.HeartBeatInfo, param *entity.PjisuvParam) string); ok2 {
  288. RuleOfHeartbeatInfo2 = append(RuleOfHeartbeatInfo2, f)
  289. goto JudgeDone
  290. }
  291. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.HeartBeatInfo) string); ok3 {
  292. RuleOfHeartbeatInfo3 = append(RuleOfHeartbeatInfo3, f)
  293. goto JudgeDone
  294. }
  295. log(triggerLocalPath)
  296. continue
  297. } else if TopicOfLidarPretreatmentCost == topic2 { //15
  298. if f, ok1 := rule.(func(data *geometry_msgs.Vector3Stamped) string); ok1 {
  299. RuleOfLidarPretreatmentCost1 = append(RuleOfLidarPretreatmentCost1, f)
  300. goto JudgeDone
  301. }
  302. if f, ok2 := rule.(func(data *geometry_msgs.Vector3Stamped, param *entity.PjisuvParam) string); ok2 {
  303. RuleOfLidarPretreatmentCost2 = append(RuleOfLidarPretreatmentCost2, f)
  304. goto JudgeDone
  305. }
  306. if f, ok3 := rule.(func(shareVars *sync.Map, data *geometry_msgs.Vector3Stamped) string); ok3 {
  307. RuleOfLidarPretreatmentCost3 = append(RuleOfLidarPretreatmentCost3, f)
  308. goto JudgeDone
  309. }
  310. log(triggerLocalPath)
  311. continue
  312. } else if TopicOfLidarPretreatmentOdometry == topic2 { //16
  313. if f, ok1 := rule.(func(data *nav_msgs.Odometry) string); ok1 {
  314. RuleOfLidarPretreatmentOdometry1 = append(RuleOfLidarPretreatmentOdometry1, f)
  315. goto JudgeDone
  316. }
  317. if f, ok2 := rule.(func(data *nav_msgs.Odometry, param *entity.PjisuvParam) string); ok2 {
  318. RuleOfLidarPretreatmentOdometry2 = append(RuleOfLidarPretreatmentOdometry2, f)
  319. goto JudgeDone
  320. }
  321. if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Odometry) string); ok3 {
  322. RuleOfLidarPretreatmentOdometry3 = append(RuleOfLidarPretreatmentOdometry3, f)
  323. goto JudgeDone
  324. }
  325. log(triggerLocalPath)
  326. continue
  327. } else if TopicOfLidarRoi == topic2 { //17
  328. if f, ok1 := rule.(func(data *geometry_msgs.PolygonStamped) string); ok1 {
  329. RuleOfLidarRoi1 = append(RuleOfLidarRoi1, f)
  330. goto JudgeDone
  331. }
  332. if f, ok2 := rule.(func(data *geometry_msgs.PolygonStamped, param *entity.PjisuvParam) string); ok2 {
  333. RuleOfLidarRoi2 = append(RuleOfLidarRoi2, f)
  334. goto JudgeDone
  335. }
  336. if f, ok3 := rule.(func(shareVars *sync.Map, data *geometry_msgs.PolygonStamped) string); ok3 {
  337. RuleOfLidarRoi3 = append(RuleOfLidarRoi3, f)
  338. goto JudgeDone
  339. }
  340. log(triggerLocalPath)
  341. continue
  342. } else if TopicOfLine1 == topic2 { //18
  343. if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
  344. RuleOfLine11 = append(RuleOfLine11, f)
  345. goto JudgeDone
  346. }
  347. if f, ok2 := rule.(func(data *nav_msgs.Path, param *entity.PjisuvParam) string); ok2 {
  348. RuleOfLine12 = append(RuleOfLine12, f)
  349. goto JudgeDone
  350. }
  351. if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
  352. RuleOfLine13 = append(RuleOfLine13, f)
  353. goto JudgeDone
  354. }
  355. log(triggerLocalPath)
  356. continue
  357. } else if TopicOfLine2 == topic2 { //19
  358. if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
  359. RuleOfLine21 = append(RuleOfLine21, f)
  360. goto JudgeDone
  361. }
  362. if f, ok2 := rule.(func(data *nav_msgs.Path, param *entity.PjisuvParam) string); ok2 {
  363. RuleOfLine22 = append(RuleOfLine22, f)
  364. goto JudgeDone
  365. }
  366. if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
  367. RuleOfLine23 = append(RuleOfLine23, f)
  368. goto JudgeDone
  369. }
  370. log(triggerLocalPath)
  371. continue
  372. } else if TopicOfMapPolygon == topic2 { //20
  373. if f, ok1 := rule.(func(data *pjisuv_msgs.PolygonStamped) string); ok1 {
  374. RuleOfMapPolygon1 = append(RuleOfMapPolygon1, f)
  375. goto JudgeDone
  376. }
  377. if f, ok2 := rule.(func(data *pjisuv_msgs.PolygonStamped, param *entity.PjisuvParam) string); ok2 {
  378. RuleOfMapPolygon2 = append(RuleOfMapPolygon2, f)
  379. goto JudgeDone
  380. }
  381. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PolygonStamped) string); ok3 {
  382. RuleOfMapPolygon3 = append(RuleOfMapPolygon3, f)
  383. goto JudgeDone
  384. }
  385. log(triggerLocalPath)
  386. continue
  387. } else if TopicOfObstacleDisplay == topic2 { //21
  388. if f, ok1 := rule.(func(data *visualization_msgs.MarkerArray) string); ok1 {
  389. RuleOfObstacleDisplay1 = append(RuleOfObstacleDisplay1, f)
  390. goto JudgeDone
  391. }
  392. if f, ok2 := rule.(func(data *visualization_msgs.MarkerArray, param *entity.PjisuvParam) string); ok2 {
  393. RuleOfObstacleDisplay2 = append(RuleOfObstacleDisplay2, f)
  394. goto JudgeDone
  395. }
  396. if f, ok3 := rule.(func(shareVars *sync.Map, data *visualization_msgs.MarkerArray) string); ok3 {
  397. RuleOfObstacleDisplay3 = append(RuleOfObstacleDisplay3, f)
  398. goto JudgeDone
  399. }
  400. log(triggerLocalPath)
  401. continue
  402. } else if TopicOfPjControlPub == topic2 { //22
  403. if f, ok1 := rule.(func(data *pjisuv_msgs.CommonVehicleCmd) string); ok1 {
  404. RuleOfPjControlPub1 = append(RuleOfPjControlPub1, f)
  405. goto JudgeDone
  406. }
  407. if f, ok2 := rule.(func(data *pjisuv_msgs.CommonVehicleCmd, param *entity.PjisuvParam) string); ok2 {
  408. RuleOfPjControlPub2 = append(RuleOfPjControlPub2, f)
  409. goto JudgeDone
  410. }
  411. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.CommonVehicleCmd) string); ok3 {
  412. RuleOfPjControlPub3 = append(RuleOfPjControlPub3, f)
  413. goto JudgeDone
  414. }
  415. log(triggerLocalPath)
  416. continue
  417. } else if TopicOfPointsCluster == topic2 { //23
  418. if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
  419. RuleOfPointsCluster1 = append(RuleOfPointsCluster1, f)
  420. goto JudgeDone
  421. }
  422. if f, ok2 := rule.(func(data *sensor_msgs.PointCloud2, param *entity.PjisuvParam) string); ok2 {
  423. RuleOfPointsCluster2 = append(RuleOfPointsCluster2, f)
  424. goto JudgeDone
  425. }
  426. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
  427. RuleOfPointsCluster3 = append(RuleOfPointsCluster3, f)
  428. goto JudgeDone
  429. }
  430. log(triggerLocalPath)
  431. continue
  432. } else if TopicOfPointsConcat == topic2 { //24
  433. if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
  434. RuleOfPointsConcat1 = append(RuleOfPointsConcat1, f)
  435. goto JudgeDone
  436. }
  437. if f, ok2 := rule.(func(data *sensor_msgs.PointCloud2, param *entity.PjisuvParam) string); ok2 {
  438. RuleOfPointsConcat2 = append(RuleOfPointsConcat2, f)
  439. goto JudgeDone
  440. }
  441. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
  442. RuleOfPointsConcat3 = append(RuleOfPointsConcat3, f)
  443. goto JudgeDone
  444. }
  445. log(triggerLocalPath)
  446. continue
  447. } else if TopicOfReferenceDisplay == topic2 { //25
  448. if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
  449. RuleOfReferenceDisplay1 = append(RuleOfReferenceDisplay1, f)
  450. goto JudgeDone
  451. }
  452. if f, ok2 := rule.(func(data *nav_msgs.Path, param *entity.PjisuvParam) string); ok2 {
  453. RuleOfReferenceDisplay2 = append(RuleOfReferenceDisplay2, f)
  454. goto JudgeDone
  455. }
  456. if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
  457. RuleOfReferenceDisplay3 = append(RuleOfReferenceDisplay3, f)
  458. goto JudgeDone
  459. }
  460. log(triggerLocalPath)
  461. continue
  462. } else if TopicOfReferenceTrajectory == topic2 { //26
  463. if f, ok1 := rule.(func(data *pjisuv_msgs.Trajectory) string); ok1 {
  464. RuleOfReferenceTrajectory1 = append(RuleOfReferenceTrajectory1, f)
  465. goto JudgeDone
  466. }
  467. if f, ok2 := rule.(func(data *pjisuv_msgs.Trajectory, param *entity.PjisuvParam) string); ok2 {
  468. RuleOfReferenceTrajectory2 = append(RuleOfReferenceTrajectory2, f)
  469. goto JudgeDone
  470. }
  471. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.Trajectory) string); ok3 {
  472. RuleOfReferenceTrajectory3 = append(RuleOfReferenceTrajectory3, f)
  473. goto JudgeDone
  474. }
  475. log(triggerLocalPath)
  476. continue
  477. } else if TopicOfRoiPoints == topic2 { //27
  478. if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
  479. RuleOfRoiPoints1 = append(RuleOfRoiPoints1, f)
  480. goto JudgeDone
  481. }
  482. if f, ok2 := rule.(func(data *sensor_msgs.PointCloud2, param *entity.PjisuvParam) string); ok2 {
  483. RuleOfRoiPoints2 = append(RuleOfRoiPoints2, f)
  484. goto JudgeDone
  485. }
  486. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
  487. RuleOfRoiPoints3 = append(RuleOfRoiPoints3, f)
  488. goto JudgeDone
  489. }
  490. log(triggerLocalPath)
  491. continue
  492. } else if TopicOfRoiPolygon == topic2 { //28
  493. if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
  494. RuleOfRoiPolygon1 = append(RuleOfRoiPolygon1, f)
  495. goto JudgeDone
  496. }
  497. if f, ok2 := rule.(func(data *nav_msgs.Path, param *entity.PjisuvParam) string); ok2 {
  498. RuleOfRoiPolygon2 = append(RuleOfRoiPolygon2, f)
  499. goto JudgeDone
  500. }
  501. if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
  502. RuleOfRoiPolygon3 = append(RuleOfRoiPolygon3, f)
  503. goto JudgeDone
  504. }
  505. log(triggerLocalPath)
  506. continue
  507. } else if TopicOfTf == topic2 { //29
  508. if f, ok1 := rule.(func(data *tf2_msgs.TFMessage) string); ok1 {
  509. RuleOfTf1 = append(RuleOfTf1, f)
  510. goto JudgeDone
  511. }
  512. if f, ok2 := rule.(func(data *tf2_msgs.TFMessage, param *entity.PjisuvParam) string); ok2 {
  513. RuleOfTf2 = append(RuleOfTf2, f)
  514. goto JudgeDone
  515. }
  516. if f, ok3 := rule.(func(shareVars *sync.Map, data *tf2_msgs.TFMessage) string); ok3 {
  517. RuleOfTf3 = append(RuleOfTf3, f)
  518. goto JudgeDone
  519. }
  520. log(triggerLocalPath)
  521. continue
  522. } else if TopicOfTpperception == topic2 { //30
  523. if f, ok1 := rule.(func(data *pjisuv_msgs.PerceptionObjects) string); ok1 {
  524. RuleOfTpperception1 = append(RuleOfTpperception1, f)
  525. goto JudgeDone
  526. }
  527. if f, ok2 := rule.(func(data *pjisuv_msgs.PerceptionObjects, param *entity.PjisuvParam) string); ok2 {
  528. RuleOfTpperception2 = append(RuleOfTpperception2, f)
  529. goto JudgeDone
  530. }
  531. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string); ok3 {
  532. RuleOfTpperception3 = append(RuleOfTpperception3, f)
  533. goto JudgeDone
  534. }
  535. log(triggerLocalPath)
  536. continue
  537. } else if TopicOfTpperceptionVis == topic2 { //31
  538. if f, ok1 := rule.(func(data *visualization_msgs.MarkerArray) string); ok1 {
  539. RuleOfTpperceptionVis1 = append(RuleOfTpperceptionVis1, f)
  540. goto JudgeDone
  541. }
  542. if f, ok2 := rule.(func(data *visualization_msgs.MarkerArray, param *entity.PjisuvParam) string); ok2 {
  543. RuleOfTpperceptionVis2 = append(RuleOfTpperceptionVis2, f)
  544. goto JudgeDone
  545. }
  546. if f, ok3 := rule.(func(shareVars *sync.Map, data *visualization_msgs.MarkerArray) string); ok3 {
  547. RuleOfTpperceptionVis3 = append(RuleOfTpperceptionVis3, f)
  548. goto JudgeDone
  549. }
  550. log(triggerLocalPath)
  551. continue
  552. } else if TopicOfTprouteplan == topic2 { //32
  553. if f, ok1 := rule.(func(data *pjisuv_msgs.RoutePlan) string); ok1 {
  554. RuleOfTprouteplan1 = append(RuleOfTprouteplan1, f)
  555. goto JudgeDone
  556. }
  557. if f, ok2 := rule.(func(data *pjisuv_msgs.RoutePlan, param *entity.PjisuvParam) string); ok2 {
  558. RuleOfTprouteplan2 = append(RuleOfTprouteplan2, f)
  559. goto JudgeDone
  560. }
  561. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.RoutePlan) string); ok3 {
  562. RuleOfTprouteplan3 = append(RuleOfTprouteplan3, f)
  563. goto JudgeDone
  564. }
  565. log(triggerLocalPath)
  566. continue
  567. } else if TopicOfTrajectoryDisplay == topic2 { //33
  568. if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
  569. RuleOfTrajectoryDisplay1 = append(RuleOfTrajectoryDisplay1, f)
  570. goto JudgeDone
  571. }
  572. if f, ok2 := rule.(func(data *nav_msgs.Path, param *entity.PjisuvParam) string); ok2 {
  573. RuleOfTrajectoryDisplay2 = append(RuleOfTrajectoryDisplay2, f)
  574. goto JudgeDone
  575. }
  576. if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
  577. RuleOfTrajectoryDisplay3 = append(RuleOfTrajectoryDisplay3, f)
  578. goto JudgeDone
  579. }
  580. log(triggerLocalPath)
  581. continue
  582. } else if TopicOfUngroundCloudpoints == topic2 { //34
  583. if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
  584. RuleOfUngroundCloudpoints1 = append(RuleOfUngroundCloudpoints1, f)
  585. goto JudgeDone
  586. }
  587. if f, ok2 := rule.(func(data *sensor_msgs.PointCloud2, param *entity.PjisuvParam) string); ok2 {
  588. RuleOfUngroundCloudpoints2 = append(RuleOfUngroundCloudpoints2, f)
  589. goto JudgeDone
  590. }
  591. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
  592. RuleOfUngroundCloudpoints3 = append(RuleOfUngroundCloudpoints3, f)
  593. goto JudgeDone
  594. }
  595. log(triggerLocalPath)
  596. continue
  597. } else if TopicOfCameraImage == topic2 { //35
  598. if f, ok1 := rule.(func(data *sensor_msgs.Image) string); ok1 {
  599. RuleOfCameraImage1 = append(RuleOfCameraImage1, f)
  600. goto JudgeDone
  601. }
  602. if f, ok2 := rule.(func(data *sensor_msgs.Image, param *entity.PjisuvParam) string); ok2 {
  603. RuleOfCameraImage2 = append(RuleOfCameraImage2, f)
  604. goto JudgeDone
  605. }
  606. if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.Image) string); ok3 {
  607. RuleOfCameraImage3 = append(RuleOfCameraImage3, f)
  608. goto JudgeDone
  609. }
  610. log(triggerLocalPath)
  611. continue
  612. } else if TopicOfDataRead == topic2 { //36
  613. if f, ok1 := rule.(func(data *pjisuv_msgs.Retrieval) string); ok1 {
  614. RuleOfDataRead1 = append(RuleOfDataRead1, f)
  615. goto JudgeDone
  616. }
  617. if f, ok2 := rule.(func(data *pjisuv_msgs.Retrieval, param *entity.PjisuvParam) string); ok2 {
  618. RuleOfDataRead2 = append(RuleOfDataRead2, f)
  619. goto JudgeDone
  620. }
  621. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.Retrieval) string); ok3 {
  622. RuleOfDataRead3 = append(RuleOfDataRead3, f)
  623. goto JudgeDone
  624. }
  625. log(triggerLocalPath)
  626. continue
  627. } else if TopicOfPjiGps == topic2 { //37
  628. if f, ok1 := rule.(func(data *pjisuv_msgs.PerceptionLocalization) string); ok1 {
  629. RuleOfPjiGps1 = append(RuleOfPjiGps1, f)
  630. goto JudgeDone
  631. }
  632. if f, ok2 := rule.(func(data *pjisuv_msgs.PerceptionLocalization, param *entity.PjisuvParam) string); ok2 {
  633. RuleOfPjiGps2 = append(RuleOfPjiGps2, f)
  634. goto JudgeDone
  635. }
  636. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string); ok3 {
  637. RuleOfPjiGps3 = append(RuleOfPjiGps3, f)
  638. goto JudgeDone
  639. }
  640. log(triggerLocalPath)
  641. continue
  642. } else if TopicOfFaultInfo == topic2 { //38
  643. if f, ok1 := rule.(func(data *pjisuv_msgs.FaultVec) string); ok1 {
  644. RuleOfFaultInfo1 = append(RuleOfFaultInfo1, f)
  645. goto JudgeDone
  646. }
  647. if f, ok2 := rule.(func(data *pjisuv_msgs.FaultVec, param *entity.PjisuvParam) string); ok2 {
  648. RuleOfFaultInfo2 = append(RuleOfFaultInfo2, f)
  649. goto JudgeDone
  650. }
  651. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.FaultVec) string); ok3 {
  652. RuleOfFaultInfo3 = append(RuleOfFaultInfo3, f)
  653. goto JudgeDone
  654. }
  655. log(triggerLocalPath)
  656. continue
  657. } else if TopicOfPjVehicleFdbPub == topic2 { //39
  658. if f, ok1 := rule.(func(data *pjisuv_msgs.VehicleFdb) string); ok1 {
  659. RuleOfPjVehicleFdbPub1 = append(RuleOfPjVehicleFdbPub1, f)
  660. goto JudgeDone
  661. }
  662. if f, ok2 := rule.(func(data *pjisuv_msgs.VehicleFdb, param *entity.PjisuvParam) string); ok2 {
  663. RuleOfPjVehicleFdbPub2 = append(RuleOfPjVehicleFdbPub2, f)
  664. goto JudgeDone
  665. }
  666. if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.VehicleFdb) string); ok3 {
  667. RuleOfPjVehicleFdbPub3 = append(RuleOfPjVehicleFdbPub3, f)
  668. goto JudgeDone
  669. }
  670. log(triggerLocalPath)
  671. continue
  672. } else {
  673. c_log.GlobalLogger.Error("未知的topic:", topic2)
  674. continue
  675. }
  676. JudgeDone:
  677. label, err := open.Lookup("Label")
  678. if err != nil {
  679. c_log.GlobalLogger.Error("加载本地插件 ", triggerLocalPath, " 中的 Label 方法失败。", err)
  680. continue
  681. }
  682. labelFunc := label.(func() string)
  683. labelString := labelFunc()
  684. LabelMapTriggerId.Store(labelString, triggerId)
  685. success++
  686. }
  687. c_log.GlobalLogger.Info("一共应加载", len(config.PlatformConfig.TaskTriggers), "个触发器,实际加载 ", success, " 个触发器。")
  688. }
  689. func log(triggerLocalPath string) {
  690. c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的 Rule 方法参数格式不正确。")
  691. }