Пример #1
0
def main():
    rospy.init_node('lg_media_service_mplayer', anonymous=True)
    viewport_name = rospy.get_param("~viewport", DEFAULT_VIEWPORT)

    if not viewport_name:
        rospy.logerr("Viewport is not set - exiting")
        exit(1)

    topic_name = "/{0}/{1}".format(ROS_NODE_NAME, viewport_name)
    mplayer_pool = MplayerPool(viewport_name)
    make_soft_relaunch_callback(mplayer_pool.handle_soft_relaunch, groups=["media"])

    # Initialize mplayer pool on specified viewport
    rospy.Subscriber(topic_name, AdhocMedias, mplayer_pool.handle_ros_message)

    # Initialize director => mplayer pool bridge
    adhoc_media_mplayer_pool_publisher = rospy.Publisher(topic_name,
                                                         AdhocMedias,
                                                         queue_size=3)
    adhoc_media_mplayer_director_bridge = DirectorMediaBridge(
        adhoc_media_mplayer_pool_publisher,
        viewport_name,
        MEDIA_TYPE)
    rospy.Subscriber('/director/scene',
                     GenericMessage,
                     adhoc_media_mplayer_director_bridge.translate_director)

    handle_initial_state(adhoc_media_mplayer_director_bridge.translate_director)

    # Create service service about the mplayer pool service
    rospy.Service(SRV_QUERY,
                  MediaAppsInfo,
                  mplayer_pool.get_media_apps_info)
    rospy.spin()
Пример #2
0
def main():
    rospy.init_node(NODE_NAME)

    viewports = str(rospy.get_param('~viewports'))
    viewports = [x.strip() for x in viewports.split(',')]
    geometry = util.combine_viewport_geometries(viewports)
    url = str(rospy.get_param('~url', DEFAULT_URL))
    field_of_view = float(rospy.get_param('~fov', DEFAULT_FOV))
    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'))
    clock_addr = rospy.get_param('~clock_addr', 'ws://localhost:9091')
    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')
    kiosk = rospy.get_param('~kiosk', True)

    url = add_url_params(url,
                         hFov=field_of_view,
                         master=leader,
                         clockAddr=clock_addr,
                         yawOffsets=yaw_offsets,
                         rosbridgeHost=rosbridge_host,
                         rosbridgePort=rosbridge_port,
                         rosbridgeSecure=rosbridge_secure)

    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, 'panovideo server', timeout)
    check_www_dependency(depend_on_webserver, rosbridge_host, rosbridge_port, 'rosbridge', timeout)

    x_available_or_raise(timeout)

    slug = "lg_panovideo__" + str(geometry).replace('\n', '_').replace(': ', '_')
    managed_browser = ManagedAdhocBrowser(url=url, geometry=geometry, slug=slug, kiosk=kiosk)

    # set initial state
    state = ApplicationState.STOPPED
    managed_browser.set_state(state)

    make_soft_relaunch_callback(managed_browser.handle_soft_relaunch, groups=['panovideo'])

    def handle_scene(scene):
        has_panovideo = has_activity(scene, 'panovideo')
        if has_panovideo:
            managed_browser.set_state(ApplicationState.VISIBLE)
        else:
            managed_browser.set_state(ApplicationState.STOPPED)

    on_new_scene(handle_scene)

    rospy.spin()
Пример #3
0
def main():
    rospy.init_node(NODE_NAME, anonymous=True)

    topic = rospy.get_param('~director_topic', '/director/scene')
    service_channel = rospy.get_param('~service_channel', 'kmlsync/state')
    playtour_channel = rospy.get_param('~playtour_channel', 'kmlsync/playtour_query')
    planet_channel = rospy.get_param('~planet_channel', 'kmlsync/planet_query')
    s = KmlSyncState()
    rospy.Subscriber(topic, GenericMessage, s._save_state)
    handle_initial_state(s._save_state)
    rospy.Service(service_channel, KmlState, s._process_service_request)
    rospy.Service(playtour_channel, PlaytourQuery, s._send_playtour_query)
    rospy.Service(planet_channel, PlanetQuery, s._send_planet_query)
    make_soft_relaunch_callback(s._handle_soft_relaunch, groups=["earth"])

    rospy.spin()
