Exemplo n.º 1
0
def init(_mpstate):
    '''initialise module'''
    global mpstate
    mpstate = _mpstate
    mpstate.console_state = module_state()
    mpstate.console = wxconsole.MessageConsole(title='Console')

    # setup some default status information
    mpstate.console.set_status('Mode', 'UNKNOWN', row=0, fg='blue')
    mpstate.console.set_status('GPS', 'GPS: --', fg='red', row=0)
    mpstate.console.set_status('Vcc', 'Vcc: --', fg='red', row=0)
    mpstate.console.set_status('Radio', 'Radio: --', row=0)
    mpstate.console.set_status('Heading', 'Hdg ---/---', row=2)
    mpstate.console.set_status('Alt', 'Alt ---', row=2)
    mpstate.console.set_status('AGL', 'AGL ---', row=2)
    mpstate.console.set_status('AirSpeed', 'AirSpeed --', row=2)
    mpstate.console.set_status('GPSSpeed', 'GPSSpeed --', row=2)
    mpstate.console.set_status('Thr', 'Thr ---', row=2)
    mpstate.console.set_status('Roll', 'Roll ---', row=2)
    mpstate.console.set_status('Pitch', 'Pitch ---', row=2)
    mpstate.console.set_status('WP', 'WP --', row=3)
    mpstate.console.set_status('WPDist', 'Distance ---', row=3)
    mpstate.console.set_status('WPBearing', 'Bearing ---', row=3)
    mpstate.console.set_status('AltError', 'AltError --', row=3)
    mpstate.console.set_status('AspdError', 'AspdError --', row=3)
    mpstate.console.set_status('FlightTime', 'FlightTime --', row=3)
    mpstate.console.set_status('ETR', 'ETR --', row=3)

    mpstate.console.ElevationMap = mp_elevation.ElevationModel()
Exemplo n.º 2
0
    def __init__(self, mpstate):
        super(TerrainModule, self).__init__(mpstate,
                                            "terrain",
                                            "terrain handling",
                                            public=False)

        self.ElevationModel = mp_elevation.ElevationModel()
        self.current_request = None
        self.sent_mask = 0
        self.last_send_time = time.time()
        self.requests_received = 0
        self.blocks_sent = 0
        self.check_lat = 0
        self.check_lon = 0
        self.add_command('terrain', self.cmd_terrain, "terrain control",
                         ["<status|check>", 'set (TERRAINSETTING)'])
        self.terrain_settings = mp_settings.MPSettings([('debug', int, 0),
                                                        ('enable', int, 1)])
        self.add_completion_function('(TERRAINSETTING)',
                                     self.terrain_settings.completion)
Exemplo n.º 3
0
 def __init__(self, mpstate):
     super(CameraViewModule, self).__init__(mpstate, "cameraview")
     self.add_command('cameraview', self.cmd_cameraview, "camera view")
     self.roll = 0
     self.pitch = 0
     self.yaw = 0
     self.mount_roll = 0
     self.mount_pitch = 0
     self.mount_yaw = 0
     self.height = 0
     self.lat = 0
     self.lon = 0
     self.home_height = 0
     self.hdg = 0
     self.elevation_model = mp_elevation.ElevationModel()
     self.camera_params = CameraParams() # TODO how to get actual camera params
     self.view_settings = mp_settings.MPSettings(
         [ ('r', float, 0.5),
           ('g', float, 0.5),
           ('b', float, 1.0),
         ])
     self.update_col()
