Main
Reinforcement Learning of Concepts
ActionData = ActionRequest | TakeAction
module-attribute
PerceptionData = VisionData | Settled | Feature[Any]
module-attribute
__all__ = ['Component', 'GymComponent', 'Perception', 'PerceptionData', 'ActionData', 'Action', 'ExpMod']
module-attribute
ng = None
module-attribute
Action
Bases: Component
Component for determining which action to take.
Source code in roc/action.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
action_bus_conn = self.connect_bus(self.bus)
instance-attribute
bus = EventBus[ActionData]('action', cache_depth=10)
class-attribute
instance-attribute
__init__()
Source code in roc/action.py
33 34 35 36 |
|
action_request(e)
Source code in roc/action.py
41 42 43 44 |
|
event_filter(e)
Source code in roc/action.py
38 39 |
|
Component
Bases: ABC
An abstract component class for building pieces of ROC that will talk to each other.
Source code in roc/component.py
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
bus_conns = {}
instance-attribute
id
property
name = '<name unassigned>'
class-attribute
instance-attribute
type = '<type unassigned>'
class-attribute
instance-attribute
__del__()
Source code in roc/component.py
48 49 50 51 |
|
__init__()
Source code in roc/component.py
41 42 43 44 45 |
|
connect_bus(bus)
Create a new bus connection for the component, storing the result for later shutdown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bus
|
EventBus[T]
|
The event bus to attach to |
required |
Raises:
Type | Description |
---|---|
ValueError
|
if the bus has already been connected to by this component |
Returns:
Type | Description |
---|---|
BusConnection[T]
|
BusConnection[T]: The bus connection for listening or sending events |
Source code in roc/component.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
deregister(name, type)
staticmethod
Removes a component from the Component registry. Primarlly used for testing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the Component to deregister |
required |
type
|
str
|
The type of the Component to deregister |
required |
Source code in roc/component.py
168 169 170 171 172 173 174 175 176 177 |
|
event_filter(e)
A filter for any incoming events. By default it filters out events sent by itself, but it is especially useful for creating new filters in sub-classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
e
|
Event[Any]
|
The event to be evaluated |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the event should be sent, False if it should be dropped |
Source code in roc/component.py
75 76 77 78 79 80 81 82 83 84 85 86 |
|
get(name, type, *args, **kwargs)
classmethod
Retreives a component with the specified name from the registry and
creates a new version of it with the specified args. Used by
Config.init
and for testing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the component to get, as specified during its registration |
required |
type
|
str
|
The type of the component to get, as specified during its registration |
required |
args
|
Any
|
Fixed position arguments to pass to the Component constructor |
()
|
kwargs
|
Any
|
Keyword args to pass to the Component constructor |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
the component that was created, casted as the calling class. |
Self
|
(e.g. |
|
Self
|
|
Source code in roc/component.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
get_component_count()
staticmethod
Returns the number of currently created Components. The number goes up on init and down on del. Primarily used for testing to ensure Components are being shutdown appropriately.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The number of currently active Component instances |
Source code in roc/component.py
144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
get_loaded_components()
staticmethod
Returns the names and types of all initiated components.
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: A list of the names and types of components, as strings. |
Source code in roc/component.py
158 159 160 161 162 163 164 165 166 |
|
init()
staticmethod
Loads all components registered as auto
and perception components
in the perception_components
config field.
Source code in roc/component.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
reset()
staticmethod
Shuts down all components
Source code in roc/component.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
shutdown()
De-initializes the component, removing any bus connections and any other clean-up that needs to be performed
Source code in roc/component.py
88 89 90 91 92 93 94 95 96 97 |
|
ExpMod
Source code in roc/expmod.py
18 19 20 21 22 23 24 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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
modtype
instance-attribute
__init_subclass__()
Source code in roc/expmod.py
21 22 23 |
|
get(default=None)
classmethod
Source code in roc/expmod.py
38 39 40 41 42 43 44 45 46 47 48 49 |
|
import_file(filename, basepath='')
staticmethod
Source code in roc/expmod.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
init()
staticmethod
Source code in roc/expmod.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
register(name)
staticmethod
Source code in roc/expmod.py
25 26 27 28 29 30 31 32 33 34 35 36 |
|
set(name, modtype=None)
classmethod
Source code in roc/expmod.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
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 |
|
init(config=None)
Initializes the agent before starting the agent.
Source code in roc/__init__.py
40 41 42 43 44 45 46 47 48 49 |
|
start()
Starts the agent.
Source code in roc/__init__.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|