Пример #4
0
def main():
    rospy.init_node(NODE_NAME)

    kmlsync_host = 'localhost'
    kmlsync_port = rospy.get_param('/kmlsync_server/port', 8765)
    global_dependency_timeout = rospy.get_param('/global_dependency_timeout',
                                                15)
    depend_on_kmlsync = rospy.get_param('~depend_on_kmlsync', False)
    initial_state = rospy.get_param('~initial_state', 'VISIBLE')
    state_topic = rospy.get_param('~state_topic', '/earth/state')

    if os.environ.get("LG_LANG"):
        os.environ["LANG"] = os.environ["LG_LANG"]

    check_www_dependency(depend_on_kmlsync, kmlsync_host, kmlsync_port,
                         'kmlsync', global_dependency_timeout)

    x_available_or_raise(global_dependency_timeout)

    viewsync_port = None
    if rospy.get_param('~viewsync_send', False):
        viewsync = make_viewsync()
        viewsync_port = viewsync.listen_port
    random_stagger = rospy.get_param('~staggered', False)
    if random_stagger:
        random_sleep_length = randint(1, 10)
        rospy.logerr("Random sleep length: {}".format(random_sleep_length))
        sleep(random_sleep_length)

    instance = '_earth_instance_' + rospy.get_name().strip('/')
    tmpdir = os.path.normpath(systmp() + '/' + instance)
    config = get_config(tmpdir, instance, viewsync_port)
    # extend config with tmpdir and instance
    config = config + (tmpdir, instance)
    client = Client(config, initial_state=initial_state)

    rospy.Subscriber(state_topic, ApplicationState,
                     client.earth_proc.handle_state_msg)
    if random_stagger:
        make_soft_relaunch_callback(client._handle_staggered_soft_relaunch,
                                    groups=["earth"])
    else:
        make_soft_relaunch_callback(client._handle_soft_relaunch,
                                    groups=["earth"])
    rospy.spin()
Пример #5
0
def main():
    rospy.init_node(NODE_NAME)

    viewport_name = rospy.get_param('~viewport', None)
    if not viewport_name:
        msg = "Viewport not configured for lg_media browser_launcher - exiting"
        rospy.logerr(msg)
        exit(1)

    browser_pool_publisher = rospy.Publisher(
        '/media_service/launch_browser/%s' % viewport_name,
        AdhocBrowsers,
        queue_size=10)
    is_leader = str(rospy.get_param('~leader', False)).lower()
    ros_port = str(rospy.get_param('~ros_port', '9090'))
    ros_host = str(rospy.get_param('~ros_host', 'localhost'))
    url = str(rospy.get_param('~videosync_url', VIDEOSYNC_URL))
    sync_rate = str(rospy.get_param('~sync_rate', 60))
    frame_latency = str(rospy.get_param('~frame_latency', 3 / 25))
    ping_interval = str(rospy.get_param('~ping_interval', 1000))
    hard_sync_diff = str(rospy.get_param('~hard_sync_diff', 1.0))
    min_playbackrate = str(rospy.get_param('~min_playbackrate', 0.5))
    max_playbackrate = str(rospy.get_param('~max_playbackrate', 1.5))
    autoplay = str(rospy.get_param('~autoplay', False)).lower()
    show_controls = str(rospy.get_param('~show_controls', False)).lower()

    basic_browser_data = BasicBrowserData(browser_pool_publisher, is_leader,
                                          ros_port, ros_host, url, sync_rate,
                                          frame_latency, ping_interval,
                                          hard_sync_diff, min_playbackrate,
                                          max_playbackrate, autoplay,
                                          show_controls, viewport_name)

    browser_pool = AdhocBrowserPool(viewport_name)
    make_soft_relaunch_callback(browser_pool.handle_soft_relaunch,
                                groups=["media"])

    rospy.Subscriber('/media_service/browser/%s' % viewport_name, AdhocMedias,
                     basic_browser_data.launch_browser)

    rospy.Subscriber('/media_service/launch_browser/%s' % viewport_name,
                     AdhocBrowsers, browser_pool.handle_ros_message)

    rospy.spin()
