trigger_init.go 23 KB

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