code: def check_heading(self, m):
          '''check heading discrepancy'''
          if 'GPS_RAW' in self.status.msgs:
              gps = self.status.msgs['GPS_RAW']
              if gps.v < 3:
                  return
              diff = math.fabs(angle_diff(m.heading, gps.hdg))
          elif 'GPS_RAW_INT' in self.status.msgs:
              gps = self.status.msgs['GPS_RAW_INT']
              if gps.vel < 300:
                  return
              diff = math.fabs(angle_diff(m.heading, gps.cog / 100.0))
          else:
              return
          self.report('heading', diff < 20, 'heading error %u' % difff check_heading(self, m):
          '''check heading discrepancy'''
          if 'GPS_RAW' in self.status.msgs:
              gps = self.status.msgs['GPS_RAW']
              if gps.v < 3:
                  return
              diff = math.fabs(angle_diff(m.heading, gps.hdg))
          elif 'GPS_RAW_INT' in self.status.msgs:
              gps = self.status.msgs['GPS_RAW_INT']
              if gps.vel < 300:
                  return
              diff = math.fabs(angle_diff(m.heading, gps.cog / 100.0))
          else:
              return
          self.report('heading', diff < 20, 'heading error %u' % diff)
docs: check heading discrepancy