Пример #6
0
def main():
    rospy.init_node(NODE_NAME)

    kmlsync_host = 'localhost'
    kmlsync_port = rospy.get_param('/kmlsync_server/port', 8765)
    global_dependency_timeout = rospy.get_param('/global_dependency_timeout', 15)
    depend_on_kmlsync = rospy.get_param('~depend_on_kmlsync', False)
    initial_state = rospy.get_param('~initial_state', 'VISIBLE')
    state_topic = rospy.get_param('~state_topic', '/earth/state')

    if os.environ.get("LG_LANG"):
        os.environ["LANG"] = os.environ["LG_LANG"]

    check_www_dependency(depend_on_kmlsync, kmlsync_host, kmlsync_port, 'kmlsync', global_dependency_timeout)

    x_available_or_raise(global_dependency_timeout)

    viewsync_port = None
    if rospy.get_param('~viewsync_send', False):
        viewsync = make_viewsync()
        viewsync_port = viewsync.listen_port
    random_stagger = rospy.get_param('~staggered', False)
    if random_stagger:
        random_sleep_length = randint(1, 10)
        rospy.logerr("Random sleep length: {}".format(random_sleep_length))
        sleep(random_sleep_length)

    instance = '_earth_instance_' + rospy.get_name().strip('/')
    tmpdir = os.path.normpath(systmp() + '/' + instance)
    config = get_config(tmpdir, instance, viewsync_port)
    # extend config with tmpdir and instance
    config = config + (tmpdir, instance)
    client = Client(config, initial_state=initial_state)

    rospy.Subscriber(state_topic, ApplicationState,
                     client.earth_proc.handle_state_msg)
    if random_stagger:
        make_soft_relaunch_callback(client._handle_staggered_soft_relaunch, groups=["earth"])
    else:
        make_soft_relaunch_callback(client._handle_soft_relaunch, groups=["earth"])
    rospy.spin()
Пример #7
0
def main():
    rospy.init_node(NODE_NAME)

    viewport_name = rospy.get_param('~viewport', None)
    if not viewport_name:
        msg = "Viewport not configured for lg_media browser_launcher - exiting"
        rospy.logerr(msg)
        exit(1)

    browser_pool_publisher = rospy.Publisher('/media_service/launch_browser/%s' % viewport_name,
                                             AdhocBrowsers, queue_size=10)
    is_leader = str(rospy.get_param('~leader', False)).lower()
    ros_port = str(rospy.get_param('~ros_port', '9090'))
    ros_host = str(rospy.get_param('~ros_host', 'localhost'))
    url = str(rospy.get_param('~videosync_url', VIDEOSYNC_URL))
    sync_rate = str(rospy.get_param('~sync_rate', 60))
    frame_latency = str(rospy.get_param('~frame_latency', 3 / 25))
    ping_interval = str(rospy.get_param('~ping_interval', 1000))
    hard_sync_diff = str(rospy.get_param('~hard_sync_diff', 1.0))
    min_playbackrate = str(rospy.get_param('~min_playbackrate', 0.5))
    max_playbackrate = str(rospy.get_param('~max_playbackrate', 1.5))
    autoplay = str(rospy.get_param('~autoplay', False)).lower()
    show_controls = str(rospy.get_param('~show_controls', False)).lower()

    basic_browser_data = BasicBrowserData(browser_pool_publisher, is_leader,
                                          ros_port, ros_host, url, sync_rate,
                                          frame_latency, ping_interval,
                                          hard_sync_diff, min_playbackrate,
                                          max_playbackrate, autoplay,
                                          show_controls, viewport_name)

    browser_pool = AdhocBrowserPool(viewport_name)
    make_soft_relaunch_callback(browser_pool.handle_soft_relaunch, groups=["media"])

    rospy.Subscriber('/media_service/browser/%s' % viewport_name, AdhocMedias,
                     basic_browser_data.launch_browser)

    rospy.Subscriber('/media_service/launch_browser/%s' % viewport_name, AdhocBrowsers,
                     browser_pool.handle_ros_message)

    rospy.spin()
