LingxinMeng 1 rok temu
rodzic
commit
a668beec0c
59 zmienionych plików z 3127 dodań i 354 usunięć
  1. 53 6
      trigger/pji/diagnostics/errorcode#2#21021101/main/main.go
  2. 53 6
      trigger/pji/diagnostics/errorcode#2#21030001/main/main.go
  3. 53 6
      trigger/pji/diagnostics/errorcode#2#21030401/main/main.go
  4. 53 6
      trigger/pji/diagnostics/errorcode#2#21030501/main/main.go
  5. 53 6
      trigger/pji/diagnostics/errorcode#2#21030601/main/main.go
  6. 53 6
      trigger/pji/diagnostics/errorcode#2#21030701/main/main.go
  7. 53 6
      trigger/pji/diagnostics/errorcode#2#21030702/main/main.go
  8. 53 6
      trigger/pji/diagnostics/errorcode#2#21030801/main/main.go
  9. 53 6
      trigger/pji/diagnostics/errorcode#2#21030802/main/main.go
  10. 53 6
      trigger/pji/diagnostics/errorcode#2#21031001/main/main.go
  11. 53 6
      trigger/pji/diagnostics/errorcode#2#21031101/main/main.go
  12. 53 6
      trigger/pji/diagnostics/errorcode#2#21031201/main/main.go
  13. 53 6
      trigger/pji/diagnostics/errorcode#2#21031401/main/main.go
  14. 53 6
      trigger/pji/diagnostics/errorcode#2#21031403/main/main.go
  15. 53 6
      trigger/pji/diagnostics/errorcode#2#21031404/main/main.go
  16. 53 6
      trigger/pji/diagnostics/errorcode#2#21040803/main/main.go
  17. 53 6
      trigger/pji/diagnostics/errorcode#2#21041001/main/main.go
  18. 53 6
      trigger/pji/diagnostics/errorcode#2#21041102/main/main.go
  19. 53 6
      trigger/pji/diagnostics/errorcode#2#21050701/main/main.go
  20. 53 6
      trigger/pji/diagnostics/errorcode#2#21050703/main/main.go
  21. 53 6
      trigger/pji/diagnostics/errorcode#2#21050801/main/main.go
  22. 53 6
      trigger/pji/diagnostics/errorcode#2#21051401/main/main.go
  23. 53 6
      trigger/pji/diagnostics/errorcode#2#21051402/main/main.go
  24. 53 6
      trigger/pji/diagnostics/errorcode#4#21050101/main/main.go
  25. 53 6
      trigger/pji/diagnostics/errorcode#4#21050201/main/main.go
  26. 53 6
      trigger/pji/diagnostics/errorcode#4#21050202/main/main.go
  27. 53 6
      trigger/pji/diagnostics/errorcode#4#21050301/main/main.go
  28. 53 6
      trigger/pji/diagnostics/errorcode#5#21030907/main/main.go
  29. 53 6
      trigger/pji/diagnostics/errorcode#5#21030908/main/main.go
  30. 53 6
      trigger/pji/diagnostics/errorcode#5#21031511/main/main.go
  31. 53 6
      trigger/pji/diagnostics/errorcode#5#21031512/main/main.go
  32. 53 6
      trigger/pji/diagnostics/errorcode#5#21031513/main/main.go
  33. 53 6
      trigger/pji/diagnostics/errorcode#5#21031514/main/main.go
  34. 53 6
      trigger/pji/diagnostics/errorcode#5#21031603/main/main.go
  35. 53 6
      trigger/pji/diagnostics/errorcode#5#21031604/main/main.go
  36. 53 6
      trigger/pji/diagnostics/errorcode#5#21031605/main/main.go
  37. 53 6
      trigger/pji/diagnostics/errorcode#5#21041501/main/main.go
  38. 53 6
      trigger/pji/diagnostics/errorcode#5#21041502/main/main.go
  39. 53 6
      trigger/pji/diagnostics/errorcode#5#21041503/main/main.go
  40. 53 6
      trigger/pji/diagnostics/errorcode#5#21041504/main/main.go
  41. 53 6
      trigger/pji/diagnostics/errorcode#5#21041505/main/main.go
  42. 53 6
      trigger/pji/diagnostics/errorcode#5#21041506/main/main.go
  43. 53 6
      trigger/pji/diagnostics/errorcode#5#21041507/main/main.go
  44. 53 6
      trigger/pji/diagnostics/errorcode#5#21041508/main/main.go
  45. 53 6
      trigger/pji/diagnostics/errorcode#5#21041510/main/main.go
  46. 53 6
      trigger/pji/diagnostics/errorcode#5#21041601/main/main.go
  47. 53 6
      trigger/pji/diagnostics/errorcode#5#21041602/main/main.go
  48. 53 6
      trigger/pji/diagnostics/errorcode#5#21041606/main/main.go
  49. 53 6
      trigger/pji/diagnostics/errorcode#5#21050901/main/main.go
  50. 53 6
      trigger/pji/diagnostics/errorcode#5#21050902/main/main.go
  51. 53 6
      trigger/pji/diagnostics/errorcode#5#21050904/main/main.go
  52. 53 6
      trigger/pji/diagnostics/errorcode#5#21050905/main/main.go
  53. 53 6
      trigger/pji/diagnostics/errorcode#5#21050906/main/main.go
  54. 53 6
      trigger/pji/diagnostics/errorcode#5#21051509/main/main.go
  55. 53 6
      trigger/pji/diagnostics/errorcode#5#21051704/main/main.go
  56. 53 6
      trigger/pji/diagnostics/errorcode#5#21051705/main/main.go
  57. 53 6
      trigger/pji/diagnostics/errorcode#5#21051706/main/main.go
  58. 53 6
      trigger/pji/diagnostics/errorcode#5#21051707/main/main.go
  59. 53 6
      trigger/pji/diagnostics/errorcode#5#21051708/main/main.go

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21021101/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21030001/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21030401/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21030501/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21030601/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21030701/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21030702/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21030801/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21030802/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21031001/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21031101/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21031201/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21031401/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21031403/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21031404/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21040803/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21041001/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21041102/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21050701/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21050703/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21050801/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21051401/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#2#21051402/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#4#21050101/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#4#21050201/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#4#21050202/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#4#21050301/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031702"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21030907/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21030908/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21031511/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21031512/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21031513/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21031514/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21031603/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21031604/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21031605/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041501/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041502/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041503/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041504/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041505/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041506/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041507/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041508/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041510/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041601/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041602/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21041606/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21050901/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21050902/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21050904/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21050905/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21050906/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21051509/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21051704/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21051705/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21051706/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21051707/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }

