def _add_msg(self, m):
        '''add a new message'''
        type = m.get_type()
        self.messages[type] = m

        if self.clock:
            self.clock.message_arrived(m)

        if type == 'MSG':
            if m.Message.find("Rover") != -1:
                self.mav_type = mavutil.mavlink.MAV_TYPE_GROUND_ROVER
            elif m.Message.find("Plane") != -1:
                self.mav_type = mavutil.mavlink.MAV_TYPE_FIXED_WING
            elif m.Message.find("Copter") != -1:
                self.mav_type = mavutil.mavlink.MAV_TYPE_QUADROTOR
            elif m.Message.startswith("Antenna"):
                self.mav_type = mavutil.mavlink.MAV_TYPE_ANTENNA_TRACKER
        if type == 'MODE':
            if isinstance(m.Mode, str):
                self.flightmode = m.Mode.upper()
            elif 'ModeNum' in m._fieldnames:
                mapping = mavutil.mode_mapping_bynumber(self.mav_type)
                if mapping is not None and m.ModeNum in mapping:
                    self.flightmode = mapping[m.ModeNum]
            else:
                self.flightmode = mavutil.mode_string_acm(m.Mode)
        if type == 'STAT' and 'MainState' in m._fieldnames:
            self.flightmode = mavutil.mode_string_px4(m.MainState)
        if type == 'PARM' and getattr(m, 'Name', None) is not None:
            self.params[m.Name] = m.Value
        self._set_time(m)
def _add_msg ( self , m ) : type = m . get_type ( ) self . messages [ type ] = m if self . clock : self . clock . message_arrived ( m ) if type == 'MSG' : if m . Message . find ( "Rover" ) != - 1 : self . mav_type = mavutil . mavlink . MAV_TYPE_GROUND_ROVER elif m . Message . find ( "Plane" ) != - 1 : self . mav_type = mavutil . mavlink . MAV_TYPE_FIXED_WING elif m . Message . find ( "Copter" ) != - 1 : self . mav_type = mavutil . mavlink . MAV_TYPE_QUADROTOR elif m . Message . startswith ( "Antenna" ) : self . mav_type = mavutil . mavlink . MAV_TYPE_ANTENNA_TRACKER if type == 'MODE' : if isinstance ( m . Mode , str ) : self . flightmode = m . Mode . upper ( ) elif 'ModeNum' in m . _fieldnames : mapping = mavutil . mode_mapping_bynumber ( self . mav_type ) if mapping is not None and m . ModeNum in mapping : self . flightmode = mapping [ m . ModeNum ] else : self . flightmode = mavutil . mode_string_acm ( m . Mode ) if type == 'STAT' and 'MainState' in m . _fieldnames : self . flightmode = mavutil . mode_string_px4 ( m . MainState ) if type == 'PARM' and getattr ( m , 'Name' , None ) is not None : self . params [ m . Name ] = m . Value self . _set_time ( m )
add a new message