def __init__(self, config_path, viewport): self.config_path = config_path self.viewport = viewport self.selected = False viewport_geometry = ManagedWindow.lookup_viewport_geometry(self.viewport) cmd = ['/usr/bin/onboard', '-m'] onboard_width = viewport_geometry.width onboard_height = viewport_geometry.height / 4 onboard_x = viewport_geometry.x onboard_y = viewport_geometry.y + (viewport_geometry.height - onboard_height) onboard_geometry = WindowGeometry(x=onboard_x, y=onboard_y, width=onboard_width, height=onboard_height) self.config = OnboardConfig(config_path=config_path).get_config() window = ManagedWindow(w_class='Onboard', geometry=onboard_geometry, visible=False) cmd.extend(map(str, ['-x', onboard_x, '-y', onboard_y, '-s', '{}x{}'.format(onboard_width, onboard_height)])) self.app = ManagedApplication(cmd, window=window)
def __init__(self, display, viewport, janus_url): self.display = display self.viewport = viewport self.janus_url = janus_url self.geometry = ManagedWindow.lookup_viewport_geometry(viewport) self.players = {} self.lock = threading.Lock()
def _create_mplayer(self, mplayer_id, incoming_mplayer): """ Start a ManagedApplication instance according to the details in the media argument and return process instance, FIFO file (full path) to drive the mplayer application and resource URL. """ fifo_path = self._create_fifo(mplayer_id) geometry = WindowGeometry(x=incoming_mplayer.geometry.x, y=incoming_mplayer.geometry.y, width=incoming_mplayer.geometry.width, height=incoming_mplayer.geometry.height) mplayer_window = ManagedWindow(geometry=geometry, w_instance=str(mplayer_id), w_class="MPlayer") if incoming_mplayer.on_finish == "nothing" or incoming_mplayer.on_finish == "close": respawn = False else: respawn = True mplayer = ManagedMplayer(fifo_path=fifo_path, url=incoming_mplayer.url, slug=mplayer_id, window=mplayer_window, respawn=respawn) mplayer.set_state(ApplicationState.VISIBLE) rospy.logdebug( "MPlayer Pool: started new mplayer instance %s on viewport %s with id %s" % (self.viewport_name, incoming_mplayer, mplayer_id)) self.mplayers[mplayer_id] = mplayer return True
def test_combine_portrait_geometries(self): geometry_names = ['left_one', 'center', 'right_one'] combined_geometry = util.combine_viewport_geometries(geometry_names) expected_geometry = ManagedWindow.lookup_viewport_geometry('expected_portraits') self._assert_equal_geometries(expected_geometry, combined_geometry)
def __init__(self, viewports, arc_width): """ Args: viewports (list[str]): List of viewports from left to right. arc_width (float): Physical arc width of all viewports in radians. Raises: Exception: No viewports provided. """ if not len(viewports) > 0: raise Exception( 'Must provide at least one viewport for MegaViewport!') self.viewports = viewports self.arc_width = arc_width # Calculate aspect ratio of all viewports. # Here we do not assume that all viewports have the same dimensions. x_min = 16384 y_min = 16384 x_max = 0 y_max = 0 for viewport in viewports: geometry = ManagedWindow.lookup_viewport_geometry(viewport) x_min = min(geometry.x, x_min) y_min = min(geometry.y, y_min) x_max = max(geometry.x + geometry.width, x_max) y_max = max(geometry.y + geometry.height, y_max) overall_width = x_max - x_min overall_height = y_max - y_min aspect_ratio = overall_width / overall_height num_viewports = len(viewports) # It is assumed here that all viewports have the same width. self.viewport_width = self.arc_width / num_viewports self.arc_height = self.arc_width / aspect_ratio
def setUp(self): """ - instantiate ManagedMplayer - run asserts on object's parameters """ self.width = 1000 self.height = 1001 self.x = 1002 self.y = 1003 self.slug = 'testing_slug' self.url = 'http://lg-head/lg/assets/videos/bunny.mp4' self.fifo_path = '/tmp/asd_lol' self.cmd = '-idle -slave' self.geometry = WindowGeometry(width=self.width, height=self.height, x=self.x, y=self.y) self.window = ManagedWindow( geometry=self.geometry, w_instance="Mplayer \\({}\\)".format(self.slug), w_class="Mplayer \\({}\\)".format(self.slug)) self.mam = ManagedMplayer(window=self.window, fifo_path=self.fifo_path, slug=self.slug, url=self.url) super(ManagedMplayer, self.mam).__init__(cmd=self.cmd, window=self.window) rospy.logdebug("This is mam: %s" % self.mam.__dict__)
def test_combine_portrait_geometries(self): geometry_names = ['left_one', 'center', 'right_one'] combined_geometry = util.combine_viewport_geometries(geometry_names) expected_geometry = ManagedWindow.lookup_viewport_geometry( 'expected_portraits') self._assert_equal_geometries(expected_geometry, combined_geometry)
def _get_viewport_offset(self): """ Adhoc browser needs geometry that's honoring viewport offsets This method will add viewport offset """ viewport_geometry = ManagedWindow.get_viewport_geometry() if not viewport_geometry: viewport_geometry = WindowGeometry() return {'x': viewport_geometry.x, 'y': viewport_geometry.y}
def _get_viewport_offset(self): """ Director messages contain offset and size local to the screen that media should be displayed on. Screens have their own offsets that should be honored during ManagedWindow creation. This method will return `real` offset. """ viewport_geometry = ManagedWindow.get_viewport_geometry() if not viewport_geometry: viewport_geometry = WindowGeometry() return {'x': viewport_geometry.x, 'y': viewport_geometry.y}
def __init__(self, viewport, display, show_pointer, framerate, quality, image_pub): self.viewport = str(viewport) self.display = str(display) self.show_pointer = show_pointer self.framerate = int(framerate) self.quality = int(quality) self.image_pub = image_pub self.geometry = ManagedWindow.lookup_viewport_geometry(self.viewport) self.lock = threading.Lock() self._gst = None self._previous_width = None self._previous_height = None
def main(): rospy.init_node(NODE_NAME) geometry = ManagedWindow.get_viewport_geometry() url = rospy.get_param('~url', None) command_line_args = rospy.get_param('~command_line_args', '') scale_factor = rospy.get_param('~force_device_scale_factor', 1) extra_logging = rospy.get_param('~extra_logging', False) debug_port = rospy.get_param('~debug_port', None) user_agent = rospy.get_param( '~user_agent', 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; ' 'en-us AppleWebKit/531.21.10 (KHTML, like Gecko) ' + 'Version/4.0.4 Mobile/7B314 Safari/531.21.10') state = rospy.get_param('~state', ApplicationState.VISIBLE) extensions = rospy.get_param('~extensions', []) kiosk = rospy.get_param('~kiosk', True) global_dependency_timeout = rospy.get_param("/global_dependency_timeout", 15) depend_on_url = rospy.get_param("~depend_on_url", False) www_host = discover_host_from_url(url) www_port = discover_port_from_url(url) check_www_dependency(depend_on_url, www_host, www_port, 'static browser URL', global_dependency_timeout) browser = ManagedBrowser(geometry=geometry, url=url, command_line_args=command_line_args, log_stderr=extra_logging, force_device_scale_factor=scale_factor, remote_debugging_port=debug_port, user_agent=user_agent, extensions=extensions, kiosk=kiosk) browser.set_state(state) rospy.Subscriber('{}/state'.format(rospy.get_name()), ApplicationState, browser.handle_state_msg) def handle_debug_sock_msg(msg): browser.send_debug_sock_msg(msg.data) rospy.Subscriber('{}/debug'.format(rospy.get_name()), String, handle_debug_sock_msg) rospy.spin()
def main(): rospy.init_node(NODE_NAME) geometry = ManagedWindow.get_viewport_geometry() url = rospy.get_param('~url', None) command_line_args = rospy.get_param('~command_line_args', '') scale_factor = rospy.get_param('~force_device_scale_factor', 1) extra_logging = rospy.get_param('~extra_logging', False) debug_port = rospy.get_param('~debug_port', None) user_agent = rospy.get_param( '~user_agent', 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; ' 'en-us AppleWebKit/531.21.10 (KHTML, like Gecko) ' + 'Version/4.0.4 Mobile/7B314 Safari/531.21.10' ) state = rospy.get_param('~state', ApplicationState.VISIBLE) extensions = rospy.get_param('~extensions', []) kiosk = rospy.get_param('~kiosk', True) global_dependency_timeout = rospy.get_param("/global_dependency_timeout", 15) depend_on_url = rospy.get_param("~depend_on_url", False) www_host = discover_host_from_url(url) www_port = discover_port_from_url(url) check_www_dependency(depend_on_url, www_host, www_port, 'static browser URL', global_dependency_timeout) browser = ManagedBrowser( geometry=geometry, url=url, command_line_args=command_line_args, log_stderr=extra_logging, force_device_scale_factor=scale_factor, remote_debugging_port=debug_port, user_agent=user_agent, extensions=extensions, kiosk=kiosk ) browser.set_state(state) rospy.Subscriber('{}/state'.format(rospy.get_name()), ApplicationState, browser.handle_state_msg) def handle_debug_sock_msg(msg): browser.send_debug_sock_msg(msg.data) rospy.Subscriber('{}/debug'.format(rospy.get_name()), String, handle_debug_sock_msg) rospy.spin()
def combine_viewport_geometries(viewport_names): geometries = [ManagedWindow.lookup_viewport_geometry(v) for v in viewport_names] combined = WindowGeometry( x=geometries[0].x, y=geometries[0].y, width=geometries[0].width, height=geometries[0].height ) for geometry in geometries: combined.x = min(combined.x, geometry.x) combined.y = min(combined.y, geometry.y) combined.width = max(combined.width, geometry.x - combined.x + geometry.width) combined.height = max(combined.height, geometry.y - combined.y + geometry.height) return combined
def combine_viewport_geometries(viewport_names): geometries = [ ManagedWindow.lookup_viewport_geometry(v) for v in viewport_names ] combined = WindowGeometry(x=geometries[0].x, y=geometries[0].y, width=geometries[0].width, height=geometries[0].height) for geometry in geometries: combined.x = min(combined.x, geometry.x) combined.y = min(combined.y, geometry.y) combined.width = max(combined.width, geometry.x - combined.x + geometry.width) combined.height = max(combined.height, geometry.y - combined.y + geometry.height) return combined
def setUp(self): display = CAPTURE_DISPLAY geometry = ManagedWindow.lookup_viewport_geometry(CAPTURE_VIEWPORT) geometry_str = '{}x{}x24'.format(CAPTURE_WIDTH, CAPTURE_HEIGHT) self.image_capture = TopicCapture() self.image_capture_sub = rospy.Subscriber(CAPTURE_TOPIC, CompressedImage, self.image_capture.handle_msg) # Run an Xvfb with the configured DISPLAY and geometry matching the # viewport exactly. self.xvfb = ProcController( ['Xvfb', display, '-noreset', '-screen', '0', geometry_str] ) self.xvfb.start() rospy.sleep(3.0) self.pub = rospy.Publisher('/director/scene', GenericMessage, queue_size=100) rospy.sleep(1.0)
def __init__(self, viewports, arc_width): """ Args: viewports (list[str]): List of viewports from left to right. arc_width (float): Physical arc width of all viewports in radians. Raises: Exception: No viewports provided. """ if not len(viewports) > 0: raise Exception( 'Must provide at least one viewport for MegaViewport!' ) self.viewports = viewports self.arc_width = arc_width # Calculate aspect ratio of all viewports. # Here we do not assume that all viewports have the same dimensions. x_min = 16384 y_min = 16384 x_max = 0 y_max = 0 for viewport in viewports: geometry = ManagedWindow.lookup_viewport_geometry(viewport) x_min = min(geometry.x, x_min) y_min = min(geometry.y, y_min) x_max = max(geometry.x + geometry.width, x_max) y_max = max(geometry.y + geometry.height, y_max) overall_width = x_max - x_min overall_height = y_max - y_min aspect_ratio = overall_width / overall_height num_viewports = len(viewports) # It is assumed here that all viewports have the same width. self.viewport_width = self.arc_width / num_viewports self.arc_height = self.arc_width / aspect_ratio self.half_arc_width = self.arc_width / 2 self.half_arc_height = self.arc_height / 2
def main(): rospy.init_node(NODE_NAME, anonymous=True) geometry = ManagedWindow.get_viewport_geometry() server_type = rospy.get_param('~server_type', 'streetview') url = str(rospy.get_param('~url', DEFAULT_URL)) field_of_view = float(rospy.get_param('~fov', DEFAULT_FOV)) pitch_offset = float(rospy.get_param('~pitch_offset', 0)) show_links = str(rospy.get_param('~show_links', False)).lower() show_fps = str(rospy.get_param('~show_fps', False)).lower() show_attribution = str(rospy.get_param('~show_attribution', False)).lower() yaw_offset = float(rospy.get_param('~yaw_offset', 0)) yaw_offsets = str(rospy.get_param('~yaw_offsets', yaw_offset)) leader = str(rospy.get_param('~leader', 'false')) tilt = str(rospy.get_param('~tilt', 'false')) depend_on_webserver = rospy.get_param('~depend_on_webserver', False) depend_on_rosbridge = rospy.get_param('~depend_on_rosbridge', False) rosbridge_host = rospy.get_param('~rosbridge_host', '127.0.0.1') rosbridge_port = rospy.get_param('~rosbridge_port', 9090) rosbridge_secure = rospy.get_param('~rosbridge_secure', 'false') zoom = str(rospy.get_param('~zoom', 'false')).lower() initial_zoom = rospy.get_param('~initial_zoom', 3) kiosk = rospy.get_param('~kiosk', True) map_api_key = rospy.get_param('/google/maps_api_key', None) # put parameters into one big url url = add_url_params(url, zoom=zoom, initialZoom=initial_zoom, fov=field_of_view, pitchOffset=pitch_offset, showLinks=show_links, showFPS=show_fps, showAttribution=show_attribution, leader=leader, yawOffset=yaw_offset, yawOffsets=yaw_offsets, tilt=tilt, rosbridgeHost=rosbridge_host, rosbridgePort=rosbridge_port, rosbridgeSecure=rosbridge_secure) rospy.loginfo('Use Google maps API key: {}'.format(map_api_key)) if map_api_key: url = add_url_params(url, map_api_key=map_api_key) # check if server is already there host = discover_host_from_url(url) port = discover_port_from_url(url) timeout = rospy.get_param('/global_dependency_timeout', 15) check_www_dependency(depend_on_webserver, host, port, 'streetview server', timeout) check_www_dependency(depend_on_webserver, rosbridge_host, rosbridge_port, 'rosbridge', timeout) x_available_or_raise(timeout) # create the managed browser slug = server_type + "__" + "_fov-" + str(field_of_view) + "__" + "_yaw-" + str(yaw_offset) + "__" + "_pitch-" + str(pitch_offset) managed_browser = ManagedAdhocBrowser(url=url, geometry=geometry, slug=slug, kiosk=kiosk) # set initial state state = ApplicationState.STOPPED managed_browser.set_state(state) def state_proxy(msg): if not msg.state == ApplicationState.VISIBLE: managed_browser.set_state(ApplicationState.HIDDEN) else: managed_browser.set_state(ApplicationState.VISIBLE) # listen to state messages rospy.Subscriber('/%s/state' % server_type, ApplicationState, state_proxy) make_soft_relaunch_callback(managed_browser.handle_soft_relaunch, groups=['streetview']) rospy.spin()
def __init__(self, config, initial_state=None): args, geplus_config, layers_config, kml_content, view_content, \ tmpdir, instance = config self.tmpdir = tmpdir self.instance = instance # See whether we are running EC or Free. use_dir = None maybe_dirs = [ '/opt/google/earth/ec', '/opt/google/earth/free', ] for maybe_dir in maybe_dirs: if os.path.isdir(maybe_dir): use_dir = maybe_dir if use_dir is None: raise Exception('Could not find Earth install dir in {}'.format(maybe_dirs)) # Window placement support for the different versions. window_names = { '/opt/google/earth/ec': 'Google Earth EC', '/opt/google/earth/free': 'Google Earth', } window_classes = { '/opt/google/earth/ec': 'Google Earth EC', '/opt/google/earth/free': 'Googleearth-bin', } # Skip window management if this window is hidden. if '--hidegui' in args: earth_window = None else: geometry = ManagedWindow.get_viewport_geometry() if geometry is not None: geometry.y -= TOOLBAR_HEIGHT geometry.height += TOOLBAR_HEIGHT earth_window = ManagedWindow( geometry=geometry, w_class=window_classes[use_dir], w_name=window_names[use_dir], w_instance=self._get_instance() ) env = copy.copy(os.environ) # Override the HOME location. This requires a hack to the Earth # libraries if we are not using Enterprise Client. See the lg_earth README. env['OLDHOME'] = env['HOME'] env['HOME'] = self._get_tempdir() # Prevent external browser launch. env['BROWSER'] = '/dev/null' # If the Xorg DISPLAY is not in our environment, assume :0 if os.getenv('DISPLAY') is None: env['DISPLAY'] = ':0' # Google Earth has its own copies of some libraries normally found on # the system, so we need to tell the loader to look there. This is # normally done in the google-earth wrapper script. env['LD_LIBRARY_PATH'] += use_dir cmd = [use_dir + '/googleearth-bin'] cmd.extend(args) self.earth_proc = ManagedApplication(cmd, window=earth_window, initial_state=initial_state, env=env) # config rendering values self.geplus_config = geplus_config self.layers_config = layers_config self.kml_content = kml_content self.view_content = view_content self._render_configs()
def main(): rospy.init_node(NODE_NAME) geometry = ManagedWindow.get_viewport_geometry() url = rospy.get_param('~url', None) url_base = rospy.get_param('~url_base', 'http://lg-head/ros_touchscreens/ts/') command_line_args = rospy.get_param('~command_line_args', '') extra_logging = rospy.get_param('~extra_logging', False) # TODO (wz) director_host and director_port should be global director_host = rospy.get_param('~director_host', '42-a') director_port = rospy.get_param('~director_port', 8060) rosbridge_secure = rospy.get_param('~rosbridge_secure', 0) director_secure = rospy.get_param('~director_secure', 0) rosbridge_host = rospy.get_param('~rosbridge_host', '127.0.0.1') rosbridge_port = rospy.get_param('~rosbridge_port', 9090) ts_name = rospy.get_param('~ts_name', 'default') depend_on_rosbridge = rospy.get_param('~depend_on_rosbridge', False) depend_on_director = rospy.get_param('~depend_on_director', False) global_dependency_timeout = rospy.get_param('/global_dependency_timeout', 15) check_www_dependency(depend_on_rosbridge, rosbridge_host, rosbridge_port, 'rosbridge', global_dependency_timeout) check_www_dependency(depend_on_director, director_host, director_port, 'director', global_dependency_timeout) x_available_or_raise(global_dependency_timeout) if url: rospy.loginfo("got prepared full url: %s" % url) else: url = url_base + ts_name + "/" url = add_url_params(url, director_host=director_host, director_port=director_port, director_secure=director_secure, rosbridge_secure=rosbridge_secure, rosbridge_host=rosbridge_host, rosbridge_port=rosbridge_port) url = url2pathname(url) rospy.loginfo("assembled a url: %s" % url) scale_factor = rospy.get_param('~force_device_scale_factor', 1) debug_port = rospy.get_param('~debug_port', None) user_agent = rospy.get_param( '~user_agent', 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; ' 'en-us AppleWebKit/531.21.10 (KHTML, like Gecko) ' + 'Version/4.0.4 Mobile/7B314 Safari/531.21.10' ) log_level = rospy.get_param('/logging/level', 0) browser = ManagedBrowser( geometry=geometry, url=url, log_level=log_level, command_line_args=command_line_args, log_stderr=extra_logging, force_device_scale_factor=scale_factor, remote_debugging_port=debug_port, user_agent=user_agent ) browser.set_state(ApplicationState.VISIBLE) make_soft_relaunch_callback(browser.handle_soft_relaunch, groups=['touchscreen']) def handle_debug_sock_msg(msg): browser.send_debug_sock_msg(msg.data) rospy.Subscriber('{}/debug'.format(rospy.get_name()), String, handle_debug_sock_msg) rospy.spin()
def __init__( self, url=None, slug=None, kiosk=True, geometry=None, binary=DEFAULT_BINARY, remote_debugging_port=None, app=False, shell=True, command_line_args=[], default_args_removal=[], disk_cache_size=314572800, log_level=0, extensions=[], log_stderr=False, user_agent='', pepper_flash_dir='/home/lg/inc/PepperFlash', pnacl_dir='/home/lg/inc/pnacl', **kwargs ): # If no slug provided, attempt to use the node name. if slug is None: try: slug = rospy.get_name().lstrip('/') except Exception as e: sys.stderr.write('Could not resolve slug for this browser!') sys.stderr.write(' * Has your node been initialized?') raise e cmd = [binary] if user_agent: cmd.append('--user-agent={}'.format(user_agent)) # If no debug port provided, pick one. if remote_debugging_port is None: remote_debugging_port = ManagedBrowser.get_os_port() self.debug_port = ManagedBrowser.get_os_port() self.relay = TCPRelay(self.debug_port, remote_debugging_port) if log_stderr: cmd.append('--enable-logging=stderr') else: cmd.append('--enable-logging') cmd.append('--remote-debugging-port={}'.format(self.debug_port)) cmd.append('--log-level={}'.format(log_level)) self.tmp_dir = '/tmp/lg_browser_{}'.format(slug) self.clear_tmp_dir() self.pepper_flash_dir = pepper_flash_dir self.pnacl_dir = pnacl_dir self.init_tmp_dir() cmd.append('--user-data-dir={}'.format(self.tmp_dir)) cmd.append('--disk-cache-dir={}'.format(self.tmp_dir)) cmd.append('--crash-dumps-dir={}/crashes'.format(self.tmp_dir)) if extensions: for extension in extensions: if not os.path.isdir(extension): extensions.remove(extension) rospy.logwarn("Could not load extension from %s because dir does not exist" % extension) if extensions: cmd.append('--load-extension={}'.format(','.join(extensions))) for _cmd in default_args_removal: if _cmd in DEFAULT_ARGS: DEFAULT_ARGS.remove(_cmd) cmd.extend(DEFAULT_ARGS) if command_line_args != []: cmd.extend(command_line_args) # All remaining kwargs are mapped to command line args. # _ is replaced with -. def consume_kwarg(item): key, value = item arg = '--{}'.format(key.replace('_', '-')) if value is None: return arg if isinstance(value, bool): arg += '=' + str(value).lower() else: arg += '=' + str(value) return arg args = map(consume_kwarg, kwargs.iteritems()) cmd.extend(args) if app: cmd.append('--app={}'.format(url)) else: if kiosk: cmd.append('--kiosk') pass if url is not None: cmd.append(url) # finishing command line and piping output to logger rospy.logdebug("Starting cmd: %s" % cmd) # Different versions of Chrome use different window instance names. # Matching the tmp_dir should work for all of them. w_instance = '\\({}\\)'.format(self.tmp_dir) window = ManagedWindow(w_instance=w_instance, geometry=geometry, chrome_kiosk_workaround=kiosk) rospy.logdebug("Command {}".format(cmd)) # clean up after thyself rospy.on_shutdown(self.clear_tmp_dir) super(ManagedBrowser, self).__init__(cmd=cmd, window=window)
def main(): rospy.init_node(NODE_NAME, anonymous=True) geometry = ManagedWindow.get_viewport_geometry() server_type = rospy.get_param('~server_type', 'streetview') url = str(rospy.get_param('~url', DEFAULT_URL)) field_of_view = float(rospy.get_param('~fov', DEFAULT_FOV)) pitch_offset = float(rospy.get_param('~pitch_offset', 0)) show_links = str(rospy.get_param('~show_links', False)).lower() show_fps = str(rospy.get_param('~show_fps', False)).lower() show_attribution = str(rospy.get_param('~show_attribution', False)).lower() yaw_offset = float(rospy.get_param('~yaw_offset', 0)) yaw_offsets = str(rospy.get_param('~yaw_offsets', yaw_offset)) leader = str(rospy.get_param('~leader', 'false')) tilt = str(rospy.get_param('~tilt', 'false')) depend_on_webserver = rospy.get_param('~depend_on_webserver', False) depend_on_rosbridge = rospy.get_param('~depend_on_rosbridge', False) rosbridge_host = rospy.get_param('~rosbridge_host', '127.0.0.1') rosbridge_port = rospy.get_param('~rosbridge_port', 9090) rosbridge_secure = rospy.get_param('~rosbridge_secure', 'false') zoom = str(rospy.get_param('~zoom', 'false')).lower() initial_zoom = rospy.get_param('~initial_zoom', 3) kiosk = rospy.get_param('~kiosk', True) map_api_key = rospy.get_param('~map_api_key', None) # put parameters into one big url url = add_url_params(url, zoom=zoom, initialZoom=initial_zoom, fov=field_of_view, pitchOffset=pitch_offset, showLinks=show_links, showFPS=show_fps, showAttribution=show_attribution, leader=leader, yawOffset=yaw_offset, yawOffsets=yaw_offsets, tilt=tilt, rosbridgeHost=rosbridge_host, rosbridgePort=rosbridge_port, rosbridgeSecure=rosbridge_secure) rospy.loginfo('Use Google maps API key: {}'.format(map_api_key)) if map_api_key: url = add_url_params(url, map_api_key=map_api_key) # check if server is already there host = discover_host_from_url(url) port = discover_port_from_url(url) timeout = rospy.get_param('/global_dependency_timeout', 15) check_www_dependency(depend_on_webserver, host, port, 'streetview server', timeout) check_www_dependency(depend_on_webserver, rosbridge_host, rosbridge_port, 'rosbridge', timeout) x_available_or_raise(timeout) # create the managed browser slug = server_type + "__" + "_fov-" + str(field_of_view) + "__" + "_yaw-" + str(yaw_offset) + "__" + "_pitch-" + str(pitch_offset) managed_browser = ManagedAdhocBrowser(url=url, geometry=geometry, slug=slug, kiosk=kiosk) # set initial state state = ApplicationState.STOPPED managed_browser.set_state(state) def state_proxy(msg): if not msg.state == ApplicationState.VISIBLE: managed_browser.set_state(ApplicationState.HIDDEN) else: managed_browser.set_state(ApplicationState.VISIBLE) # listen to state messages rospy.Subscriber('/%s/state' % server_type, ApplicationState, state_proxy) make_soft_relaunch_callback(managed_browser.handle_soft_relaunch, groups=['streetview']) rospy.spin()