Agent default
Module contains a default implementation for a guidance agent, see DefaultGuidanceAgent
documentation for details.
ArrowGuidanceActuator
¶
Bases: GuidanceActuator
A concrete implementation of GuidanceActuator
that implements a guidance arrow.
The arrow can be displayed in three different ways depending on the value of arrow_mode
:
- "gaze" will display the arrow at the users gaze position, offset by arrow_offset
.
- "mouse" will display the arrow at the users mouse position, offset by arrow_offset
.
- "fixed" will display the arrow at a fixed position on the screen, this position is specified by arrow_offset
.
Source code in icua\agent\actuator_guidance.py
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 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
__init__(arrow_mode, arrow_scale=1.0, arrow_fill_color='none', arrow_stroke_color='#ff0000', arrow_stroke_width=4.0, arrow_offset=(80, 80))
¶
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arrow_mode |
Literal['gaze', 'mouse', 'fixed']
|
modes for arrow display. |
required |
arrow_scale |
float
|
scale of the arrow. Defaults to 1.0. |
1.0
|
arrow_fill_color |
str
|
fill colour of the arrow. Defaults to "none". |
'none'
|
arrow_stroke_color |
str
|
line colour of the arrow outline. Defaults to "#ff0000". |
'#ff0000'
|
arrow_stroke_width |
float
|
line width of the arrow outline. Defaults to 4.0. |
4.0
|
arrow_offset |
tuple[float, float]
|
offset of the arrow from its set position. This is the position used if `arrow_mode == "fixed". Defaults to (80, 80). |
(80, 80)
|
Source code in icua\agent\actuator_guidance.py
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 |
|
draw_guidance_arrow(name, x, y, scale=1.0, rotation=0.0, fill='none', opacity=0.0, stroke_color='#ff0000', stroke_width=2.0, **kwargs)
¶
Attempt method that takes an action to draw a guidance arrow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
id. |
required |
x |
float
|
x position. |
required |
y |
float
|
y position. |
required |
scale |
float
|
scale. Defaults to 1.0. |
1.0
|
rotation |
float
|
rotation. Defaults to 0.0. |
0.0
|
fill |
str
|
fill color. Defaults to "none". |
'none'
|
opacity |
float
|
opacity (0.0 means hidden). Defaults to 0.0. |
0.0
|
stroke_color |
str
|
color of the arrow border. Defaults to "#ff0000". |
'#ff0000'
|
stroke_width |
float
|
thickness of the arrow border. Defaults to 2.0. |
2.0
|
kwargs |
(dict[str,Any]): additional optional keyword arguments. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
DrawArrowAction |
DrawArrowAction
|
action |
Source code in icua\agent\actuator_guidance.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
hide_guidance(task)
¶
Hide guidance on the given task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str
|
task to hide guidance for. |
required |
Returns:
Type | Description |
---|---|
list[Action]
|
list[Action]: guidance actions |
Source code in icua\agent\actuator_guidance.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
set_gaze_position(action)
¶
Sets the users current gaze position. This may be used as a position for arrow display.
Source code in icua\agent\actuator_guidance.py
229 230 231 232 |
|
set_mouse_motion(action)
¶
Sets the users current mouse position. This may be used as a position for arrow display.
Source code in icua\agent\actuator_guidance.py
234 235 236 237 |
|
show_guidance(task)
¶
Show guidance on the given task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str
|
task to show guidance for. |
required |
Returns:
Type | Description |
---|---|
list[Action]
|
list[Action]: guidance actions |
Source code in icua\agent\actuator_guidance.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
BoxGuidanceActuator
¶
Bases: GuidanceActuator
A concrete implementation of GuidanceActuator
that implements box guidance. The box bounds a given task element serving to highlight it to the user, typically the task will be one that is not in an acceptible state.
Source code in icua\agent\actuator_guidance.py
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 |
|
__init__(box_stroke_color='#ff0000', box_stroke_width=4.0)
¶
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
box_stroke_color |
str
|
color of the box. Defaults to "#ff0000". |
'#ff0000'
|
box_stroke_width |
float
|
width of the box outline. Defaults to 4.0. |
4.0
|
Source code in icua\agent\actuator_guidance.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
draw_guidance_box_on_element(element_id, **box_data)
¶
Attempt method that will draw a box around a given element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element_id |
str
|
the |
required |
box_data |
dict[str, Any]
|
data associated with the box. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
DrawBoxOnElementAction |
DrawBoxOnElementAction
|
action |
Source code in icua\agent\actuator_guidance.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
hide_guidance(task)
¶
Hide guidance on the given task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str
|
task to hide guidance for. |
required |
Returns:
Type | Description |
---|---|
list[Action]: guidance actions |
Source code in icua\agent\actuator_guidance.py
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 |
|
show_guidance(task)
¶
Show guidance on the given task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str
|
task to show guidance for. |
required |
Returns:
Type | Description |
---|---|
list[Action]
|
list[Action]: guidance actions |
Source code in icua\agent\actuator_guidance.py
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 |
|
DefaultGuidanceAgent
¶
Bases: GuidanceAgent
Default implementation of a guidance agent for the matbii system.
Show guidance if
- there is no guidance already active.
- the task is unacceptable.
- the user is not already attending on the task.
- the grace period has elapsed.
Source code in matbii\guidance\agent_default.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 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 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
__init__(sensors, actuators, break_ties='random', grace_mode='failure', attention_mode='fixation', grace_period=3.0, counter_factual=False, **kwargs)
¶
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensors |
list[Sensor]
|
list of sensors, this will typically be a list of |
required |
actuators |
list[Actuator]
|
list of actuators, this will typically contain actuators that are capable of providing visual feedback to a user, see e.g. |
required |
break_ties |
Literal['random', 'longest', 'since']
|
how to break ties if guidance may be shown on multiple tasks simultaneously. Defaults to "random". "random" will randomly break the tie, "longest" will choose the task that has been in failure for the longest, "since" will choose the task that has not had guidance shown for the longest time. |
'random'
|
grace_mode |
Literal['guidance_task', 'guidance_any', 'failure', 'attention']
|
how to track the grace period. "guidance_task" will track the time since guidance was last shown on the task, "guidance_any" will track the time since guidance was last shown on any task, "failure" will track the time since the last failure on the task, "attention" will track the time since the user was last attending to a task. Defaults to "failure". |
'failure'
|
attention_mode |
Literal['fixation', 'gaze', 'mouse']
|
method of determining where the user is attending. "fixation" will use the most recent gaze fixation, "gaze" will use the gaze position (including saccades), "mouse" will use the current mouse position. Defaults to "fixation". |
'fixation'
|
grace_period |
float
|
the time to wait (seconds) before guidance may be shown for a task after the last time guidance was shown on the task. Defaults to 3.0 seconds. |
3.0
|
counter_factual |
bool
|
whether guidance should be shown to the user, or whether it should just be logged. This allows counter-factual experiments to be run, we can track when guidance would have been shown, and compare the when it was actually shown (in a different run). Defaults to False. |
False
|
kwargs |
dict[str, Any]
|
Additional optional keyword arguments. |
{}
|
Source code in matbii\guidance\agent_default.py
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 |
|
attending_task_fixation()
¶
Use fixation to determine which task the user is attending to.
Source code in matbii\guidance\agent_default.py
234 235 236 237 |
|
attending_task_gaze()
¶
Use gaze position (including saccades) to determine which task the user is attending to.
Source code in matbii\guidance\agent_default.py
230 231 232 |
|
attending_task_mouse()
¶
Use mouse position to determine which task the user is attending to.
Source code in matbii\guidance\agent_default.py
226 227 228 |
|
break_tie(tasks, method='random')
¶
Break a tie on tasks that all met the criteria for displaying guiance.
The tie is broken using the method
argument:
- "random" will randomly break the tie.
- "longest" will choose the task that has been in failure for the longest.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tasks |
Iterable[str]
|
tasks to break the tie, one of which will be returned. |
required |
method |
Literal['random', 'longest']
|
how to break ties if guidance may be shown on multiple tasks simultaneously. Defaults to "random". |
'random'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str | None
|
the chosen task, or None if there are no tasks to choose from. |
Source code in matbii\guidance\agent_default.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
get_attending_tasks()
¶
Get the set of tasks that the user is currently attending to - this is typically only one task.
Returns:
Type | Description |
---|---|
set[str]
|
set[str]: set of tasks that the user is currently attending to (empty if no tasks are being attended to). |
Source code in matbii\guidance\agent_default.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
grace_period_over(tasks)
¶
Get the set of (unacceptable) tasks that have had their grace period elapse.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tasks |
set[str]
|
the set of tasks to check. |
required |
Returns:
Type | Description |
---|---|
set[str]
|
set[str]: the set of tasks that have had their grace period elapse. |
Source code in matbii\guidance\agent_default.py
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 |
|
on_attending(attending_tasks)
¶
Called when the user's attention changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attending_tasks |
set[str]
|
the new set of tasks that the user is currently attending to. |
required |
Source code in matbii\guidance\agent_default.py
102 103 104 105 106 107 108 109 110 111 112 |
|
time_since_last_attended(task)
¶
Get the time since the user was last attending to a task.
Source code in matbii\guidance\agent_default.py
201 202 203 204 205 |
|