123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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")
- 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 {
- if !IsStopped {
- IsStopped = true
- return Label()
- }
- }
- } else {
- // 如果速度大于 0.1,重置开始时间和停止标志
- StartTime = 0
- IsStopped = false
- }
- } else {
- StartTime = 0
- IsStopped = false
- }
- }
- return ""
- }
|