Example #1
0
    def draw_svg(self, drawing, g):
        texture = self.get_name_texture()
        L, W = 0.2, 0.5
        try:
            from .map_loading import get_texture_file
            fn = get_texture_file(texture)
        except KeyError:
            msg = 'Cannot find texture for %s' % texture
            logger.warning(msg)

            c = drawing.rect(
                insert=(-L / 2, -W / 2),
                fill="white",
                size=(
                    L,
                    W,
                ),
                stroke_width="0.01",
                stroke="black",
            )
            g.add(c)

        else:
            texture = open(fn, 'rb').read()
            from duckietown_world.world_duckietown.tile import data_encoded_for_src
            href = data_encoded_for_src(texture, 'image/jpeg')

            img = drawing.image(
                href=href,
                size=(L, W),
                insert=(-L / 2, -W / 2),
                style='transform: rotate(90deg) scaleX(-1)  rotate(-90deg) ')
            g.add(img)
Example #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
Example #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
Example #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
Example #5
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())
Example #6
0
    def draw_svg(self, drawing, g):
        texture = self.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
        try:
            from .map_loading import get_texture_file
            fn = get_texture_file(texture)
        except KeyError:
            msg = 'Cannot find texture for %s' % texture
            logger.warning(msg)

            c = drawing.rect(
                insert=(x, y),
                fill="white",
                size=(
                    PAPER_WIDTH,
                    PAPER_HEIGHT,
                ),
                stroke_width="0.01",
                stroke="black",
            )
            g.add(c)

        else:
            texture = open(fn, 'rb').read()
            from duckietown_world.world_duckietown.tile import data_encoded_for_src

            href = data_encoded_for_src(texture, mime_from_fn(fn))

            img = drawing.image(
                href=href,
                size=(PAPER_WIDTH, PAPER_HEIGHT),
                insert=(x, y),
                stroke_width=0.001,
                stroke='black',
                style=
                'transform: rotate(90deg) rotate(90deg) scaleX(-1)  rotate(-90deg);'
                'border: solid 1px black ')
            img.attribs['class'] = 'sign-paper'
            g.add(img)

        c = drawing.rect(insert=(-BASE_SIGN / 2, -BASE_SIGN / 2),
                         fill="lightgreen",
                         stroke_width=0.001,
                         stroke='black',
                         size=(
                             BASE_SIGN,
                             BASE_SIGN,
                         ))
        g.add(c)
        draw_axes(drawing, g)
        alpha = 1.2
        c = drawing.rect(insert=(-WIDTH_SIGN / 2, -BASE_SIGN / 2 * alpha),
                         fill="#FFCB9C",
                         stroke_width=0.001,
                         stroke='black',
                         size=(
                             WIDTH_SIGN,
                             BASE_SIGN * alpha,
                         ))
        g.add(c)

        c = drawing.rect(insert=(+0.01 + -PAPER_THICK / 2, -PAPER_WIDTH / 2),
                         fill="white",
                         stroke_width=0.001,
                         stroke='black',
                         size=(
                             PAPER_THICK,
                             PAPER_WIDTH,
                         ))
        g.add(c)