1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package main
- import (
- "cicv-data-closedloop/pjisuv_msgs"
- "fmt"
- "math"
- "sync"
- )
- func Topic() string {
- return "/cicv_location"
- }
- // 禁止存在下划线_
- func Label() string {
- return "LocationJump"
- }
- // 主进程的逻辑是先判断触发再缓存全局变量
- func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string {
- defer func() {
- if r := recover(); r != nil {
- fmt.Println("Recovered from panic:", r)
- }
- }()
- OutsideWorkshopFlag, ok3 := shareVars.Load("OutsideWorkshopFlag")
- OutsideWorkshopFlag = OutsideWorkshopFlag.(bool)
- positionXOfCicvLocation, ok1 := shareVars.Load("PositionXOfCicvLocation")
- positionYOfCicvLocation, ok2 := shareVars.Load("PositionYOfCicvLocation")
- if ok1 && ok2 && ok3 {
- v1 := positionXOfCicvLocation.(float64)
- v2 := positionYOfCicvLocation.(float64)
- if v1 != 0 && v2 != 0 {
- d := math.Sqrt((v1-data.PositionX)*(v1-data.PositionX) + (v2-data.PositionY)*(v2-data.PositionY))
- if d >= 2 && OutsideWorkshopFlag == true {
- return Label()
- }
- }
- }
- return ""
- }
|