How to use the pymavlink.mavutil.mavlink.MAVLink_mission_item_message function in pymavlink

To help you get started, we’ve selected a few pymavlink examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArduPilot / MAVProxy / MAVProxy / tools / mavflightview.py View on Github external
break

        type = m.get_type()

        if type == 'MISSION_ITEM':
            try:
                while m.seq > wp.count():
                    print("Adding dummy WP %u" % wp.count())
                    wp.set(m, wp.count())
                wp.set(m, m.seq)
            except Exception:
                pass
            continue
        if type == 'CMD':
            if options.mission is None:
                m = mavutil.mavlink.MAVLink_mission_item_message(0,
                                                                0,
                                                                m.CNum,
                                                                mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT,
                                                                m.CId,
                                                                0, 1,
                                                                m.Prm1, m.Prm2, m.Prm3, m.Prm4,
                                                                m.Lat, m.Lng, m.Alt)
                try:
                    while m.seq > wp.count():
                        print("Adding dummy WP %u" % wp.count())
                        wp.set(m, wp.count())
                    wp.set(m, m.seq)
                except Exception:
                    pass
            continue
        if not mlog.check_condition(options.condition):
github ArduPilot / MAVProxy / MAVProxy / modules / mavproxy_misseditor / mission_editor.py View on Github external
elif event_type == me_event.MEE_GET_WP_DEFAULT_ALT:
                    self.mp_misseditor.gui_event_queue_lock.acquire()
                    self.mp_misseditor.gui_event_queue.put(MissionEditorEvent(
                        me_event.MEGE_SET_WP_DEFAULT_ALT,def_wp_alt=self.mp_misseditor.mpstate.settings.wpalt))
                    self.mp_misseditor.gui_event_queue_lock.release()
                elif event_type == me_event.MEE_SET_WP_DEFAULT_ALT:
                    self.mp_misseditor.mpstate.settings.command(["wpalt",event.get_arg("alt")])

                elif event_type == me_event.MEE_WRITE_WPS:
                    self.module('wp').wploader.clear()
                    self.master().waypoint_count_send(event.get_arg("count"))
                    self.mp_misseditor.num_wps_expected = event.get_arg("count")
                    self.mp_misseditor.wps_received = {}
                elif event_type == me_event.MEE_WRITE_WP_NUM:
                    w = mavutil.mavlink.MAVLink_mission_item_message(
                        self.mp_misseditor.mpstate.settings.target_system,
                        self.mp_misseditor.mpstate.settings.target_component,
                        event.get_arg("num"),
                        int(event.get_arg("frame")),
                        event.get_arg("cmd_id"),
                        0, 1,
                        event.get_arg("p1"), event.get_arg("p2"),
                        event.get_arg("p3"), event.get_arg("p4"),
                        event.get_arg("lat"), event.get_arg("lon"),
                        event.get_arg("alt"))

                    self.module('wp').wploader.add(w)
                    wsend = self.module('wp').wploader.wp(w.seq)
                    if self.mp_misseditor.mpstate.settings.wp_use_mission_int:
                        wsend = self.module('wp').wp_to_mission_item_int(w)
                    self.master().mav.send(wsend)
github ArduPilot / pymavlink / tools / mavmission.py View on Github external
frame = m.Frame
            except AttributeError:
                print("Warning: assuming frame is GLOBAL_RELATIVE_ALT")
                frame = mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT
            num_wps = m.CTot
            m = mavutil.mavlink.MAVLink_mission_item_message(0,
                                                             0,
                                                             m.CNum,
                                                             frame,
                                                             m.CId,
                                                             0, 1,
                                                             m.Prm1, m.Prm2, m.Prm3, m.Prm4,
                                                             m.Lat, m.Lng, m.Alt)

        if m.get_type() == 'MISSION_ITEM_INT':
            m = mavutil.mavlink.MAVLink_mission_item_message(m.target_system,
                                                             m.target_component,
                                                             m.seq,
                                                             m.frame,
                                                             m.command,
                                                             m.current,
                                                             m.autocontinue,
                                                             m.param1,
                                                             m.param2,
                                                             m.param3,
                                                             m.param4,
                                                             m.x*1.0e-7,
                                                             m.y*1.0e-7,
                                                             m.z)
        if m.current >= 2:
            continue
github ArduPilot / MAVProxy / MAVProxy / modules / mavproxy_wp.py View on Github external
def wp_from_mission_item_int(self, wp):
        '''convert a MISSION_ITEM_INT to a MISSION_ITEM'''
        wp2 = mavutil.mavlink.MAVLink_mission_item_message(wp.target_system,
                                                           wp.target_component,
                                                           wp.seq,
                                                           wp.frame,
                                                           wp.command,
                                                           wp.current,
                                                           wp.autocontinue,
                                                           wp.param1,
                                                           wp.param2,
                                                           wp.param3,
                                                           wp.param4,
                                                           wp.x*1.0e-7,
                                                           wp.y*1.0e-7,
                                                           wp.z)
        # preserve srcSystem as that is used for naming waypoint file
        wp2._header.srcSystem = wp.get_srcSystem()
        wp2._header.srcComponent = wp.get_srcComponent()