Exemplo n.º 4
0
    def __init__(self, parent, state):
        from modules.lib import mp_widgets

        wx.Panel.__init__(self, parent)
        self.state = state
        self.img = None
        self.map_img = None
        self.redraw_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer)
        self.Bind(wx.EVT_SET_FOCUS, self.on_focus)
        self.redraw_timer.Start(200)
        self.mouse_pos = None
        self.mouse_down = None
        self.click_pos = None
        self.last_click_pos = None
        if state.elevation:
            self.ElevationMap = mp_elevation.ElevationModel()

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(self.mainSizer)

        # display for lat/lon/elevation
        self.position = wx.TextCtrl(self,
                                    style=wx.TE_MULTILINE | wx.TE_READONLY)
        if os.name == 'nt':
            self.position.SetValue("line 1\nline 2\n")
            size = self.position.GetBestSize()
            self.position.SetMinSize(size)
            self.position.SetValue("")
        else:
            textsize = tuple(
                self.position.GetFullTextExtent('line 1\nline 2\n')[0:2])
            self.position.SetMinSize(textsize)

        self.mainSizer.AddSpacer(2)
        self.mainSizer.Add(self.position,
                           flag=wx.LEFT | wx.BOTTOM | wx.GROW,
                           border=0)
        self.position.Bind(wx.EVT_SET_FOCUS, self.on_focus)

        # a place to put control flags
        self.controls = wx.BoxSizer(wx.HORIZONTAL)
        self.mainSizer.Add(self.controls,
                           0,
                           flag=wx.ALIGN_LEFT | wx.TOP | wx.GROW)
        self.mainSizer.AddSpacer(2)

        # a place to put information like image details
        self.information = wx.BoxSizer(wx.HORIZONTAL)
        self.mainSizer.Add(self.information,
                           0,
                           flag=wx.ALIGN_LEFT | wx.TOP | wx.GROW)
        self.mainSizer.AddSpacer(2)

        # panel for the main map image
        self.imagePanel = mp_widgets.ImagePanel(
            self, np.zeros((state.height, state.width, 3), dtype=np.uint8))
        self.mainSizer.Add(self.imagePanel, flag=wx.GROW, border=5)
        self.imagePanel.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse)
        self.imagePanel.Bind(wx.EVT_KEY_DOWN, self.on_key_down)
        self.imagePanel.Bind(wx.EVT_MOUSEWHEEL, self.on_mouse_wheel)

        # a function to convert from (lat,lon) to (px,py) on the map
        self.pixmapper = functools.partial(self.pixel_coords)

        self.last_view = None
        self.redraw_map()
        state.frame.Fit()
