perception
The Perception system breaks down the environment into features that can be re-assembled as concepts.
FeatureNodeType = TypeVar('FeatureNodeType', bound=FeatureNode)
module-attribute
FeatureType = TypeVar('FeatureType')
module-attribute
PerceptionData = VisionData | Settled | Feature[Any]
module-attribute
PerceptionEvent = Event[PerceptionData]
module-attribute
cache_registry = defaultdict(WeakValueDictionary)
module-attribute
fe_list = []
module-attribute
AreaFeature
dataclass
Bases: Feature[FeatureNodeType]
Source code in roc/perception.py
160 161 162 163 164 165 166 167 168 169 170 |
|
points
instance-attribute
size
instance-attribute
type
instance-attribute
__init__(*, feature_name, origin_id, type, points, size)
get_points()
Source code in roc/perception.py
166 167 |
|
node_hash()
Source code in roc/perception.py
169 170 |
|
Detail
Bases: Edge
Source code in roc/perception.py
101 102 |
|
allowed_connections = [('FeatureGroup', 'FeatureNode')]
class-attribute
instance-attribute
Direction
Bases: str
, Enum
Source code in roc/perception.py
87 88 89 90 91 92 93 94 95 96 97 98 |
|
down = 'DOWN'
class-attribute
instance-attribute
down_left = 'DOWN_LEFT'
class-attribute
instance-attribute
down_right = 'DOWN_RIGHT'
class-attribute
instance-attribute
left = 'LEFT'
class-attribute
instance-attribute
right = 'RIGHT'
class-attribute
instance-attribute
up = 'UP'
class-attribute
instance-attribute
up_left = 'UP_LEFT'
class-attribute
instance-attribute
up_right = 'UP_RIGHT'
class-attribute
instance-attribute
__str__()
Source code in roc/perception.py
97 98 |
|
Feature
dataclass
Bases: ABC
, Generic[FeatureNodeType]
Source code in roc/perception.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
feature_name
instance-attribute
origin_id
instance-attribute
__init__(*, feature_name, origin_id)
get_points()
abstractmethod
Source code in roc/perception.py
147 148 |
|
node_hash()
abstractmethod
Source code in roc/perception.py
156 157 |
|
to_nodes()
Source code in roc/perception.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
FeatureExtractor
Bases: Perception
, Generic[FeatureType]
, ABC
Source code in roc/perception.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
__init__()
Source code in roc/perception.py
214 215 216 |
|
do_perception(e)
Source code in roc/perception.py
218 219 220 221 222 223 |
|
get_feature(e)
abstractmethod
Source code in roc/perception.py
228 229 |
|
list()
classmethod
Source code in roc/perception.py
231 232 233 234 235 236 237 238 239 240 |
|
settled()
Source code in roc/perception.py
225 226 |
|
FeatureNode
Bases: Node
Source code in roc/perception.py
105 106 107 108 109 110 111 112 113 114 115 116 |
|
attr_strs
abstractmethod
property
__hash__()
Source code in roc/perception.py
106 107 108 109 |
|
__str__()
Source code in roc/perception.py
111 112 |
|
HashingNoneFeature
Bases: Exception
Source code in roc/perception.py
243 244 |
|
Perception
Bases: Component
, ABC
The abstract class for Perception components. Handles perception bus connections and corresponding clean-up.
Source code in roc/perception.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
bus = EventBus[PerceptionData]('perception')
class-attribute
instance-attribute
pb_conn = self.connect_bus(Perception.bus)
instance-attribute
__init__()
Source code in roc/perception.py
196 197 198 199 |
|
do_perception(e)
abstractmethod
Source code in roc/perception.py
201 202 |
|
init()
classmethod
Source code in roc/perception.py
204 205 206 207 |
|
PointFeature
dataclass
Bases: Feature[FeatureNodeType]
Source code in roc/perception.py
173 174 175 176 177 178 179 180 181 182 |
|
point
instance-attribute
type
instance-attribute
__init__(*, feature_name, origin_id, type, point)
get_points()
Source code in roc/perception.py
178 179 |
|
node_hash()
Source code in roc/perception.py
181 182 |
|
Settled
Source code in roc/perception.py
83 84 |
|
VisionData
Vision data received from the environment.
Source code in roc/perception.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
chars = chars
instance-attribute
colors = colors
instance-attribute
glyphs = glyphs
instance-attribute
__init__(glyphs, chars, colors)
Source code in roc/perception.py
28 29 30 31 32 33 34 35 36 |
|
for_test(test_data)
staticmethod
Creates VisionData for a test case, using a static 2D list of values to create all aspects of the VisionData
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_data
|
list[list[int]]
|
The test data to convert into VisionData |
required |
Returns:
Name | Type | Description |
---|---|---|
VisionData |
VisionData
|
The created VisionData |
Source code in roc/perception.py
64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
from_dict(d)
staticmethod
Creates VisionData from an arbitrary dictionary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d
|
dict[str, Any]
|
The dictionary to create VisionData from. Must |
required |
Returns:
Name | Type | Description |
---|---|---|
VisionData |
VisionData
|
The newly created vision data. |
Source code in roc/perception.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|