|
@@ -684,18 +684,6 @@ func ProduceWindow() {
|
|
|
Node: commonConfig.RosNode,
|
|
|
Topic: topic,
|
|
|
Callback: func(data *pjisuv_msgs.PerceptionLocalization) {
|
|
|
- // 更新共享变量
|
|
|
- mutexOfCicvLocation.RLock()
|
|
|
- {
|
|
|
- pjisuvParam.VelocityXOfCicvLocation = data.VelocityX
|
|
|
- pjisuvParam.VelocityYOfCicvLocation = data.VelocityY
|
|
|
- pjisuvParam.VelocityZOfCicvLocation = data.VelocityZ
|
|
|
- pjisuvParam.YawOfCicvLocation = data.Yaw
|
|
|
- pjisuvParam.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
|
|
|
- pjisuvParam.PositionXOfCicvLocation = data.PositionX
|
|
|
- pjisuvParam.PositionYOfCicvLocation = data.PositionY
|
|
|
- }
|
|
|
- mutexOfCicvLocation.RUnlock()
|
|
|
|
|
|
subscribersTimeMutexes[i].Lock()
|
|
|
if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
@@ -739,6 +727,22 @@ func ProduceWindow() {
|
|
|
subscribersMutexes[i].Unlock()
|
|
|
}
|
|
|
subscribersTimeMutexes[i].Unlock()
|
|
|
+ // 更新共享变量
|
|
|
+ mutexOfCicvLocation.RLock()
|
|
|
+ {
|
|
|
+ //shareVars.Store("VelocityXOfCicvLocation",data.VelocityX) pjisuvParam以后不要新加全局变量了,采用这种方式添加
|
|
|
+ //value, _ := shareVars.Load("VelocityXOfCicvLocation") 在Rule函数数中通过Load方法获取全局变量,获取之后通过value.(float64)方法转换数据类型
|
|
|
+ //s := value.(float64)
|
|
|
+
|
|
|
+ pjisuvParam.VelocityXOfCicvLocation = data.VelocityX
|
|
|
+ pjisuvParam.VelocityYOfCicvLocation = data.VelocityY
|
|
|
+ pjisuvParam.VelocityZOfCicvLocation = data.VelocityZ
|
|
|
+ pjisuvParam.YawOfCicvLocation = data.Yaw
|
|
|
+ pjisuvParam.AngularVelocityZOfCicvLocation = data.AngularVelocityZ
|
|
|
+ pjisuvParam.PositionXOfCicvLocation = data.PositionX
|
|
|
+ pjisuvParam.PositionYOfCicvLocation = data.PositionY
|
|
|
+ }
|
|
|
+ mutexOfCicvLocation.RUnlock()
|
|
|
},
|
|
|
})
|
|
|
}
|
|
@@ -2196,6 +2200,7 @@ func ProduceWindow() {
|
|
|
Node: commonConfig.RosNode,
|
|
|
Topic: topic,
|
|
|
Callback: func(data *pjisuv_msgs.VehicleFdb) {
|
|
|
+ shareVars.Store("Automode", data.Automode)
|
|
|
subscribersTimeMutexes[i].Lock()
|
|
|
if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
subscribersMutexes[i].Lock()
|
|
@@ -2242,6 +2247,63 @@ func ProduceWindow() {
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
+ // 40 有共享变量的订阅者必须被创建
|
|
|
+ if topic == masterConfig.TopicOfEndPointMessage {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Point) {
|
|
|
+ // 更新共享变量
|
|
|
+
|
|
|
+ shareVars.Store("EndPointX", data.X)
|
|
|
+ shareVars.Store("EndPointY", data.Y)
|
|
|
+
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := util.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := commonEntity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ faultLabel := ""
|
|
|
+ if len(masterConfig.RuleOfEndPointMessage1) > 0 {
|
|
|
+ for _, f := range masterConfig.RuleOfEndPointMessage1 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ goto TriggerSuccess
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(masterConfig.RuleOfEndPointMessage2) > 0 {
|
|
|
+ for _, f := range masterConfig.RuleOfEndPointMessage2 {
|
|
|
+ faultLabel = f(data, &pjisuvParam)
|
|
|
+ if faultLabel != "" {
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ goto TriggerSuccess
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(masterConfig.RuleOfEndPointMessage3) > 0 {
|
|
|
+ for _, f := range masterConfig.RuleOfEndPointMessage3 {
|
|
|
+ faultLabel = f(shareVars, data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ goto TriggerSuccess
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TriggerSuccess:
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
if err != nil {
|
|
|
c_log.GlobalLogger.Info("创建订阅者报错,可能由于节点未启动,再次尝试:", err)
|
|
|
time.Sleep(time.Duration(2) * time.Second)
|