Exemplo n.º 5
0
    def __init__(self, mpstate):
        super(MapModule, self).__init__(mpstate,
                                        "map",
                                        "map display",
                                        public=True,
                                        multi_instance=True,
                                        multi_vehicle=True)
        cmdname = "map"
        if self.instance > 1:
            cmdname += "%u" % self.instance
        # lat/lon per system ID
        self.lat_lon = {}
        self.wp_change_time = 0
        self.fence_change_time = 0
        self.rally_change_time = 0
        self.have_simstate = False
        self.have_vehicle = {}
        self.move_wp = -1
        self.moving_wp = None
        self.moving_fencepoint = None
        self.moving_rally = None
        self.mission_list = None
        self.icon_counter = 0
        self.circle_counter = 0
        self.draw_line = None
        self.draw_callback = None
        self.have_global_position = False
        self.vehicle_type_by_sysid = {}
        self.vehicle_type_name = 'plane'
        self.ElevationMap = mp_elevation.ElevationModel()
        self.last_unload_check_time = time.time()
        self.unload_check_interval = 0.1  # seconds
        self.trajectory_layers = set()
        self.map_settings = mp_settings.MPSettings([
            ('showgpspos', int, 1), ('showgps2pos', int, 1),
            ('showsimpos', int, 0), ('showahrspos', int, 1),
            ('showahrs2pos', int, 0), ('showahrs3pos', int, 0),
            ('brightness', float, 1), ('rallycircle', bool, False),
            ('loitercircle', bool, False), ('showclicktime', int, 2),
            ('showdirection', bool, False)
        ])

        service = 'MicrosoftHyb'
        if 'MAP_SERVICE' in os.environ:
            service = os.environ['MAP_SERVICE']
        import platform
        from modules.mavproxy_map import mp_slipmap
        title = "Map"
        if self.instance > 1:
            title += str(self.instance)
        self.map = mp_slipmap.MPSlipMap(service=service,
                                        elevation=True,
                                        title=title)
        if self.instance == 1:
            self.mpstate.map = self.map
            mpstate.map_functions = {'draw_lines': self.draw_lines}

        self.map.add_callback(functools.partial(self.map_callback))
        self.add_command(
            cmdname, self.cmd_map, "map control",
            ['icon', 'set (MAPSETTING)', 'zoom', 'center', 'follow', 'clear'])
        self.add_completion_function('(MAPSETTING)',
                                     self.map_settings.completion)

        self.default_popup = MPMenuSubMenu('Popup', items=[])
        self.add_menu(
            MPMenuItem('Fly To',
                       'Fly To',
                       '# guided ',
                       handler=MPMenuCallTextDialog(
                           title='Altitude (m)',
                           default=self.mpstate.settings.guidedalt)))
        self.add_menu(MPMenuItem('Set Home', 'Set Home', '# map sethomepos '))
        self.add_menu(
            MPMenuItem('Set Home (with height)', 'Set Home', '# map sethome '))
        self.add_menu(
            MPMenuItem('Set Origin', 'Set Origin', '# map setoriginpos '))
        self.add_menu(
            MPMenuItem('Set Origin (with height)', 'Set Origin',
                       '# map setorigin '))
        self.add_menu(
            MPMenuItem('Terrain Check', 'Terrain Check', '# terrain check'))
        self.add_menu(
            MPMenuItem('Show Position', 'Show Position', 'showPosition'))

        self._colour_for_wp_command = {
            # takeoff commands
            mavutil.mavlink.MAV_CMD_NAV_TAKEOFF: (255, 0, 0),
            mavutil.mavlink.MAV_CMD_NAV_TAKEOFF_LOCAL: (255, 0, 0),
            mavutil.mavlink.MAV_CMD_NAV_VTOL_TAKEOFF: (255, 0, 0),

            # land commands
            mavutil.mavlink.MAV_CMD_NAV_LAND_LOCAL: (255, 255, 0),
            mavutil.mavlink.MAV_CMD_NAV_LAND: (255, 255, 0),
            mavutil.mavlink.MAV_CMD_NAV_VTOL_LAND: (255, 255, 0),

            # waypoint commands
            mavutil.mavlink.MAV_CMD_NAV_WAYPOINT: (0, 255, 255),
            mavutil.mavlink.MAV_CMD_NAV_SPLINE_WAYPOINT: (64, 255, 64),

            # other commands
            mavutil.mavlink.MAV_CMD_DO_LAND_START: (255, 127, 0),
        }
        self._label_suffix_for_wp_command = {
            mavutil.mavlink.MAV_CMD_NAV_TAKEOFF: "TOff",
            mavutil.mavlink.MAV_CMD_DO_LAND_START: "DLS",
            mavutil.mavlink.MAV_CMD_NAV_SPLINE_WAYPOINT: "SW",
            mavutil.mavlink.MAV_CMD_NAV_VTOL_LAND: "VL",
        }
Exemplo n.º 6
0
import socket, time, random, math

track_count = 0

# object types
DNFZ_types = {
    'Aircraft': 1,
    'Weather': 20000,
    'BirdMigrating': 30000,
    'BirdOfPrey': 40000
}

from modules.mavproxy_map import mp_elevation

ElevationMap = mp_elevation.ElevationModel()

gen_settings = mp_settings.MPSettings([("port", int, 45454), ('debug', int, 0),
                                       ('home_lat', float, -27.298440),
                                       ('home_lon', float, 151.290775),
                                       ('region_width', float, 15000),
                                       ('num_aircraft', int, 5),
                                       ('num_bird_prey', int, 5),
                                       ('num_bird_migratory', int, 5),
                                       ('num_weather', int, 5),
                                       ('wgs84_to_AMSL', float, -41.2),
                                       ('stop', int, 0)])


class DNFZ:
    '''a dynamic no-fly zone object'''