Пример #8
0
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()
Пример #9
0
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()
Пример #10
0
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()
Пример #11
0
def main():
    rospy.init_node('pano_viewer_server', anonymous=True)
    server_type = rospy.get_param('~server_type', 'streetview')
    location_pub = rospy.Publisher('/%s/location' % server_type,
                                   Pose2D,
                                   queue_size=1)
    panoid_pub = rospy.Publisher('/%s/panoid' % server_type,
                                 String,
                                 queue_size=1)
    pov_pub = rospy.Publisher('/%s/pov' % server_type,
                              Quaternion,
                              queue_size=2)
    metadata_pub = rospy.Publisher('/%s/metadata' % server_type,
                                   String,
                                   queue_size=10)
    director_pub = rospy.Publisher('/director/scene',
                                   GenericMessage,
                                   queue_size=1)

    tilt_min = rospy.get_param('~tilt_min', DEFAULT_TILT_MIN)
    tilt_max = rospy.get_param('~tilt_max', DEFAULT_TILT_MAX)
    zoom_min = rospy.get_param('~zoom_min', DEFAULT_ZOOM_MIN)
    zoom_max = rospy.get_param('~zoom_max', DEFAULT_ZOOM_MAX)
    nav_sensitivity = rospy.get_param('~nav_sensitivity',
                                      DEFAULT_NAV_SENSITIVITY)
    x_threshold = rospy.get_param('~x_threshold', X_THRESHOLD)
    space_nav_interval = rospy.get_param('~space_nav_interval',
                                         DEFAULT_NAV_INTERVAL)
    nearby_class = rospy.get_param('~nearby_class', 'NearbyStreetviewPanos')
    nearby = get_nearby(nearby_class)
    inverted = str(rospy.get_param('~inverted', "false")).lower() == "true"
    nearby.invert(inverted)
    tick_rate = rospy.get_param('~tick_rate', DEFAULT_TICK_RATE)

    server = PanoViewerServer(location_pub,
                              panoid_pub,
                              pov_pub,
                              tilt_min,
                              tilt_max,
                              nav_sensitivity,
                              space_nav_interval,
                              x_threshold,
                              nearby,
                              metadata_pub,
                              zoom_max,
                              zoom_min,
                              tick_rate,
                              director_pub=director_pub,
                              server_type=server_type)

    visibility_publisher = rospy.Publisher('/%s/state' % server_type,
                                           ApplicationState,
                                           queue_size=1)

    rospy.Subscriber('/%s/location' % server_type, Pose2D,
                     server.handle_location_msg)
    rospy.Subscriber('/%s/metadata' % server_type, String,
                     server.handle_metadata_msg)
    rospy.Subscriber('/%s/panoid' % server_type, String,
                     server.handle_panoid_msg)
    rospy.Subscriber('/%s/pov' % server_type, Quaternion,
                     server.handle_pov_msg)
    rospy.Subscriber('/lg_twister/twist', Twist, server.handle_spacenav_msg)
    rospy.Subscriber('/%s/state' % server_type, ApplicationState,
                     server.handle_state_msg)
    rospy.Subscriber('/%s/raw_metadata' % server_type, String,
                     server.handle_raw_metadata_msg)
    rospy.Subscriber('/spacenav/joy', Joy, server.handle_joy)
    rospy.Subscriber('/%s/tilt_snappy' % server_type, Bool,
                     server.handle_tilt_snappy)
    rospy.Service('/%s/panoid_state' % server_type, PanoIdState,
                  server.get_panoid)
    make_soft_relaunch_callback(server.handle_soft_relaunch,
                                groups=['streetview'])

    # This will translate director messages into /<server_type>/panoid messages
    def handle_director_message(scene):
        rospy.loginfo('running handle director w/ scene: %s' % scene)
        _server_type = server_type
        if _server_type == 'streetview_old':
            _server_type = 'streetview'
        has_asset = has_activity(scene, _server_type)
        has_no_activity = has_activity(scene, 'no_activity')
        if has_no_activity:
            rospy.loginfo('ignoring scene due to no_activity')
            return
        if not has_asset:
            rospy.loginfo('hiding self')
            visibility_publisher.publish(ApplicationState(state='HIDDEN'))
            return
        if scene.get('slug', '') == 'auto_generated_sv_scene':
            rospy.loginfo("Ignoring my own generated message")
            asset = get_activity_config_from_activity(scene, _server_type)
            panoid = asset.get('panoid', '')
            rospy.logerr("length of panoid is %s server type %s" %
                         (len(panoid), server_type))
            rospy.logerr("panoid is %s" % panoid)
            if server_type == 'streetview' and (panoid[0:2] != 'F:'
                                                and len(panoid) < 60):
                visibility_publisher.publish(ApplicationState(state='VISIBLE'))
                rospy.logerr("publishing visible for {}".format(server_type))
                return
            elif server_type == 'streetview_old' and (panoid[0:2] == 'F:'
                                                      or len(panoid) >= 60):
                rospy.logerr("publishing visible for {}".format(server_type))
                visibility_publisher.publish(ApplicationState(state='VISIBLE'))
                return
            elif server_type == 'panoviewer' or server_type == 'panovideo':
                visibility_publisher.publish(ApplicationState(state='VISIBLE'))
                return
            visibility_publisher.publish(ApplicationState(state='HIDDEN'))
            return

        if server_type == 'streetview' or server_type == 'streetview_old':
            asset = get_activity_config_from_activity(scene, server_type)
            panoid = asset.get('panoid', '')
            if server_type == 'streetview' and panoid[0:2] == 'F:':
                rospy.logerr("leaving early for {}".format(server_type))
                return
            elif server_type == 'streetview_old' and panoid[0:2] != 'F':
                rospy.logerr("leaving early for {}".format(server_type))
                return
        else:
            panoid = scene['windows'][0]['assets'][0]

        visibility_publisher.publish(ApplicationState(state='VISIBLE'))

        pov = server.pov
        try:
            pov.x = float(asset['tilt'])
        except:
            pov.x = 0
        try:
            pov.z = float(asset['heading'])
            # we don't want to flip the auto generated ones, or the non_inverted
            if scene.get('slug', '') != 'auto_generated_sv_scene' and inverted:
                pov.z = (pov.z + 180) % 360
        except:
            pov.z = 0
        pov.w = zoom_max

        server.pub_panoid(panoid, pov=pov)

    def initial_state_handler(uscs_msg):
        try:
            rospy.loginfo("about to load json: %s" % uscs_msg.message)
            scene = json.loads(uscs_msg.message)
        except:
            return
        handle_director_message(scene)

    on_new_scene(handle_director_message)
    handle_initial_state(initial_state_handler)

    rospy.spin()
