Пример #1
0
def get_camera_info_for_robot(robot_name: str) -> CameraInfo:
    """
        Returns a CameraInfo object for the given robot.
        This is in a good format to pass to PinholeCameraModel:
            self.pcm = PinholeCameraModel()
            self.pcm.fromCameraInfo(self.ci)
        The fields are simply lists (not array or matrix).
        Raises:
            NoCameraInfoAvailable  if no info available
            InvalidCameraInfo   if the info exists but is invalid
    """

    if robot_name == dtu.DuckietownConstants.ROBOT_NAME_FOR_TESTS:
        calib_data = dtu.yaml_load(default_camera_info)
        fn = None
    else:
        # find the file
        fn = get_camera_info_config_file(robot_name)

        # load the YAML

        calib_data = dtu.yaml_load_file(fn, plain_yaml=True)

    # convert the YAML
    try:
        camera_info = camera_info_from_yaml(calib_data)
    except InvalidCameraInfo as e:
        msg = f"Invalid data in file {fn}"
        raise InvalidCameraInfo(msg) from e

    check_camera_info_sane_for_DB17(camera_info)

    return camera_info
Пример #2
0
def get_homography_for_robot(robot_name: str) -> np.ndarray:
    dtu.check_isinstance(robot_name, str)
    # find the file

    fn = get_homography_info_config_file(robot_name)

    # load the YAML
    data = dtu.yaml_load_file(fn, plain_yaml=True)  # True means "plain"

    # convert the YAML
    homography = homography_from_yaml(data)

    return homography
Пример #3
0
def get_logs_cloud():
    cloud_file = dtu.require_resource("cloud2.yaml")

    with dtu.timeit_wall("loading DB"):
        dtu.logger.info(f"Loading cloud DB {dtu.friendly_path(cloud_file)}")
        with dtu.timeit_wall("YAML load file"):
            data = dtu.yaml_load_file(cloud_file, plain_yaml=True)

        dtu.logger.debug("Conversion")
        logs = logs_from_yaml(data)

    logs = dict(logs)
    dtu.logger.info(f"Loaded cloud DB with {len(logs)} entries.")

    return logs
Пример #4
0
def load_board_info(filename: str = None) -> dict:
    """Load calibration checkerboard info"""
    if filename is None:
        root = dru.get_ros_package_path("duckietown")
        filename = root + "/config/baseline/ground_projection/ground_projection/default.yaml"

    if not os.path.isfile(filename):
        msg = f"No such file: {filename}"
        raise dtu.DTException(msg)

    target_data = dtu.yaml_load_file(filename)
    target_info = {
        "width": target_data["board_w"],
        "height": target_data["board_h"],
        "square_size": target_data["square_size"],
        "x_offset": target_data["x_offset"],
        "y_offset": target_data["y_offset"],
        "offset": np.array([target_data["x_offset"], -target_data["y_offset"]]),
        "size": (target_data["board_w"], target_data["board_h"]),
    }
    dtu.logger.info("Loaded checkerboard parameters")
    return target_info