|
@@ -1,9 +1,9 @@
|
|
|
package cfg
|
|
|
|
|
|
import (
|
|
|
+ "cicv-data-closedloop/common/config/c_log"
|
|
|
"cicv-data-closedloop/pji/common/cfg"
|
|
|
"cicv-data-closedloop/pji/common/cutil"
|
|
|
- "cicv-data-closedloop/pji/common/log"
|
|
|
"cicv-data-closedloop/pji_msgs"
|
|
|
"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
|
|
|
"github.com/bluenviron/goroslib/v2/pkg/msgs/nav_msgs"
|
|
@@ -39,93 +39,93 @@ func InitTriggerConfig() {
|
|
|
|
|
|
triggerLocalPath := cfg.CloudConfig.TriggersDir + fileName
|
|
|
cutil.CreateParentDir(triggerLocalPath)
|
|
|
- log.GlobalLogger.Info("下载触发器插件从", trigger.TriggerScriptPath, "到", triggerLocalPath)
|
|
|
+ c_log.GlobalLogger.Info("下载触发器插件从", trigger.TriggerScriptPath, "到", triggerLocalPath)
|
|
|
err := cfg.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath)
|
|
|
if err != nil {
|
|
|
- log.GlobalLogger.Error("下载oss上的触发器插件失败:", err)
|
|
|
+ c_log.GlobalLogger.Error("下载oss上的触发器插件失败:", err)
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
open, err := plugin.Open(triggerLocalPath)
|
|
|
if err != nil {
|
|
|
- log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "失败。", err)
|
|
|
+ c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "失败。", err)
|
|
|
}
|
|
|
topic0, err := open.Lookup("Topic")
|
|
|
if err != nil {
|
|
|
- log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Topic方法失败。", err)
|
|
|
+ c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Topic方法失败。", err)
|
|
|
continue
|
|
|
}
|
|
|
topic1, ok := topic0.(func() string)
|
|
|
if ok != true {
|
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func() string):", err)
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func() string):", err)
|
|
|
continue
|
|
|
}
|
|
|
topic2 := topic1()
|
|
|
rule, err := open.Lookup("Rule")
|
|
|
if err != nil {
|
|
|
- log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Rule方法失败。", err)
|
|
|
+ c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Rule方法失败。", err)
|
|
|
continue
|
|
|
}
|
|
|
if TopicOfOdom == topic2 {
|
|
|
f, ok := rule.(func(data *nav_msgs.Odometry) string)
|
|
|
if ok != true {
|
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *nav_msgs.Odometry) string):", err)
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *nav_msgs.Odometry) string):", err)
|
|
|
continue
|
|
|
}
|
|
|
RuleOfOdom = append(RuleOfOdom, f)
|
|
|
} else if TopicOfObstacleDetection == topic2 {
|
|
|
f, ok := rule.(func(data *std_msgs.UInt8) string)
|
|
|
if ok != true {
|
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *std_msgs.UInt8) string):", err)
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *std_msgs.UInt8) string):", err)
|
|
|
continue
|
|
|
}
|
|
|
RuleOfObstacleDetection = append(RuleOfObstacleDetection, f)
|
|
|
} else if TopicOfSysInfo == topic2 {
|
|
|
f, ok := rule.(func(data *pji_msgs.SysInfo) string)
|
|
|
if ok != true {
|
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *pji_msgs.SysInfo) string):", err)
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *pji_msgs.SysInfo) string):", err)
|
|
|
continue
|
|
|
}
|
|
|
RuleOfSysInfo = append(RuleOfSysInfo, f)
|
|
|
} else if TopicOfLocateInfo == topic2 {
|
|
|
f, ok := rule.(func(data *pji_msgs.LocateInfo) string)
|
|
|
if ok != true {
|
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *pji_msgs.LocateInfo) string):", err)
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *pji_msgs.LocateInfo) string):", err)
|
|
|
continue
|
|
|
}
|
|
|
RuleOfLocateInfo = append(RuleOfLocateInfo, f)
|
|
|
} else if TopicOfImu == topic2 {
|
|
|
f, ok := rule.(func(data *sensor_msgs.Imu) string)
|
|
|
if ok != true {
|
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *sensor_msgs.Imu) string):", err)
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *sensor_msgs.Imu) string):", err)
|
|
|
continue
|
|
|
}
|
|
|
RuleOfImu = append(RuleOfImu, f)
|
|
|
} else if TopicOfDiagnostics == topic2 {
|
|
|
f, ok := rule.(func(data *diagnostic_msgs.DiagnosticArray) string)
|
|
|
if ok != true {
|
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *diagnostic_msgs.DiagnosticArray) string):", err)
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *diagnostic_msgs.DiagnosticArray) string):", err)
|
|
|
continue
|
|
|
}
|
|
|
RuleOfDiagnostics = append(RuleOfDiagnostics, f)
|
|
|
} else {
|
|
|
- log.GlobalLogger.Error("未知的topic:", topic2)
|
|
|
+ c_log.GlobalLogger.Error("未知的topic:", topic2)
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
label, err := open.Lookup("Label")
|
|
|
if err != nil {
|
|
|
- log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的TriggerName方法失败。", err)
|
|
|
+ c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的TriggerName方法失败。", err)
|
|
|
continue
|
|
|
}
|
|
|
labelFunc, ok := label.(func() string)
|
|
|
if ok != true {
|
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Label方法必须是(func() string):", err)
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Label方法必须是(func() string):", err)
|
|
|
continue
|
|
|
}
|
|
|
labelString := labelFunc()
|
|
|
LabelMapTriggerId[labelString] = strconv.Itoa(trigger.TriggerId)
|
|
|
- log.GlobalLogger.Info("主节点加载触发器插件:【ros topic】=", topic2, ",【触发器label】=", labelString, "【触发器ID】=", trigger.TriggerId, "【label和id映射关系】=", LabelMapTriggerId)
|
|
|
+ c_log.GlobalLogger.Info("主节点加载触发器插件:【ros topic】=", topic2, ",【触发器label】=", labelString, "【触发器ID】=", trigger.TriggerId, "【label和id映射关系】=", LabelMapTriggerId)
|
|
|
}
|
|
|
- log.GlobalLogger.Info("主节点加载触发器插件 - 成功。")
|
|
|
+ c_log.GlobalLogger.Info("主节点加载触发器插件 - 成功。")
|
|
|
}
|