Esempio n. 1
0
def export_sign(gltf: GLTF, name: str, sign: Sign) -> int:
    texture = sign.get_name_texture()
    # x = -0.2
    CM = 0.01
    PAPER_WIDTH, PAPER_HEIGHT = 8.5 * CM, 15.5 * CM
    PAPER_THICK = 0.01

    BASE_SIGN = 5 * CM
    WIDTH_SIGN = 1.1 * CM

    y = -1.5 * PAPER_HEIGHT  # XXX not sure why this is negative
    y = BASE_SIGN
    x = -PAPER_WIDTH / 2

    fn = get_texture_file(texture)

    material_index = make_material(gltf, doubleSided=False, baseColorFactor=[1, 1, 1, 1.0], fn=fn)
    mi = get_square()
    mesh_index = add_polygon(
        gltf,
        name + "-mesh",
        vertices=mi.vertices,
        texture=mi.textures,
        colors=mi.color,
        normals=mi.normals,
        material=material_index,
    )
    sign_node = Node(mesh=mesh_index)
    sign_node_index = add_node(gltf, sign_node)

    fn = get_texture_file("wood")
    material_index_white = make_material(gltf, doubleSided=False, baseColorFactor=[0.5, 0.5, 0.5, 1], fn=fn)
    back_mesh_index = add_polygon(
        gltf,
        name + "-mesh",
        vertices=mi.vertices,
        texture=mi.textures,
        colors=mi.color,
        normals=mi.normals,
        material=material_index_white,
    )
    back_rot = SE3_from_rotation_translation(roty(np.pi), np.array([0, 0, 0]))

    back_node = Node(matrix=gm(back_rot), mesh=back_mesh_index)
    back_node_index = add_node(gltf, back_node)

    scale = np.diag([PAPER_WIDTH, PAPER_HEIGHT, PAPER_WIDTH, 1])
    rot = SE3_from_rotation_translation(
        rotz(np.pi / 2) @ rotx(np.pi / 2) @ rotz(np.pi), np.array([0, 0, 0.8 * PAPER_HEIGHT])
    )
    M = rot @ scale

    node = Node(matrix=gm(M), children=[sign_node_index, back_node_index])
    return add_node(gltf, node)
Esempio n. 2
0
    def __init__(self, tag_id, family, size):
        self.tag_id = tag_id
        self.family = family
        self.size = size

        texture = 'tag%s_%05d.png' % (family.replace('h', '_'), tag_id)
        try:
            from duckietown_world.world_duckietown.map_loading import get_texture_file
            self.fn = get_texture_file(texture)
        except KeyError:
            msg = 'Cannot find april tag image for %s' % texture
            logger.warning(msg)
            self.fn = None
Esempio n. 3
0
    def __init__(self, tag_id, family, size):
        self.tag_id = tag_id
        self.family = family
        self.size = size
        f = family.replace("h", "_")
        texture = f"tag{f}_{tag_id:05d}.png"
        try:
            from duckietown_world.world_duckietown.map_loading import get_texture_file

            self.fn = get_texture_file(texture)
        except KeyError:
            msg = f"Cannot find april tag image for {texture}"
            logger.warning(msg)
            self.fn = None
Esempio n. 4
0
    def __init__(self, kind, drivable, **kwargs):
        PlacedObject.__init__(self, **kwargs)
        self.kind = kind
        self.drivable = drivable

        from duckietown_world.world_duckietown.map_loading import get_texture_file

        try:
            self.fn = get_texture_file(kind)
        except KeyError:
            msg = 'Cannot find texture for %s' % kind
            logger.warning(msg)

            self.fn = None
Esempio n. 5
0
    def __init__(self, kind, drivable, **kwargs):
        # noinspection PyArgumentList
        PlacedObject.__init__(self, **kwargs)
        self.kind = kind
        self.drivable = drivable

        from duckietown_world.world_duckietown.map_loading import get_texture_file

        try:
            self.fn = get_texture_file(kind)
        except KeyError as e:
            msg = f"Cannot find texture for tile of type {kind}"
            logger.warning(msg, e=e)

            self.fn = None
        # if kind in ['asphalt']:
        if not "slots" in self.children:
            slots = get_tile_slots()
            self.set_object("slots", slots, ground_truth=SE2Transform.identity())
Esempio n. 6
0
    def __init__(self, kind, drivable, **kwargs):
        PlacedObject.__init__(self, **kwargs)
        self.kind = kind
        self.drivable = drivable

        from duckietown_world.world_duckietown.map_loading import get_texture_file

        try:
            self.fn = get_texture_file(kind)
        except KeyError:
            msg = 'Cannot find texture for %s' % kind
            logger.warning(msg)

            self.fn = None
        # if kind in ['asphalt']:
        if not 'slots' in self.children:
            slots = get_tile_slots()
            self.set_object('slots',
                            slots,
                            ground_truth=SE2Transform.identity())