|
@@ -4,6 +4,10 @@ import (
|
|
|
"cicv-data-closedloop/aarch64/pji/common/config"
|
|
|
"cicv-data-closedloop/common/config/c_log"
|
|
|
"cicv-data-closedloop/common/util"
|
|
|
+ "cicv-data-closedloop/pji_msgs"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/nav_msgs"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
|
|
|
"github.com/bluenviron/goroslib/v2/pkg/msgs/std_msgs"
|
|
|
"plugin"
|
|
|
"strconv"
|
|
@@ -11,9 +15,26 @@ import (
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
+ LabelMapTriggerId = make(map[string]string)
|
|
|
+
|
|
|
+ // 1
|
|
|
+ TopicOfDiagnostics = "/diagnostics"
|
|
|
+ RuleOfDiagnostics []func(data *diagnostic_msgs.DiagnosticArray) string
|
|
|
+ // 2
|
|
|
+ TopicOfImu = "/imu"
|
|
|
+ RuleOfImu []func(data *sensor_msgs.Imu) string
|
|
|
+ // 3
|
|
|
+ TopicOfLocateInfo = "/locate_info"
|
|
|
+ RuleOfLocateInfo []func(data *pji_msgs.LocateInfo) string
|
|
|
+ // 4
|
|
|
TopicOfObstacleDetection = "/obstacle_detection"
|
|
|
RuleOfObstacleDetection []func(data *std_msgs.UInt8) string
|
|
|
- LabelMapTriggerId = make(map[string]string)
|
|
|
+ // 5
|
|
|
+ TopicOfOdom = "/odom"
|
|
|
+ RuleOfOdom []func(data *nav_msgs.Odometry) string
|
|
|
+ // 6
|
|
|
+ TopicOfSysInfo = "/sys_info"
|
|
|
+ RuleOfSysInfo []func(data *pji_msgs.SysInfo) string
|
|
|
)
|
|
|
|
|
|
func InitTriggerConfig() {
|
|
@@ -54,14 +75,50 @@ func InitTriggerConfig() {
|
|
|
c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Rule方法失败。", err)
|
|
|
continue
|
|
|
}
|
|
|
- // 判断规则类型
|
|
|
- if TopicOfObstacleDetection == topic2 {
|
|
|
+ // 判断topic
|
|
|
+ // todo 如果是未知的topic,可以添加一个循环,更新平台配置,同理金龙车和多功能车
|
|
|
+ if TopicOfDiagnostics == topic2 { // 1
|
|
|
+ f, ok := rule.(func(*diagnostic_msgs.DiagnosticArray) string)
|
|
|
+ if ok != true {
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *diagnostic_msgs.DiagnosticArray) string):", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RuleOfDiagnostics = append(RuleOfDiagnostics, f)
|
|
|
+ } else if TopicOfImu == topic2 { // 2
|
|
|
+ f, ok := rule.(func(data *sensor_msgs.Imu) string)
|
|
|
+ if ok != true {
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *sensor_msgs.Imu) string):", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RuleOfImu = append(RuleOfImu, f)
|
|
|
+ } else if TopicOfLocateInfo == topic2 { // 3
|
|
|
+ f, ok := rule.(func(data *pji_msgs.LocateInfo) string)
|
|
|
+ if ok != true {
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *pji_msgs.LocateInfo) string):", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RuleOfLocateInfo = append(RuleOfLocateInfo, f)
|
|
|
+ } else if TopicOfObstacleDetection == topic2 { // 4
|
|
|
f, ok := rule.(func(data *std_msgs.UInt8) string)
|
|
|
if ok != true {
|
|
|
c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *std_msgs.UInt8) string):", err)
|
|
|
continue
|
|
|
}
|
|
|
RuleOfObstacleDetection = append(RuleOfObstacleDetection, f)
|
|
|
+ } else if TopicOfOdom == topic2 { // 5
|
|
|
+ f, ok := rule.(func(data *nav_msgs.Odometry) string)
|
|
|
+ if ok != true {
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *nav_msgs.Odometry) string):", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RuleOfOdom = append(RuleOfOdom, f)
|
|
|
+ } else if TopicOfSysInfo == topic2 { // 6
|
|
|
+ f, ok := rule.(func(data *pji_msgs.SysInfo) string)
|
|
|
+ if ok != true {
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *pji_msgs.SysInfo) string):", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ RuleOfSysInfo = append(RuleOfSysInfo, f)
|
|
|
} else {
|
|
|
c_log.GlobalLogger.Error("未知的topic:", topic2)
|
|
|
continue
|