github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ardupilotmega/enum_ekf_status_flags.go (about) 1 //autogenerated:yes 2 //nolint:revive,misspell,govet,lll,dupl,gocritic 3 package ardupilotmega 4 5 import ( 6 "fmt" 7 "strconv" 8 "strings" 9 ) 10 11 // Flags in EKF_STATUS message. 12 type EKF_STATUS_FLAGS uint64 13 14 const ( 15 // Set if EKF's attitude estimate is good. 16 EKF_ATTITUDE EKF_STATUS_FLAGS = 1 17 // Set if EKF's horizontal velocity estimate is good. 18 EKF_VELOCITY_HORIZ EKF_STATUS_FLAGS = 2 19 // Set if EKF's vertical velocity estimate is good. 20 EKF_VELOCITY_VERT EKF_STATUS_FLAGS = 4 21 // Set if EKF's horizontal position (relative) estimate is good. 22 EKF_POS_HORIZ_REL EKF_STATUS_FLAGS = 8 23 // Set if EKF's horizontal position (absolute) estimate is good. 24 EKF_POS_HORIZ_ABS EKF_STATUS_FLAGS = 16 25 // Set if EKF's vertical position (absolute) estimate is good. 26 EKF_POS_VERT_ABS EKF_STATUS_FLAGS = 32 27 // Set if EKF's vertical position (above ground) estimate is good. 28 EKF_POS_VERT_AGL EKF_STATUS_FLAGS = 64 29 // EKF is in constant position mode and does not know it's absolute or relative position. 30 EKF_CONST_POS_MODE EKF_STATUS_FLAGS = 128 31 // Set if EKF's predicted horizontal position (relative) estimate is good. 32 EKF_PRED_POS_HORIZ_REL EKF_STATUS_FLAGS = 256 33 // Set if EKF's predicted horizontal position (absolute) estimate is good. 34 EKF_PRED_POS_HORIZ_ABS EKF_STATUS_FLAGS = 512 35 // Set if EKF has never been healthy. 36 EKF_UNINITIALIZED EKF_STATUS_FLAGS = 1024 37 ) 38 39 var labels_EKF_STATUS_FLAGS = map[EKF_STATUS_FLAGS]string{ 40 EKF_ATTITUDE: "EKF_ATTITUDE", 41 EKF_VELOCITY_HORIZ: "EKF_VELOCITY_HORIZ", 42 EKF_VELOCITY_VERT: "EKF_VELOCITY_VERT", 43 EKF_POS_HORIZ_REL: "EKF_POS_HORIZ_REL", 44 EKF_POS_HORIZ_ABS: "EKF_POS_HORIZ_ABS", 45 EKF_POS_VERT_ABS: "EKF_POS_VERT_ABS", 46 EKF_POS_VERT_AGL: "EKF_POS_VERT_AGL", 47 EKF_CONST_POS_MODE: "EKF_CONST_POS_MODE", 48 EKF_PRED_POS_HORIZ_REL: "EKF_PRED_POS_HORIZ_REL", 49 EKF_PRED_POS_HORIZ_ABS: "EKF_PRED_POS_HORIZ_ABS", 50 EKF_UNINITIALIZED: "EKF_UNINITIALIZED", 51 } 52 53 var values_EKF_STATUS_FLAGS = map[string]EKF_STATUS_FLAGS{ 54 "EKF_ATTITUDE": EKF_ATTITUDE, 55 "EKF_VELOCITY_HORIZ": EKF_VELOCITY_HORIZ, 56 "EKF_VELOCITY_VERT": EKF_VELOCITY_VERT, 57 "EKF_POS_HORIZ_REL": EKF_POS_HORIZ_REL, 58 "EKF_POS_HORIZ_ABS": EKF_POS_HORIZ_ABS, 59 "EKF_POS_VERT_ABS": EKF_POS_VERT_ABS, 60 "EKF_POS_VERT_AGL": EKF_POS_VERT_AGL, 61 "EKF_CONST_POS_MODE": EKF_CONST_POS_MODE, 62 "EKF_PRED_POS_HORIZ_REL": EKF_PRED_POS_HORIZ_REL, 63 "EKF_PRED_POS_HORIZ_ABS": EKF_PRED_POS_HORIZ_ABS, 64 "EKF_UNINITIALIZED": EKF_UNINITIALIZED, 65 } 66 67 // MarshalText implements the encoding.TextMarshaler interface. 68 func (e EKF_STATUS_FLAGS) MarshalText() ([]byte, error) { 69 if e == 0 { 70 return []byte("0"), nil 71 } 72 var names []string 73 for i := 0; i < 11; i++ { 74 mask := EKF_STATUS_FLAGS(1 << i) 75 if e&mask == mask { 76 names = append(names, labels_EKF_STATUS_FLAGS[mask]) 77 } 78 } 79 return []byte(strings.Join(names, " | ")), nil 80 } 81 82 // UnmarshalText implements the encoding.TextUnmarshaler interface. 83 func (e *EKF_STATUS_FLAGS) UnmarshalText(text []byte) error { 84 labels := strings.Split(string(text), " | ") 85 var mask EKF_STATUS_FLAGS 86 for _, label := range labels { 87 if value, ok := values_EKF_STATUS_FLAGS[label]; ok { 88 mask |= value 89 } else if value, err := strconv.Atoi(label); err == nil { 90 mask |= EKF_STATUS_FLAGS(value) 91 } else { 92 return fmt.Errorf("invalid label '%s'", label) 93 } 94 } 95 *e = mask 96 return nil 97 } 98 99 // String implements the fmt.Stringer interface. 100 func (e EKF_STATUS_FLAGS) String() string { 101 val, _ := e.MarshalText() 102 return string(val) 103 }