123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package main
- import (
- "cicv-data-closedloop/pjisuv_msgs"
- "fmt"
- "math"
- "sync"
- )
- func Topic() string {
- return "/cicv_location"
- }
- func Label() string {
- return "ExcessiveSpeedWhenDownhill"
- }
- var (
- count int = 0
- threshold = -0.05
- )
- func QuaternionToEuler(x, y, z, w float64) float64 {
-
- length := math.Sqrt(x*x + y*y + z*z + w*w)
- x /= length
- y /= length
- z /= length
- w /= length
-
- pitch := math.Asin(2 * (w*y - z*x))
- return pitch
- }
- func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string {
- defer func() {
- if r := recover(); r != nil {
- fmt.Println("Recovered from panic:", r)
- }
- }()
- if count%10 == 0 {
- OutsideWorkshopFlag, ok1 := shareVars.Load("OutsideWorkshopFlag")
- if ok1 && OutsideWorkshopFlag.(bool) {
- if math.Abs(data.AngularVelocityZ) >= 17.0 && QuaternionToEuler(data.Qx, data.Qy, data.Qz, data.Qw) <= threshold {
- count = 1
- return Label()
- }
- }
- }
- count++
- return ""
- }
|