Exemplo n.º 1
0
def display_waypoints(wploader, map):
    '''display the waypoints'''
    mission_list = wploader.view_list()
    polygons = wploader.polygon_list()
    map.add_object(mp_slipmap.SlipClearLayer('Mission'))
    for k in range(len(polygons)):
        p = polygons[k]
        if len(p) > 1:
            map.add_object(
                mp_slipmap.SlipPolygon('mission %u' % k,
                                       p,
                                       layer='Mission',
                                       linewidth=2,
                                       colour=(255, 255, 255)))
        labeled_wps = {}
        for i in range(len(mission_list)):
            next_list = mission_list[i]
            for j in range(len(next_list)):
                #label already printed for this wp?
                if (next_list[j] not in labeled_wps):
                    map.add_object(
                        mp_slipmap.SlipLabel('miss_cmd %u/%u' % (i, j),
                                             polygons[i][j],
                                             str(next_list[j]),
                                             'Mission',
                                             colour=(0, 255, 255)))
                    labeled_wps[next_list[j]] = (i, j)
Exemplo n.º 2
0
    def display_waypoints(self):
        '''display the waypoints'''
        self.mission_list = self.module('wp').wploader.view_list()
        polygons = self.module('wp').wploader.polygon_list()
        self.mpstate.map.add_object(mp_slipmap.SlipClearLayer('Mission'))
        for i in range(len(polygons)):
            p = polygons[i]
            if len(p) > 1:
                popup = MPMenuSubMenu('Popup',
                                      items=[MPMenuItem('Set', returnkey='popupMissionSet'),
                                             MPMenuItem('WP Remove', returnkey='popupMissionRemove'),
                                             MPMenuItem('WP Move', returnkey='popupMissionMove')])
                self.mpstate.map.add_object(mp_slipmap.SlipPolygon('mission %u' % i, p,
                                                                   layer='Mission', linewidth=2, colour=(255,255,255),
                                                                   popup_menu=popup))
        loiter_rad = self.get_mav_param('WP_LOITER_RAD')
        labeled_wps = {}
        self.mpstate.map.add_object(mp_slipmap.SlipClearLayer('LoiterCircles'))
        for i in range(len(self.mission_list)):
            next_list = self.mission_list[i]
            for j in range(len(next_list)):
                #label already printed for this wp?
                if (next_list[j] not in labeled_wps):
                    self.mpstate.map.add_object(mp_slipmap.SlipLabel(
                        'miss_cmd %u/%u' % (i,j), polygons[i][j], str(next_list[j]), 'Mission', colour=(0,255,255)))

                    if (self.map_settings.loitercircle and
                        self.module('wp').wploader.wp_is_loiter(next_list[j])):
                        self.mpstate.map.add_object(mp_slipmap.SlipCircle('Loiter Circle %u' % (next_list[j] + 1), 'LoiterCircles', polygons[i][j], abs(loiter_rad), (255, 255, 255), 2))

                    labeled_wps[next_list[j]] = (i,j)
Exemplo n.º 3
0
    def loadkml(self, filename):
        '''Load a kml from file and put it on the map'''
        #Open the zip file
        nodes = self.readkmz(filename)

        #go through each object in the kml...
        for n in nodes:     
            point = self.readObject(n)
            
            #and place any polygons on the map
            if self.mpstate.map is not None and point[0] == 'Polygon':
                #print "Adding " + point[1]
                newcolour = (random.randint(0, 255), 0, random.randint(0, 255))
                curpoly = mp_slipmap.SlipPolygon(point[1], point[2],
                                                             layer=2, linewidth=2, colour=newcolour)
                self.mpstate.map.add_object(curpoly)
                self.allayers.append(curpoly)
                self.curlayers.append(point[1])
                
                
            #and points - barrell image and text
            if self.mpstate.map is not None and point[0] == 'Point':
                #print "Adding " + point[1]
                icon = self.mpstate.map.icon('barrell.png')
                curpoint = mp_slipmap.SlipIcon(point[1], latlon = (point[2][0][0], point[2][0][1]), layer=3, img=icon, rotation=0, follow=False)
                curtext = mp_slipmap.SlipLabel(point[1], point = (point[2][0][0], point[2][0][1]), layer=4, label=point[1], colour=(0,255,255))
                self.mpstate.map.add_object(curpoint)
                self.mpstate.map.add_object(curtext)
                self.allayers.append(curpoint)
                self.alltextlayers.append(curtext)
                self.curlayers.append(point[1])
                self.curtextlayers.append(point[1])
        self.menu_needs_refreshing = True
