コード例 #1
0
def create_homography_calibrator_launch(filename):
    """
    Creates launch file for homography calibrators
    """
    template_name = 'homography_calibrator_launch.xml'
    machine_file = faa_utilities.file_tools.machine_launch_file
    params_file = faa_utilities.file_tools.homography_calibrator_params_file

    # Get list of pairs (namespace, rectified images)
    image_rect_list = faa_introspection.find_camera_image_topics(transport='image_rect')
    launch_list = []
    for topic in image_rect_list:
        print(topic)
        topic_split = topic.split('/')
        namespace = '/'.join(topic_split[:4])
        launch_list.append((namespace,topic))

    # Create xml launch file
    jinja2_env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
    template = jinja2_env.get_template(template_name)
    xml_str = template.render(
            machine_file=machine_file,
            params_file=params_file,
            launch_list=launch_list
            )
    with open(filename,'w') as f:
        f.write(xml_str)
コード例 #2
0
def create_zoom_tool_launch(filename):
    """
    Creates launch file for zoom tool nodes.
    """
    template_name = 'zoom_tool_launch.xml'
    machine_file = faa_utilities.file_tools.machine_launch_file
    params_file = faa_utilities.file_tools.zoom_tool_params_file
    camera_assignment = faa_utilities.file_tools.read_camera_assignment()

    # Create launch list for zoom tools (namespace, topic, computer)
    image_topics = faa_introspection.find_camera_image_topics(transport='image_raw')
    launch_list = []
    for topic in image_topics:
        topic_split = topic.split('/')
        namespace = '/'.join(topic_split[:4])
        camera = topic_split[2]
        computer = camera_assignment[camera]['computer']
        launch_list.append((namespace,topic,computer))

    # Create xml launch file
    jinja2_env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
    template = jinja2_env.get_template(template_name)
    xml_str = template.render(
            machine_file=machine_file,
            params_file=params_file,
            launch_list=launch_list
            )
    with open(filename,'w') as f:
        f.write(xml_str)
コード例 #3
0
def create_zoom_tool_launch(filename):
    """
    Creates launch file for zoom tool nodes.
    """
    template_name = 'zoom_tool_launch.xml'
    machine_file = faa_utilities.file_tools.machine_launch_file
    params_file = faa_utilities.file_tools.zoom_tool_params_file
    camera_assignment = faa_utilities.file_tools.read_camera_assignment()

    # Create launch list for zoom tools (namespace, topic, computer)
    image_topics = faa_introspection.find_camera_image_topics(
        transport='image_raw')
    launch_list = []
    for topic in image_topics:
        topic_split = topic.split('/')
        namespace = '/'.join(topic_split[:4])
        camera = topic_split[2]
        computer = camera_assignment[camera]['computer']
        launch_list.append((namespace, topic, computer))

    # Create xml launch file
    jinja2_env = jinja2.Environment(
        loader=jinja2.FileSystemLoader(template_dir))
    template = jinja2_env.get_template(template_name)
    xml_str = template.render(machine_file=machine_file,
                              params_file=params_file,
                              launch_list=launch_list)
    with open(filename, 'w') as f:
        f.write(xml_str)
コード例 #4
0
def create_homography_calibrator_launch(filename):
    """
    Creates launch file for homography calibrators
    """
    template_name = 'homography_calibrator_launch.xml'
    machine_file = faa_utilities.file_tools.machine_launch_file
    params_file = faa_utilities.file_tools.homography_calibrator_params_file

    # Get list of pairs (namespace, rectified images)
    image_rect_list = faa_introspection.find_camera_image_topics(
        transport='image_rect')
    launch_list = []
    for topic in image_rect_list:
        print(topic)
        topic_split = topic.split('/')
        namespace = '/'.join(topic_split[:4])
        launch_list.append((namespace, topic))

    # Create xml launch file
    jinja2_env = jinja2.Environment(
        loader=jinja2.FileSystemLoader(template_dir))
    template = jinja2_env.get_template(template_name)
    xml_str = template.render(machine_file=machine_file,
                              params_file=params_file,
                              launch_list=launch_list)
    with open(filename, 'w') as f:
        f.write(xml_str)
コード例 #5
0
def get_camera_to_image_topic(camera_list, topic_name):
    """
    Create dictionaries mapping cameras to images with the given topic name.
    """
    image_topic_list = faa_introspection.find_camera_image_topics(transport=topic_name)
    camera_to_image_topic = {}
    for camera in camera_list:
        for image_topic in image_topic_list:
            if camera in image_topic.split('/'):
                camera_to_image_topic[camera] = image_topic
    return camera_to_image_topic
コード例 #6
0
def get_camera_to_image_topic(camera_list, topic_name):
    """
    Create dictionaries mapping cameras to images with the given topic name.
    """
    image_topic_list = faa_introspection.find_camera_image_topics(
        transport=topic_name)
    camera_to_image_topic = {}
    for camera in camera_list:
        for image_topic in image_topic_list:
            if camera in image_topic.split('/'):
                camera_to_image_topic[camera] = image_topic
    return camera_to_image_topic
