Skip to content

Commit

Permalink
add citizens
Browse files Browse the repository at this point in the history
  • Loading branch information
light5551 committed Dec 30, 2020
1 parent a2143b0 commit 83d112d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/duckietown_world/data/gd2/udem1/citizens.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
citizens:
map_1/duckie1:
color: yellow
7 changes: 6 additions & 1 deletion src/duckietown_world/data/gd2/udem1/frames.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ frames:
map_1/watchtower1/watchtower2:
relative_to: map_1/watchtower1
pose:
y: 0.9
y: 0.9
map_1/duckie1:
relative_to: ~
pose:
x: 1
y: 1
3 changes: 2 additions & 1 deletion src/duckietown_world/data/gd2/udem1/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ main:
tile_maps: !include tile_maps.yaml
tiles: !include tiles.yaml
watchtowers: !include watchtowers.yaml
groups: !include groups.yaml
groups: !include groups.yaml
citizens: !include citizens.yaml
1 change: 1 addition & 0 deletions src/duckietown_world/structure_2/duckietown_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class DuckietownMap(IBaseMap, ABC):
'tiles': LayerTiles,
'watchtowers': LayerWatchtowers,
'groups': LayerGroups,
'citizens': LayerCitizens
})

def __getattr__(self, item):
Expand Down
8 changes: 7 additions & 1 deletion src/duckietown_world/structure_2/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pprint import pformat

from .base_map import IBaseMap
from .objects import _Object, _Frame, _Tile, _Group, _TileMap, _Watchtower
from .objects import _Object, _Frame, _Tile, _Group, _TileMap, _Watchtower, _Citizen


class AbstractLayer(metaclass=ABCMeta):
Expand Down Expand Up @@ -81,3 +81,9 @@ class LayerGroups(AbstractLayer, ABC):
@classmethod
def item_type(cls) -> type:
return _Group


class LayerCitizens(AbstractLayer, ABC):
@classmethod
def item_type(cls) -> type:
return _Citizen
11 changes: 10 additions & 1 deletion src/duckietown_world/structure_2/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


__all__ = ['_Object', '_Pose', '_Frame', '_TileMap', '_Tile', '_Watchtower', '_Group',
'ConstructedObject', 'Watchtower']
'ConstructedObject', 'Watchtower', '_Citizen']


@dataclass
Expand Down Expand Up @@ -57,6 +57,15 @@ class _Tile(_Object):
orientation: Optional[str] = None


@dataclass
class _Citizen(_Object):
color: str = 'yellow'

def __init__(self, color='yellow', dm=None):
super().__init__(dm)
self.color = color


@dataclass
class _Watchtower(_Object):
configuration: str = 'WT18'
Expand Down
2 changes: 2 additions & 0 deletions src/duckietown_world_tests/layers_structure_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def layers_map():
print("------------------------------------------------------")
print(dm.watchtowers)
print("------------------------------------------------------")
print(dm.citizens)



if __name__ == "__main__":
Expand Down

0 comments on commit 83d112d

Please sign in to comment.