trigger_init.go 22 KB

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