Пример #12
0
def main():
    rospy.init_node(NODE_NAME, anonymous=True)

    extensions_root = rospy.get_param('~extensions_root', '/opt/endpoint/chrome/extensions/')
    viewport_name = rospy.get_param('~viewport', None)
    rosbridge_port = rospy.get_param('~rosbridge_port', 9090)
    rosbridge_host = rospy.get_param('~rosbridge_port', 'localhost')
    depend_on_rosbridge = rospy.get_param('~depend_on_rosbridge', True)
    global_dependency_timeout = rospy.get_param('/global_dependency_timeout', 15)
    hide_delay = rospy.get_param('~hide_delay', 0.5)
    destroy_delay = rospy.get_param('~destroy_delay', 2)

    if not viewport_name:
        rospy.logerr("Viewport is not set in the roslaunch file. Exiting.")
        exit(1)

    """
    Initialize adhoc browser pool
    """

    topic_name = '/browser_service/{}'.format(viewport_name)
    common_topic_name = '/browser_service/browsers'

    actors = []

    adhocbrowser_pool = AdhocBrowserPool(viewport_name=viewport_name,
                                         extensions_root=extensions_root,
                                         hide_delay=hide_delay,
                                         destroy_delay=destroy_delay)

    make_soft_relaunch_callback(adhocbrowser_pool.handle_soft_relaunch,
                                groups=["media"])

    browser_service_sub = rospy.Subscriber(
        topic_name,
        AdhocBrowsers,
        adhocbrowser_pool.handle_ros_message
    )

    actors.append(browser_service_sub)

    """
    Initialize director => browser pool bridge that translates director GenericMessage to AdhocBrowsers.msg
    """

    adhocbrowser_viewport_publisher = rospy.Publisher(
        topic_name, AdhocBrowsers, queue_size=3)
    actors.append(adhocbrowser_viewport_publisher)

    adhocbrowser_aggregate_topic_publisher = rospy.Publisher(common_topic_name,
                                                             AdhocBrowsers,
                                                             queue_size=3)
    actors.append(adhocbrowser_aggregate_topic_publisher)

    adhocbrowser_director_bridge = AdhocBrowserDirectorBridge(
        adhocbrowser_aggregate_topic_publisher,
        adhocbrowser_viewport_publisher,
        viewport_name)

    director_scene_sub = rospy.Subscriber('/director/scene', GenericMessage, adhocbrowser_director_bridge.translate_director)
    actors.append(director_scene_sub)
    director_ready_sub = rospy.Subscriber('/director/ready', Ready, adhocbrowser_pool.unhide_browsers)
    actors.append(director_ready_sub)

    rospy.wait_for_service('/readiness_node/ready', 15)
    rospy.wait_for_service('/lg_offliner/status', 15)
    wait_for_pub_sub_connections(actors)

    handle_initial_state(adhocbrowser_director_bridge.translate_director)

    """
    Initialize overlay hiding listener
    """
    def getBrowserIds(msg):
        s = msg.data
        if '[' in s and ']' in s:
            ids = [sp for sp in re.split('\[\]\, ', s) if len(sp) > 0]
            adhocbrowser_pool.minimize_browsers(ids)
        else:
            adhocbrowser_pool.minimize_browsers([s])

    rospy.Subscriber('/director/minimize', String, getBrowserIds)

    """
    Spin FTW
    """
    rospy.spin()