Exemplo n.º 4
0
    def display_waypoints(self):
        '''display the waypoints'''
        from MAVProxy.modules.mavproxy_map import mp_slipmap
        self.mission_list = self.module('wp').wploader.view_list()
        polygons = self.module('wp').wploader.polygon_list()
        self.map.add_object(mp_slipmap.SlipClearLayer('Mission'))
        for i in range(len(polygons)):
            p = polygons[i]
            if len(p) > 1:
                items = [MPMenuItem('Set', returnkey='popupMissionSet'),
                         MPMenuItem('WP Remove', returnkey='popupMissionRemove'),
                         MPMenuItem('WP Move', returnkey='popupMissionMove'),
                         MPMenuItem('Remove NoFly', returnkey='popupMissionRemoveNoFly'),
                ]
                popup = MPMenuSubMenu('Popup', items)
                self.map.add_object(mp_slipmap.SlipPolygon('mission %u' % i, p,
                                                                   layer='Mission', linewidth=2, colour=(255,255,255),
                                                                   arrow = self.map_settings.showdirection, popup_menu=popup))
        labeled_wps = {}
        self.map.add_object(mp_slipmap.SlipClearLayer('LoiterCircles'))
        if not self.map_settings.showwpnum:
            return
        for i in range(len(self.mission_list)):
            next_list = self.mission_list[i]
            for j in range(len(next_list)):
                #label already printed for this wp?
                if (next_list[j] not in labeled_wps):
                    label = self.label_for_waypoint(next_list[j])
                    colour = self.colour_for_wp(next_list[j])
                    self.map.add_object(mp_slipmap.SlipLabel(
                        'miss_cmd %u/%u' % (i,j), polygons[i][j], label, 'Mission', colour=colour))

                    if (self.map_settings.loitercircle and
                        self.module('wp').wploader.wp_is_loiter(next_list[j])):
                        wp = self.module('wp').wploader.wp(next_list[j])                    
                        if wp.command != mavutil.mavlink.MAV_CMD_NAV_LOITER_TO_ALT and wp.param3 != 0:
                            # wp radius and direction is defined by the mission
                            loiter_rad = wp.param3
                        elif wp.command == mavutil.mavlink.MAV_CMD_NAV_LOITER_TO_ALT and wp.param2 != 0:
                            # wp radius and direction is defined by the mission
                            loiter_rad = wp.param2
                        else:
                            # wp radius and direction is defined by the parameter
                            loiter_rad = self.get_mav_param('WP_LOITER_RAD')
                            
                        self.map.add_object(mp_slipmap.SlipCircle('Loiter Circle %u' % (next_list[j] + 1), 'LoiterCircles', polygons[i][j],
                                                                          loiter_rad, (255, 255, 255), 2, arrow = self.map_settings.showdirection))

                    labeled_wps[next_list[j]] = (i,j)
Exemplo n.º 5
0
def load_kml(kml):
    '''load a kml overlay, return list of map objects'''
    print("Loading kml %s" % kml)
    nodes = kmlread.readkmz(kml)
    ret = []
    for n in nodes:
        try:
            point = kmlread.readObject(n)
        except Exception as ex:
            continue

        if point[0] == 'Polygon':
            newcolour = (random.randint(0, 255), 0, random.randint(0, 255))
            curpoly = mp_slipmap.SlipPolygon(point[1],
                                             point[2],
                                             layer=2,
                                             linewidth=2,
                                             colour=newcolour)
            ret.append(curpoly)

        if point[0] == 'Point':
            icon = mp_tile.mp_icon('barrell.png')
            curpoint = mp_slipmap.SlipIcon(point[1],
                                           latlon=(point[2][0][0],
                                                   point[2][0][1]),
                                           layer=3,
                                           img=icon,
                                           rotation=0,
                                           follow=False)
            curtext = mp_slipmap.SlipLabel(point[1],
                                           point=(point[2][0][0],
                                                  point[2][0][1]),
                                           layer=4,
                                           label=point[1],
                                           colour=(0, 255, 255))
            ret.append(curpoint)
            ret.append(curtext)
    return ret