generated from duckietown/template-library
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from OSLL/ente
added new layers
- Loading branch information
Showing
17 changed files
with
838 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from enum import Enum | ||
from typing import Union, Iterable, Optional, Any | ||
|
||
from dt_maps.types.commons import EntityHelper, FieldPath | ||
from dt_maps.types.frames import Frame | ||
|
||
COLOR = "color" | ||
|
||
|
||
class CitizenType(Enum): | ||
YELLOW = "yellow" | ||
RED = "red" | ||
GREEN = "green" | ||
GRAY = "grey" | ||
|
||
|
||
class Citizen(EntityHelper): | ||
|
||
def _get_property_values(self, name: str) -> Optional[Iterable[Any]]: | ||
return { | ||
COLOR: [w.value for w in CitizenType] | ||
}[name] | ||
|
||
def _get_property_types(self, name: str) -> Union[type, Iterable[type]]: | ||
return { | ||
COLOR: str | ||
}[name] | ||
|
||
def _get_layer_name(self) -> str: | ||
return "citizens" | ||
|
||
def _set_property(self, name: FieldPath, types: Union[type, Iterable[type]], value: Any): | ||
# CitizenType -> str | ||
if name == COLOR and isinstance(value, CitizenType): | ||
value = value.value | ||
# --- | ||
super(Citizen, self)._set_property(name, types, value) | ||
|
||
def _get_property(self, name: FieldPath) -> Any: | ||
value = super(Citizen, self)._get_property(name) | ||
# str -> CitizenType | ||
if name == COLOR: | ||
value = CitizenType(value) | ||
# --- | ||
return value | ||
|
||
@property | ||
def frame(self) -> Frame: | ||
return Frame.create(self._map, self._key) | ||
|
||
@property | ||
def color(self) -> CitizenType: | ||
return CitizenType(self._get_property(COLOR)) | ||
|
||
@color.setter | ||
def color(self, value: Union[str, CitizenType]): | ||
self._set_property(COLOR, str, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from typing import Union, Iterable, Optional, Any | ||
|
||
from dt_maps.types.commons import EntityHelper, FieldPath | ||
from dt_maps.types.frames import Frame | ||
|
||
SIZE = "size" | ||
ID = "id" | ||
FAMILY = "family" | ||
|
||
|
||
class GroundTag(EntityHelper): | ||
|
||
def _get_property_values(self, name: str) -> Optional[Iterable[Any]]: | ||
return { | ||
SIZE: None, | ||
ID: None, | ||
FAMILY: None | ||
}[name] | ||
|
||
def _get_property_types(self, name: str) -> Union[type, Iterable[type]]: | ||
return { | ||
SIZE: float, | ||
ID: int, | ||
FAMILY: str | ||
}[name] | ||
|
||
def _get_layer_name(self) -> str: | ||
return "ground_tags" | ||
|
||
def _set_property(self, name: FieldPath, types: Union[type, Iterable[type]], value: Any): | ||
super(GroundTag, self)._set_property(name, types, value) | ||
|
||
def _get_property(self, name: FieldPath) -> Any: | ||
value = super(GroundTag, self)._get_property(name) | ||
return value | ||
|
||
@property | ||
def frame(self) -> Frame: | ||
return Frame.create(self._map, self._key) | ||
|
||
@property | ||
def size(self) -> float: | ||
return self._get_property(SIZE) | ||
|
||
@property | ||
def id(self) -> int: | ||
return self._get_property(ID) | ||
|
||
@property | ||
def family(self) -> str: | ||
return self._get_property(FAMILY) | ||
|
||
@size.setter | ||
def size(self, value: float): | ||
self._set_property(SIZE, float, value) | ||
|
||
@id.setter | ||
def id(self, value: int): | ||
self._set_property(ID, int, value) | ||
|
||
@family.setter | ||
def family(self, value: str): | ||
self._set_property(FAMILY, str, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from enum import Enum | ||
from typing import Union, Iterable, Optional, Any | ||
|
||
from dt_maps.types.commons import EntityHelper, FieldPath | ||
from dt_maps.types.frames import Frame | ||
|
||
TYPE = "type" | ||
ID = "id" | ||
FAMILY = "family" | ||
|
||
|
||
class TrafficSignType(Enum): | ||
FOUR_WAY_INTERSECT = "four_way_intersect" | ||
DO_NOT_ENTER = "do_not_enter" | ||
DUCK_CROSSING = "duck_crossing" | ||
LEFT_T_INTERSECT = "left_t_intersect" | ||
NO_LEFT_TURN = "no_left_turn" | ||
NO_RIGHT_TURN = "no_right_turn" | ||
ONEWAY_LEFT = "oneway_left" | ||
ONEWAY_RIGHT = "oneway_right" | ||
PARKING = "parking" | ||
PEDESTRIAN = "pedestrian" | ||
RIGHT_T_INTERSECT = "right_t_intersect" | ||
STOP = "stop" | ||
T_INTERSECTION = "t_intersection" | ||
T_LIGHT_AHEAD = "t_light_ahead" | ||
YIELD = "yield" | ||
|
||
|
||
class TrafficSign(EntityHelper): | ||
|
||
def _get_property_values(self, name: str) -> Optional[Iterable[Any]]: | ||
return { | ||
TYPE: [w.value for w in TrafficSignType], | ||
ID: None, | ||
FAMILY: None | ||
}[name] | ||
|
||
def _get_property_types(self, name: str) -> Union[type, Iterable[type]]: | ||
return { | ||
TYPE: str, | ||
ID: int, | ||
FAMILY: str | ||
}[name] | ||
|
||
def _get_layer_name(self) -> str: | ||
return "traffic_signs" | ||
|
||
def _set_property(self, name: FieldPath, types: Union[type, Iterable[type]], value: Any): | ||
# TrafficSignType -> str | ||
if name == TYPE and isinstance(value, TrafficSignType): | ||
value = value.value | ||
# --- | ||
super(TrafficSign, self)._set_property(name, types, value) | ||
|
||
def _get_property(self, name: FieldPath) -> Any: | ||
value = super(TrafficSign, self)._get_property(name) | ||
# str -> TrafficSignType | ||
if name == TYPE: | ||
value = TrafficSignType(value) | ||
# --- | ||
return value | ||
|
||
@property | ||
def frame(self) -> Frame: | ||
return Frame.create(self._map, self._key) | ||
|
||
@property | ||
def type(self) -> TrafficSignType: | ||
return TrafficSignType(self._get_property(TYPE)) | ||
|
||
@property | ||
def id(self) -> int: | ||
return self._get_property(ID) | ||
|
||
@property | ||
def family(self) -> str: | ||
return self._get_property(FAMILY) | ||
|
||
@type.setter | ||
def type(self, value: Union[str, TrafficSignType]): | ||
self._set_property(TYPE, str, value) | ||
|
||
@id.setter | ||
def id(self, value: int): | ||
self._set_property(ID, int, value) | ||
|
||
@family.setter | ||
def family(self, value: str): | ||
self._set_property(FAMILY, str, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
from enum import Enum | ||
from typing import Union, Iterable, Optional, Any | ||
|
||
from dt_maps.types.commons import EntityHelper, FieldPath | ||
from dt_maps.types.frames import Frame | ||
|
||
CONFIGURATION = "configuration" | ||
ID = "id" | ||
COLOR = "color" | ||
|
||
|
||
class ColorType(Enum): | ||
BLUE = "blue" | ||
RED = "red" | ||
GREEN = "green" | ||
GRAY = "grey" | ||
|
||
|
||
class VehicleType(Enum): | ||
# duckie-bot | ||
DB18: str = "DB18" | ||
DB19: str = "DB19" | ||
DB20: str = "DB20" | ||
DB21M: str = "DB21M" | ||
DB21J: str = "DB21J" | ||
DB21R: str = "DB21R" | ||
# duckie-drone | ||
DD18: str = "DD18" | ||
DD21: str = "DD21" | ||
|
||
|
||
class Vehicle(EntityHelper): | ||
|
||
def _get_property_values(self, name: str) -> Optional[Iterable[Any]]: | ||
return { | ||
CONFIGURATION: [w.value for w in VehicleType], | ||
ID: None, | ||
COLOR: [w.value for w in ColorType] | ||
}[name] | ||
|
||
def _get_property_types(self, name: str) -> Union[type, Iterable[type]]: | ||
return { | ||
CONFIGURATION: str, | ||
ID: (type(None), str), | ||
COLOR: str | ||
}[name] | ||
|
||
def _get_layer_name(self) -> str: | ||
return "vehicles" | ||
|
||
def _set_property(self, name: FieldPath, types: Union[type, Iterable[type]], value: Any): | ||
# VehicleType -> str or ColorType -> str | ||
if (name == CONFIGURATION and isinstance(value, VehicleType)) or \ | ||
(name == COLOR and isinstance(value, ColorType)): | ||
value = value.value | ||
# --- | ||
super(Vehicle, self)._set_property(name, types, value) | ||
|
||
def _get_property(self, name: FieldPath) -> Any: | ||
value = super(Vehicle, self)._get_property(name) | ||
# str -> VehicleType | ||
if name == CONFIGURATION: | ||
value = VehicleType(value) | ||
# str -> ColorType | ||
if name == COLOR: | ||
value = ColorType(value) | ||
# --- | ||
return value | ||
|
||
@property | ||
def frame(self) -> Frame: | ||
return Frame.create(self._map, self._key) | ||
|
||
@property | ||
def configuration(self) -> VehicleType: | ||
return VehicleType(self._get_property(CONFIGURATION)) | ||
|
||
@property | ||
def id(self) -> Optional[str]: | ||
return self._get_property(ID) | ||
|
||
@property | ||
def color(self) -> ColorType: | ||
return ColorType(self._get_property(COLOR)) | ||
|
||
@configuration.setter | ||
def configuration(self, value: Union[str, VehicleType]): | ||
self._set_property(CONFIGURATION, str, value) | ||
|
||
@id.setter | ||
def id(self, value: Optional[str]): | ||
self._set_property(ID, (type(None), str), value) | ||
|
||
@color.setter | ||
def color(self, value: Union[str, ColorType]): | ||
self._set_property(COLOR, str, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.