Пример #13
0
def main():
    rospy.init_node(NODE_NAME)

    viewports = str(rospy.get_param('~viewports'))
    viewports = [x.strip() for x in viewports.split(',')]
    geometry = util.combine_viewport_geometries(viewports)
    url = str(rospy.get_param('~url', DEFAULT_URL))
    field_of_view = float(rospy.get_param('~fov', DEFAULT_FOV))
    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'))
    clock_addr = rospy.get_param('~clock_addr', 'ws://localhost:9091')
    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')
    kiosk = rospy.get_param('~kiosk', True)

    url = add_url_params(url,
                         hFov=field_of_view,
                         master=leader,
                         clockAddr=clock_addr,
                         yawOffsets=yaw_offsets,
                         rosbridgeHost=rosbridge_host,
                         rosbridgePort=rosbridge_port,
                         rosbridgeSecure=rosbridge_secure)

    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, 'panovideo server',
                         timeout)
    check_www_dependency(depend_on_webserver, rosbridge_host, rosbridge_port,
                         'rosbridge', timeout)

    x_available_or_raise(timeout)

    slug = "lg_panovideo__" + str(geometry).replace('\n', '_').replace(
        ': ', '_')
    managed_browser = ManagedAdhocBrowser(url=url,
                                          geometry=geometry,
                                          slug=slug,
                                          kiosk=kiosk)

    # set initial state
    state = ApplicationState.STOPPED
    managed_browser.set_state(state)

    make_soft_relaunch_callback(managed_browser.handle_soft_relaunch,
                                groups=['panovideo'])

    def handle_scene(scene):
        has_panovideo = has_activity(scene, 'panovideo')
        if has_panovideo:
            managed_browser.set_state(ApplicationState.VISIBLE)
        else:
            managed_browser.set_state(ApplicationState.STOPPED)

    on_new_scene(handle_scene)

    rospy.spin()
