Environment
Package defining environment related functionality.
MultiTaskAmbient
¶
Bases: SVGAmbient
This class manages an SVG state and a collection of tasks that a user may want to interact with. It requires that a special agent the Avatar
is provided which will act as an interface between the user and the environment. For details on what a Task
is and how they are used see the MultiTaskEnvironment
class documentation or read the icua
wiki page on tasks (TODO provide a link to this).
Source code in icua\environment\multitask_ambient.py
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 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 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 241 242 243 244 245 246 247 248 249 250 |
|
__init__(avatar=None, agents=None, svg_size=None, svg_position=None, logging_path=None, **kwargs)
¶
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
avatar |
Agent
|
The users avatar. Defaults to None. |
None
|
agents |
list[Agent]
|
list of initial agents. Defaults to None. |
None
|
svg_size |
tuple[float, float]
|
size of the root SVG element, typically this should encompase the bounds of all tasks. Defaults to None, which will use the default |
None
|
svg_position |
tuple[float, float]
|
position of the root SVG element in the UI window. Defaults to None, which which will use the default |
None
|
logging_path |
str
|
path that events will be logged to. Defaults to None (see |
None
|
kwargs |
dict[str, Any]
|
Additional optional keyword arguments, see |
{}
|
Source code in icua\environment\multitask_ambient.py
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 |
|
add_task(name, path, agent_actuators=None, avatar_actuators=None, enable=False)
¶
Add a new task, this will load all required files and prepare the task but will not start the task (unless enable
is True). To start the task use enable_task
or have an agent take the EnableTask
action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the unique name of the task. |
required |
path |
str | list[str]
|
path(s) to task files. |
required |
agent_actuators |
list[Callable[[], Actuator]] | None
|
actuators with which to create agents from a schedule file, see |
None
|
avatar_actuators |
list[Callable[[], Actuator]] | None
|
actuators that will be added to the avatar upon enabling the task, see |
None
|
enable |
bool
|
whether to immediately enable the task. Defaults to False. |
False
|
Source code in icua\environment\multitask_ambient.py
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 |
|
disable_task(task_name)
¶
Manually disable a task. Tasks may otherwise be disabled via an EnableTask
action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name |
str
|
name of the task to disable. |
required |
Source code in icua\environment\multitask_ambient.py
140 141 142 143 144 145 146 147 148 149 |
|
enable_task(task_name, context=None, insert_at=-1)
¶
Manually enable a task. Tasks may otherwise be enabled via an EnableTask
action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name |
str
|
name of the task to enable. |
required |
context |
dict[str, Any]
|
context to use when enabling the task |
None
|
insert_at |
int
|
at what position in the SVG tree to insert the task element. |
-1
|
Source code in icua\environment\multitask_ambient.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
is_task_enabled(task_name)
¶
Is the given task enabled? Specially, is the task element part of the state? This will search for an element with id
equal to the name of the task.
Note that if the id
of the task element has been changed elsewherethen this will not give the expected result. This will not happen with correct use of MultiTaskAmbient
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name |
str
|
name of the task to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the task is enabled (is part of the state), False otherwise. |
Source code in icua\environment\multitask_ambient.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
rename_task(task_name, new_name)
¶
Rename a task. If the task is enabled this will alter the id
attribute of the task element (TODO).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name |
str
|
current name of the task. |
required |
new_name |
str
|
new name of the task. |
required |
Source code in icua\environment\multitask_ambient.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
MultiTaskEnvironment
¶
Bases: Environment
Environment implementation that supports "tasks". A task is a modular part of the environment which the user typically interacts with via their Avatar
. Tasks will typially have an associated agent that updates/manages the tasks state. The users avatar should also provide some means to interact with tasks. When a new task is added, this may mean the avatar gains a new actuator and will often mean that a new agent is added to the environment.
TODO a thorough explaination of what tasks are and how to define/use them!
See
MultiTaskAmbient
Source code in icua\environment\multitask_environment.py
13 14 15 16 17 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 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 |
|
ambient: MultiTaskAmbient
property
¶
Getter for the inner ambient, which is always a MultiTaskAmbient
. IMPORTANT NOTE: remote ambients are not currently supported.
Returns:
Name | Type | Description |
---|---|---|
MultiTaskAmbient |
MultiTaskAmbient
|
the ambient. |
__init__(avatar, agents=None, wait=0.01, svg_size=None, svg_position=None, logging_path=None, terminate_after=-1, **kwargs)
¶
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
avatar |
Agent
|
The users avatar. Defaults to None. |
required |
agents |
list[Agent]
|
list of initial agents. Defaults to None. |
None
|
wait |
float
|
time to wait between simulation cycles. Defaults to 0.01. |
0.01
|
svg_size |
tuple[float, float]
|
size of the root SVG element. Defaults to None (see |
None
|
svg_position |
tuple[float, float]
|
position of the root SVG element. Defaults to None (see |
None
|
logging_path |
str
|
path that events will be logged to. Defaults to None (see |
None
|
terminate_after |
float
|
time after which to terminate the simulatio. Defaults to -1 (never terminate). |
-1
|
kwargs |
dict[str, Any]
|
Additional optional keyword arguments, see |
{}
|
Source code in icua\environment\multitask_environment.py
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 |
|
add_task(name, path, agent_actuators=None, avatar_actuators=None, enable=False)
¶
Add a new task, this will load all required files and prepare the task but will not start the task (unless enable
is True). To start the task use enable_task
or have an agent take the EnableTask
action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the unique name of the task. |
required |
path |
str | list[str]
|
path(s) to task files. |
required |
agent_actuators |
list[Callable[[], Actuator]] | None
|
actuators with which to create agents from a schedule file, see |
None
|
avatar_actuators |
list[Callable[[], Actuator]] | None
|
actuators that will be added to the avatar upon enabling the task, see |
None
|
enable |
bool
|
whether to immediately enable the task. Defaults to False. |
False
|
Source code in icua\environment\multitask_environment.py
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 |
|
disable_task(task_name)
¶
Manually disable a task. Tasks may otherwise be disabled via an EnableTask
action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name |
str
|
name of the task to disable. |
required |
Source code in icua\environment\multitask_environment.py
85 86 87 88 89 90 91 |
|
enable_task(task_name, context=None, insert_at=-1)
¶
Manually enable a task. Tasks may otherwise be enabled via an EnableTask
action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name |
str
|
name of the task to enable. |
required |
context |
dict[str, Any]
|
context to use when enabling the task |
None
|
insert_at |
int
|
at what position in the SVG tree to insert the task element. |
-1
|
Source code in icua\environment\multitask_environment.py
73 74 75 76 77 78 79 80 81 82 83 |
|
rename_task(task_name, new_name)
¶
Rename a task. If the task is enabled this will alter the id
attribute of the task element (TODO).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_name |
str
|
current name of the task. |
required |
new_name |
str
|
new name of the task. |
required |
Source code in icua\environment\multitask_environment.py
93 94 95 96 97 98 99 100 |
|