+ 53 - 6
trigger/pji/diagnostics/errorcode#5#21051708/main/main.go

@@ -1,8 +1,38 @@
 package main
 
 import (
-	"github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
-	"math"
+	"fmt"
+	"github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
+	"strconv"
+)
+
+/*
+电驱通讯轻微丢失
+*/
+
+var (
+	errorType       = "2"
+	errorCode       = "21021101"
+	code12          = "21"
+	hardwareIdIndex = map[string]string{
+		"batter":        "00",
+		"cloud":         "01",
+		"gateway":       "02",
+		"mcu":           "03",
+		"imu":           "04",
+		"odom":          "05",
+		"motor":         "06",
+		"preventFall":   "07",
+		"sonar":         "08",
+		"locate":        "09",
+		"laserLadar":    "10",
+		"electricDrive": "11",
+		"infrared":      "12",
+		"livoxLidar":    "13",
+		"camera":        "14",
+		"navigation":    "15",
+		"system":        "16",
+	}
 )
 
 func Topic() string {
@@ -10,12 +40,29 @@ func Topic() string {
 }
 
 func Label() string {
-	return "errorcode#1#21031701"
+	return "errorcode#" + errorType + "#" + errorCode
 }
 
-func Rule(data *sensor_msgs.Imu) string {
-	if math.Abs(data.LinearAcceleration.X) >= 0.7 && math.Abs(data.LinearAcceleration.Y) >= 0.7 {
-		return "unstabledriving"
+func Rule(data *diagnostic_msgs.DiagnosticArray) string {
+	if len(data.Status) == 0 {
+		return ""
+	}
+	for _, status := range data.Status {
+		if status.Level != 5 || len(status.Values) == 0 {
+			continue
+		}
+
+		code34 := fmt.Sprintf("%02d", status.Level)
+		code56 := hardwareIdIndex[status.HardwareId]
+		intVal, err := strconv.Atoi(status.Values[1].Value)
+		if err != nil {
+			fmt.Println("字段 【status.Values[1].Value】转整数报错:", err)
+			return ""
+		}
+		code78 := fmt.Sprintf("%02d", intVal)
+		if errorCode == code12+code34+code56+code78 {
+			return Label()
+		}
 	}
 	return ""
 }