Пример #14
0
def main():
    rospy.init_node(NODE_NAME, anonymous=True)

    extensions_root = rospy.get_param('~extensions_root',
                                      '/opt/endpoint/chrome/extensions/')
    viewport_name = rospy.get_param('~viewport', None)
    rosbridge_port = rospy.get_param('~rosbridge_port', 9090)
    rosbridge_host = rospy.get_param('~rosbridge_port', 'localhost')
    depend_on_rosbridge = rospy.get_param('~depend_on_rosbridge', True)
    global_dependency_timeout = rospy.get_param('/global_dependency_timeout',
                                                15)
    hide_delay = rospy.get_param('~hide_delay', 0.5)
    destroy_delay = rospy.get_param('~destroy_delay', 2)

    if not viewport_name:
        rospy.logerr("Viewport is not set in the roslaunch file. Exiting.")
        exit(1)
    """
    Initialize adhoc browser pool
    """

    topic_name = '/browser_service/{}'.format(viewport_name)
    common_topic_name = '/browser_service/browsers'

    actors = []

    adhocbrowser_pool = AdhocBrowserPool(viewport_name=viewport_name,
                                         extensions_root=extensions_root,
                                         hide_delay=hide_delay,
                                         destroy_delay=destroy_delay)

    make_soft_relaunch_callback(adhocbrowser_pool.handle_soft_relaunch,
                                groups=["media"])

    browser_service_sub = rospy.Subscriber(
        topic_name, AdhocBrowsers, adhocbrowser_pool.handle_ros_message)

    actors.append(browser_service_sub)
    """
    Initialize director => browser pool bridge that translates director GenericMessage to AdhocBrowsers.msg
    """

    adhocbrowser_viewport_publisher = rospy.Publisher(topic_name,
                                                      AdhocBrowsers,
                                                      queue_size=3)
    actors.append(adhocbrowser_viewport_publisher)

    adhocbrowser_aggregate_topic_publisher = rospy.Publisher(common_topic_name,
                                                             AdhocBrowsers,
                                                             queue_size=3)
    actors.append(adhocbrowser_aggregate_topic_publisher)

    adhocbrowser_director_bridge = AdhocBrowserDirectorBridge(
        adhocbrowser_aggregate_topic_publisher,
        adhocbrowser_viewport_publisher, viewport_name)

    director_scene_sub = rospy.Subscriber(
        '/director/scene', GenericMessage,
        adhocbrowser_director_bridge.translate_director)
    actors.append(director_scene_sub)
    director_ready_sub = rospy.Subscriber('/director/ready', Ready,
                                          adhocbrowser_pool.unhide_browsers)
    actors.append(director_ready_sub)

    rospy.wait_for_service('/readiness_node/ready', 15)
    rospy.wait_for_service('/lg_offliner/status', 15)
    wait_for_pub_sub_connections(actors)

    handle_initial_state(adhocbrowser_director_bridge.translate_director)
    """
    Initialize overlay hiding listener
    """
    def getBrowserIds(msg):
        s = msg.data
        if '[' in s and ']' in s:
            ids = [sp for sp in re.split('\[\]\, ', s) if len(sp) > 0]
            adhocbrowser_pool.minimize_browsers(ids)
        else:
            adhocbrowser_pool.minimize_browsers([s])

    rospy.Subscriber('/director/minimize', String, getBrowserIds)
    """
    Spin FTW
    """
    rospy.spin()
