1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package main
- import (
- "cicv-data-closedloop/pjisuv_msgs"
- "fmt"
- "sync"
- "time"
- )
- var (
- StartTime int64
- IsStopped bool
- )
- func Topic() string {
- return "/cicv_location"
- }
- // 禁止存在下划线_
- func Label() string {
- return "AuLongStop"
- }
- func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string {
- defer func() {
- if r := recover(); r != nil {
- fmt.Println("Recovered from panic:", r)
- }
- }()
- automodeOfPjVehicleFdbPub, ok := shareVars.Load("AutomodeOfPjVehicleFdbPub")
- OutsideWorkshopFlag, _ := shareVars.Load("OutsideWorkshopFlag")
- OutsideWorkshopFlag = OutsideWorkshopFlag.(bool)
- if ok {
- if automodeOfPjVehicleFdbPub.(int16) == 1 {
- if data.VelocityX < 0.5 {
- // 如果之前没有记录开始时间,记录当前时间
- if StartTime == 0 {
- StartTime = time.Now().Unix()
- }
- // 判断是否持续超过 50s
- if time.Now().Unix()-StartTime > 50 && OutsideWorkshopFlag == true {
- if !IsStopped {
- IsStopped = true
- return Label()
- }
- }
- } else {
- // 如果速度大于 0.1,重置开始时间和停止标志
- StartTime = 0
- IsStopped = false
- }
- } else {
- StartTime = 0
- IsStopped = false
- }
- }
- return ""
- }
|