コード例 #7
0
def create_transform_2d_calibrator_launch(filename):
    """
    Creates launch file for transform_2d_calibrator nodes.
    """
    template_name = 'transform_2d_calibrator_launch.xml'
    machine_file = faa_utilities.file_tools.machine_launch_file
    params_file = faa_utilities.file_tools.transform_2d_calibrator_params_file

    # Get region and camera pair information
    region_dict = faa_utilities.file_tools.read_tracking_2d_regions()
    camera_pairs_dict = faa_utilities.file_tools.read_tracking_2d_camera_pairs(
    )

    # Get dictionary of camera to rectified images
    image_rect_list = faa_introspection.find_camera_image_topics(
        transport='image_rect')
    camera_to_image_rect = {}
    for camera_list in region_dict.values():
        for camera in camera_list:
            for image_rect in image_rect_list:
                if camera in image_rect.split('/'):
                    camera_to_image_rect[camera] = image_rect

    # Create launch list (namespace, topic0, topic1)
    launch_list = []
    for pairs_list in camera_pairs_dict.values():
        for camera0, camera1 in pairs_list:
            try:
                namespace = '/{0}_{1}'.format(camera0, camera1)
                topic0 = camera_to_image_rect[camera0]
                topic1 = camera_to_image_rect[camera1]
                launch_list.append((namespace, topic0, topic1))
            except KeyError:
                pass

    # Create xml launch file
    jinja2_env = jinja2.Environment(
        loader=jinja2.FileSystemLoader(template_dir))
    template = jinja2_env.get_template(template_name)
    xml_str = template.render(machine_file=machine_file,
                              params_file=params_file,
                              launch_list=launch_list)
    with open(filename, 'w') as f:
        f.write(xml_str)
コード例 #8
0
def create_transform_2d_calibrator_launch(filename):
    """
    Creates launch file for transform_2d_calibrator nodes.
    """
    template_name = 'transform_2d_calibrator_launch.xml'
    machine_file = faa_utilities.file_tools.machine_launch_file
    params_file = faa_utilities.file_tools.transform_2d_calibrator_params_file

    # Get region and camera pair information
    region_dict = faa_utilities.file_tools.read_tracking_2d_regions()
    camera_pairs_dict = faa_utilities.file_tools.read_tracking_2d_camera_pairs()

    # Get dictionary of camera to rectified images
    image_rect_list = faa_introspection.find_camera_image_topics(transport='image_rect')
    camera_to_image_rect = {}
    for camera_list in region_dict.values():
        for camera in camera_list:
            for image_rect in image_rect_list:
                if camera in image_rect.split('/'):
                    camera_to_image_rect[camera] = image_rect

    # Create launch list (namespace, topic0, topic1)
    launch_list = []
    for pairs_list in camera_pairs_dict.values():
        for camera0, camera1 in pairs_list:
            try:
                namespace = '/{0}_{1}'.format(camera0, camera1)
                topic0 = camera_to_image_rect[camera0]
                topic1 = camera_to_image_rect[camera1]
                launch_list.append((namespace, topic0, topic1))
            except KeyError:
                pass

    # Create xml launch file
    jinja2_env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
    template = jinja2_env.get_template(template_name)
    xml_str = template.render(
            machine_file=machine_file,
            params_file=params_file,
            launch_list=launch_list
            )
    with open(filename,'w') as f:
        f.write(xml_str)
コード例 #9
0
def create_three_point_tracker_launch(filename):
    """
    Creates luanch file for three point tracker nodes based on the camera_lists
    in the regions.yaml.
    """
    template_name = 'three_point_tracker_launch.xml'
    machine_file = faa_utilities.file_tools.machine_launch_file
    regions_dict = faa_utilities.file_tools.read_tracking_2d_regions()
    # ------------------------------------------------------------------------------------
    # Old style - before frame drop correctors
    #image_topic_list = faa_introspection.find_camera_image_topics(transport='image_rect')
    # ------------------------------------------------------------------------------------
    image_topic_list = faa_introspection.find_camera_image_topics(
        transport='seq_and_image_corr')

    # Create launch dictionary keyed by region.
    launch_dict = {}
    for region, camera_list in regions_dict.iteritems():
        region_launch_list = []
        for camera in camera_list:
            for rect_topic in image_topic_list:
                rect_topic_split = rect_topic.split('/')
                if camera in rect_topic_split:
                    camera_topic = '/'.join(rect_topic_split[:-1])
                    machine = rect_topic_split[1]
                    region_launch_list.append(
                        (camera_topic, rect_topic, machine))
        launch_dict[region] = region_launch_list

    # Create xml launch file
    jinja2_env = jinja2.Environment(
        loader=jinja2.FileSystemLoader(template_dir))
    template = jinja2_env.get_template(template_name)
    xml_str = template.render(
        machine_file=machine_file,
        launch_dict=launch_dict,
    )
    with open(filename, 'w') as f:
        f.write(xml_str)
コード例 #10
0
def create_three_point_tracker_launch(filename):
    """
    Creates luanch file for three point tracker nodes based on the camera_lists
    in the regions.yaml.
    """
    template_name = 'three_point_tracker_launch.xml'
    machine_file = faa_utilities.file_tools.machine_launch_file
    regions_dict = faa_utilities.file_tools.read_tracking_2d_regions()
    # ------------------------------------------------------------------------------------
    # Old style - before frame drop correctors
    #image_topic_list = faa_introspection.find_camera_image_topics(transport='image_rect')
    # ------------------------------------------------------------------------------------
    image_topic_list = faa_introspection.find_camera_image_topics(transport='seq_and_image_corr')

    # Create launch dictionary keyed by region.
    launch_dict = {}
    for region, camera_list in regions_dict.iteritems():
        region_launch_list = []
        for camera in camera_list:
            for rect_topic in image_topic_list:
                rect_topic_split = rect_topic.split('/')
                if camera in rect_topic_split:
                    camera_topic = '/'.join(rect_topic_split[:-1])
                    machine = rect_topic_split[1]
                    region_launch_list.append((camera_topic, rect_topic, machine))
        launch_dict[region] = region_launch_list

    # Create xml launch file
    jinja2_env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
    template = jinja2_env.get_template(template_name)
    xml_str = template.render(
            machine_file=machine_file,
            launch_dict=launch_dict,
            )
    with open(filename,'w') as f:
        f.write(xml_str)