Пример #15
0
def main():
    rospy.init_node('pano_viewer_server', anonymous=True)
    server_type = rospy.get_param('~server_type', 'streetview')
    location_pub = rospy.Publisher('/%s/location' % server_type,
                                   Pose2D, queue_size=1)
    panoid_pub = rospy.Publisher('/%s/panoid' % server_type,
                                 String, queue_size=1)
    pov_pub = rospy.Publisher('/%s/pov' % server_type,
                              Quaternion, queue_size=2)
    metadata_pub = rospy.Publisher('/%s/metadata' % server_type,
                                   String, queue_size=10)
    director_pub = rospy.Publisher('/director/scene', GenericMessage, queue_size=1)

    tilt_min = rospy.get_param('~tilt_min', DEFAULT_TILT_MIN)
    tilt_max = rospy.get_param('~tilt_max', DEFAULT_TILT_MAX)
    zoom_min = rospy.get_param('~zoom_min', DEFAULT_ZOOM_MIN)
    zoom_max = rospy.get_param('~zoom_max', DEFAULT_ZOOM_MAX)
    nav_sensitivity = rospy.get_param('~nav_sensitivity', DEFAULT_NAV_SENSITIVITY)
    x_threshold = rospy.get_param('~x_threshold', X_THRESHOLD)
    space_nav_interval = rospy.get_param('~space_nav_interval', DEFAULT_NAV_INTERVAL)
    nearby_class = rospy.get_param('~nearby_class', 'NearbyStreetviewPanos')
    nearby = get_nearby(nearby_class)
    inverted = str(rospy.get_param('~inverted', "false")).lower() == "true"
    nearby.invert(inverted)
    tick_rate = rospy.get_param('~tick_rate', DEFAULT_TICK_RATE)
    idle_time_until_snap = rospy.get_param('~idle_time_until_snap', DEFAULT_IDLE_TIME_UNTIL_SNAP)

    server = PanoViewerServer(location_pub, panoid_pub, pov_pub, tilt_min, tilt_max,
                              nav_sensitivity, space_nav_interval, idle_time_until_snap, x_threshold,
                              nearby, metadata_pub, zoom_max, zoom_min, tick_rate, director_pub=director_pub,
                              server_type=server_type)

    visibility_publisher = rospy.Publisher('/%s/state' % server_type, ApplicationState, queue_size=1)

    rospy.Subscriber('/%s/location' % server_type, Pose2D,
                     server.handle_location_msg)
    rospy.Subscriber('/%s/metadata' % server_type, String,
                     server.handle_metadata_msg)
    rospy.Subscriber('/%s/panoid' % server_type, String,
                     server.handle_panoid_msg)
    rospy.Subscriber('/%s/pov' % server_type, Quaternion,
                     server.handle_pov_msg)
    rospy.Subscriber('/lg_twister/twist', Twist,
                     server.handle_spacenav_msg)
    rospy.Subscriber('/%s/state' % server_type, ApplicationState,
                     server.handle_state_msg)
    rospy.Subscriber('/%s/raw_metadata' % server_type, String,
                     server.handle_raw_metadata_msg)
    rospy.Subscriber('/spacenav/joy', Joy, server.handle_joy)
    rospy.Subscriber('/%s/tilt_snappy' % server_type, Bool, server.handle_tilt_snappy)
    rospy.Service('/%s/panoid_state' % server_type, PanoIdState, server.get_panoid)
    make_soft_relaunch_callback(server.handle_soft_relaunch, groups=['streetview'])

    # This will translate director messages into /<server_type>/panoid messages
    def handle_director_message(scene):
        rospy.loginfo('running handle director w/ scene: %s' % scene)
        _server_type = server_type
        if _server_type == 'streetview_old':
            _server_type = 'streetview'
        has_asset = has_activity(scene, _server_type)
        has_no_activity = has_activity(scene, 'no_activity')
        if has_no_activity:
            rospy.loginfo('ignoring scene due to no_activity')
            return
        if not has_asset:
            rospy.loginfo('hiding self')
            visibility_publisher.publish(ApplicationState(state='HIDDEN'))
            return
        if scene.get('slug', '') == 'auto_generated_sv_scene':
            rospy.loginfo("Ignoring my own generated message")
            asset = get_activity_config_from_activity(scene, _server_type)
            panoid = asset.get('panoid', '')
            rospy.logerr("length of panoid is %s server type %s" % (len(panoid), server_type))
            rospy.logerr("panoid is %s" % panoid)
            if server_type == 'streetview' and (panoid[0:2] != 'F:' and len(panoid) < 60):
                visibility_publisher.publish(ApplicationState(state='VISIBLE'))
                rospy.logerr("publishing visible for {}".format(server_type))
                return
            elif server_type == 'streetview_old' and (panoid[0:2] == 'F:' or len(panoid) >= 60):
                rospy.logerr("publishing visible for {}".format(server_type))
                visibility_publisher.publish(ApplicationState(state='VISIBLE'))
                return
            elif server_type == 'panoviewer' or server_type == 'panovideo':
                visibility_publisher.publish(ApplicationState(state='VISIBLE'))
                return
            visibility_publisher.publish(ApplicationState(state='HIDDEN'))
            return

        if server_type == 'streetview' or server_type == 'streetview_old':
            asset = get_activity_config_from_activity(scene, server_type)
            panoid = asset.get('panoid', '')
            if server_type == 'streetview' and panoid[0:2] == 'F:':
                rospy.logerr("leaving early for {}".format(server_type))
                return
            elif server_type == 'streetview_old' and panoid[0:2] != 'F':
                rospy.logerr("leaving early for {}".format(server_type))
                return
        else:
            panoid = scene['windows'][0]['assets'][0]

        visibility_publisher.publish(ApplicationState(state='VISIBLE'))

        pov = server.pov
        try:
            pov.x = float(asset['tilt'])
        except:
            pov.x = 0
        try:
            pov.z = float(asset['heading'])
            # we don't want to flip the auto generated ones, or the non_inverted
            if scene.get('slug', '') != 'auto_generated_sv_scene' and inverted:
                pov.z = (pov.z + 180) % 360
        except:
            pov.z = 0
        pov.w = zoom_max

        server.pub_panoid(panoid, pov=pov)

    def initial_state_handler(uscs_msg):
        try:
            rospy.loginfo("about to load json: %s" % uscs_msg.message)
            scene = json.loads(uscs_msg.message)
        except:
            return
        handle_director_message(scene)

    on_new_scene(handle_director_message)
    handle_initial_state(initial_state_handler)

    rospy.spin()