github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/common/enum_estimator_status_flags.go (about) 1 //autogenerated:yes 2 //nolint:revive,misspell,govet,lll,dupl,gocritic 3 package common 4 5 import ( 6 "fmt" 7 "strconv" 8 "strings" 9 ) 10 11 // Flags in ESTIMATOR_STATUS message 12 type ESTIMATOR_STATUS_FLAGS uint64 13 14 const ( 15 // True if the attitude estimate is good 16 ESTIMATOR_ATTITUDE ESTIMATOR_STATUS_FLAGS = 1 17 // True if the horizontal velocity estimate is good 18 ESTIMATOR_VELOCITY_HORIZ ESTIMATOR_STATUS_FLAGS = 2 19 // True if the vertical velocity estimate is good 20 ESTIMATOR_VELOCITY_VERT ESTIMATOR_STATUS_FLAGS = 4 21 // True if the horizontal position (relative) estimate is good 22 ESTIMATOR_POS_HORIZ_REL ESTIMATOR_STATUS_FLAGS = 8 23 // True if the horizontal position (absolute) estimate is good 24 ESTIMATOR_POS_HORIZ_ABS ESTIMATOR_STATUS_FLAGS = 16 25 // True if the vertical position (absolute) estimate is good 26 ESTIMATOR_POS_VERT_ABS ESTIMATOR_STATUS_FLAGS = 32 27 // True if the vertical position (above ground) estimate is good 28 ESTIMATOR_POS_VERT_AGL ESTIMATOR_STATUS_FLAGS = 64 29 // True if the EKF is in a constant position mode and is not using external measurements (eg GPS or optical flow) 30 ESTIMATOR_CONST_POS_MODE ESTIMATOR_STATUS_FLAGS = 128 31 // True if the EKF has sufficient data to enter a mode that will provide a (relative) position estimate 32 ESTIMATOR_PRED_POS_HORIZ_REL ESTIMATOR_STATUS_FLAGS = 256 33 // True if the EKF has sufficient data to enter a mode that will provide a (absolute) position estimate 34 ESTIMATOR_PRED_POS_HORIZ_ABS ESTIMATOR_STATUS_FLAGS = 512 35 // True if the EKF has detected a GPS glitch 36 ESTIMATOR_GPS_GLITCH ESTIMATOR_STATUS_FLAGS = 1024 37 // True if the EKF has detected bad accelerometer data 38 ESTIMATOR_ACCEL_ERROR ESTIMATOR_STATUS_FLAGS = 2048 39 ) 40 41 var labels_ESTIMATOR_STATUS_FLAGS = map[ESTIMATOR_STATUS_FLAGS]string{ 42 ESTIMATOR_ATTITUDE: "ESTIMATOR_ATTITUDE", 43 ESTIMATOR_VELOCITY_HORIZ: "ESTIMATOR_VELOCITY_HORIZ", 44 ESTIMATOR_VELOCITY_VERT: "ESTIMATOR_VELOCITY_VERT", 45 ESTIMATOR_POS_HORIZ_REL: "ESTIMATOR_POS_HORIZ_REL", 46 ESTIMATOR_POS_HORIZ_ABS: "ESTIMATOR_POS_HORIZ_ABS", 47 ESTIMATOR_POS_VERT_ABS: "ESTIMATOR_POS_VERT_ABS", 48 ESTIMATOR_POS_VERT_AGL: "ESTIMATOR_POS_VERT_AGL", 49 ESTIMATOR_CONST_POS_MODE: "ESTIMATOR_CONST_POS_MODE", 50 ESTIMATOR_PRED_POS_HORIZ_REL: "ESTIMATOR_PRED_POS_HORIZ_REL", 51 ESTIMATOR_PRED_POS_HORIZ_ABS: "ESTIMATOR_PRED_POS_HORIZ_ABS", 52 ESTIMATOR_GPS_GLITCH: "ESTIMATOR_GPS_GLITCH", 53 ESTIMATOR_ACCEL_ERROR: "ESTIMATOR_ACCEL_ERROR", 54 } 55 56 var values_ESTIMATOR_STATUS_FLAGS = map[string]ESTIMATOR_STATUS_FLAGS{ 57 "ESTIMATOR_ATTITUDE": ESTIMATOR_ATTITUDE, 58 "ESTIMATOR_VELOCITY_HORIZ": ESTIMATOR_VELOCITY_HORIZ, 59 "ESTIMATOR_VELOCITY_VERT": ESTIMATOR_VELOCITY_VERT, 60 "ESTIMATOR_POS_HORIZ_REL": ESTIMATOR_POS_HORIZ_REL, 61 "ESTIMATOR_POS_HORIZ_ABS": ESTIMATOR_POS_HORIZ_ABS, 62 "ESTIMATOR_POS_VERT_ABS": ESTIMATOR_POS_VERT_ABS, 63 "ESTIMATOR_POS_VERT_AGL": ESTIMATOR_POS_VERT_AGL, 64 "ESTIMATOR_CONST_POS_MODE": ESTIMATOR_CONST_POS_MODE, 65 "ESTIMATOR_PRED_POS_HORIZ_REL": ESTIMATOR_PRED_POS_HORIZ_REL, 66 "ESTIMATOR_PRED_POS_HORIZ_ABS": ESTIMATOR_PRED_POS_HORIZ_ABS, 67 "ESTIMATOR_GPS_GLITCH": ESTIMATOR_GPS_GLITCH, 68 "ESTIMATOR_ACCEL_ERROR": ESTIMATOR_ACCEL_ERROR, 69 } 70 71 // MarshalText implements the encoding.TextMarshaler interface. 72 func (e ESTIMATOR_STATUS_FLAGS) MarshalText() ([]byte, error) { 73 if e == 0 { 74 return []byte("0"), nil 75 } 76 var names []string 77 for i := 0; i < 12; i++ { 78 mask := ESTIMATOR_STATUS_FLAGS(1 << i) 79 if e&mask == mask { 80 names = append(names, labels_ESTIMATOR_STATUS_FLAGS[mask]) 81 } 82 } 83 return []byte(strings.Join(names, " | ")), nil 84 } 85 86 // UnmarshalText implements the encoding.TextUnmarshaler interface. 87 func (e *ESTIMATOR_STATUS_FLAGS) UnmarshalText(text []byte) error { 88 labels := strings.Split(string(text), " | ") 89 var mask ESTIMATOR_STATUS_FLAGS 90 for _, label := range labels { 91 if value, ok := values_ESTIMATOR_STATUS_FLAGS[label]; ok { 92 mask |= value 93 } else if value, err := strconv.Atoi(label); err == nil { 94 mask |= ESTIMATOR_STATUS_FLAGS(value) 95 } else { 96 return fmt.Errorf("invalid label '%s'", label) 97 } 98 } 99 *e = mask 100 return nil 101 } 102 103 // String implements the fmt.Stringer interface. 104 func (e ESTIMATOR_STATUS_FLAGS) String() string { 105 val, _ := e.MarshalText() 106 return string(val) 107 }