github ArduPilot / MAVProxy / MAVProxy / modules / mavproxy_wp.py View on Github external
def nofly_add(self):
        '''add a square flight exclusion zone'''
        latlon = self.mpstate.click_location
        if latlon is None:
            print("No position chosen")
            return
        loader = self.wploader
        (center_lat, center_lon) = latlon
        points = []
        points.append(mp_util.gps_offset(center_lat, center_lon, -25,  25))
        points.append(mp_util.gps_offset(center_lat, center_lon,  25,  25))
        points.append(mp_util.gps_offset(center_lat, center_lon,  25, -25))
        points.append(mp_util.gps_offset(center_lat, center_lon, -25, -25))
        start_idx = loader.count()
        for p in points:
            wp = mavutil.mavlink.MAVLink_mission_item_message(0, 0, 0, 0, mavutil.mavlink.MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION,
                                                              0, 1, 4, 0, 0, 0, p[0], p[1], 0)
            loader.add(wp)
        self.loading_waypoints = True
        self.loading_waypoint_lasttime = time.time()
        self.master.mav.mission_write_partial_list_send(self.target_system,
                                                        self.target_component,
                                                        start_idx, start_idx+4)
        print("Added nofly zone")
github ArduPilot / MAVProxy / MAVProxy / modules / mavproxy_wp.py View on Github external
print("previous wp is not a location command")
            return

        if wp.frame != prev_wp.frame:
            print("waypoints differ in frame (%u vs %u)" %
                  (wp.frame, prev_wp.frame))
            return

        if wp.frame != prev_wp.frame:
            print("waypoints differ in frame")
            return

        lat_avg = (loc.lat + prev_loc.lat)/2
        lng_avg = (loc.lng + prev_loc.lng)/2
        alt_avg = (loc.alt + prev_loc.alt)/2
        new_wp = mavutil.mavlink.MAVLink_mission_item_message(
            self.target_system,
            self.target_component,
            wp.seq,    # seq
            wp.frame,    # frame
            mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,    # command
            0,    # current
            0,    # autocontinue
            0.0,  # param1,
            0.0,  # param2,
            0.0,  # param3
            0.0,  # param4
            lat_avg * 1e-7,  # x (latitude)
            lng_avg * 1e-7,  # y (longitude)
            alt_avg * 1e-2,  # z (altitude)
        )
        self.wploader.insert(wp.seq, new_wp)
github dronekit / dronekit-python / dronekit / lib / __init__.py View on Github external
            @vehicle.parameters.on_attribute('THR_MIN')  
            def decorated_thr_min_callback(self, attr_name, value):
                print " PARAMETER CALLBACK: %s changed to: %s" % (attr_name, value)   
        
        See :ref:`vehicle_state_observing_parameters` for more information.
        
        :param String attr_name: The name of the parameter to watch (or '*' to watch all parameters).
        :param args: The callback to invoke when a change in the parameter is detected.

        """    
        attr_name = attr_name.upper()
        return super(Parameters, self).on_attribute(attr_name, *args, **kwargs)


class Command(mavutil.mavlink.MAVLink_mission_item_message):
    """
    A waypoint object.

    This object encodes a single mission item command. The set of commands that are supported by ArduPilot in Copter, Plane and Rover (along with their parameters)
    are listed in the wiki article `MAVLink Mission Command Messages (MAV_CMD) `_.

    For example, to create a `NAV_WAYPOINT `_ command:

    .. code:: python

        cmd = Command(0,0,0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT,
            mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 0, 0, 0, 0,-34.364114, 149.166022, 30)

    :param target_system: This can be set to any value 
        (DroneKit changes the value to the MAVLink ID of the connected vehicle before the command is sent).
    :param target_component: The component id if the message is intended for a particular component within the target system
github ArduPilot / pymavlink / tools / mavmission.py View on Github external
wp = mavwp.MAVWPLoader()

    num_wps = None
    while True:
        m = mlog.recv_match(type=['MISSION_ITEM','CMD','WAYPOINT','MISSION_ITEM_INT'])
        if m is None:
            break
        if m.get_type() == 'CMD':
            try:
                frame = m.Frame
            except AttributeError:
                print("Warning: assuming frame is GLOBAL_RELATIVE_ALT")
                frame = mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT
            num_wps = m.CTot
            m = mavutil.mavlink.MAVLink_mission_item_message(0,
                                                             0,
                                                             m.CNum,
                                                             frame,
                                                             m.CId,
                                                             0, 1,
                                                             m.Prm1, m.Prm2, m.Prm3, m.Prm4,
                                                             m.Lat, m.Lng, m.Alt)

        if m.get_type() == 'MISSION_ITEM_INT':
            m = mavutil.mavlink.MAVLink_mission_item_message(m.target_system,
                                                             m.target_component,
                                                             m.seq,
                                                             m.frame,
                                                             m.command,
                                                             m.current,
                                                             m.autocontinue,