Skip to content

Commit 17293d4

Browse files
galenlynchclaude
andcommitted
docs: document abort_velocity_threshold interaction with the stop threshold
Per review feedback: the velocity abort is evaluated on the same filtered velocity signal as stop detection (IsStopped = velocity < StopVelocityThreshold), so the two gates partition one velocity axis in opposite directions. Document that abort_velocity_threshold must stay >= the operative StopVelocityThreshold (else a locked stop instantly aborts), and that because StopVelocityThreshold is shaped (60->8 via the GAIN updater) while the abort is a fixed absolute, the abort may only be enabled where the stop gate is already floored below it. Add the matching rationale where the grid stages set 15 against their static stop threshold of 8. Docstring only; schema/*.json and Generated.cs must be regenerated on the rig. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 834948e commit 17293d4

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

  • src/packages
    • aind_behavior_vr_foraging_curricula/src/aind_behavior_vr_foraging_curricula/single_site
    • aind_behavior_vr_foraging/src/aind_behavior_vr_foraging

src/packages/aind_behavior_vr_foraging/src/aind_behavior_vr_foraging/task_logic.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,20 @@ class OperantLogic(BaseModel):
205205
ge=0,
206206
description="Velocity (cm/s) above which an in-progress operant choice is aborted. This is an ADDITIONAL "
207207
"abort source: the choice aborts if velocity exceeds this OR displacement exceeds grace_distance_threshold "
208-
"OR the animal leaves the reward site. None disables only the velocity source (grace + leave-site still apply).",
209-
) # NOTE: in InstantiateSite.bonsai, add a velocity-abort branch ALONGSIDE the grace/leave-site sources (do not replace them).
208+
"OR the animal leaves the reward site. None disables only the velocity source (grace + leave-site still apply). "
209+
"Interaction with the stop threshold: this is evaluated on the SAME filtered velocity signal as stop "
210+
"detection, which locks a choice when velocity falls BELOW StopVelocityThreshold "
211+
"(UpdaterTarget.STOP_VELOCITY_THRESHOLD, seeded from the position-control velocity_threshold and shaped "
212+
"within/across sessions). The two gates partition the same velocity axis in opposite directions, so this "
213+
"value must be >= the operative StopVelocityThreshold: if it is lower, the band "
214+
"(abort_velocity_threshold, StopVelocityThreshold) lets the animal lock a stop while already too fast to "
215+
"hold it, forfeiting every such choice. Because StopVelocityThreshold is dynamic (e.g. shaped 60 -> 8 cm/s "
216+
"by a GAIN updater) whereas this is a fixed absolute, only enable the velocity abort on stages where the "
217+
"stop threshold is already floored below it (e.g. a static stop threshold of 8 with this set to 15); never "
218+
"pair a low fixed abort with an actively-shaped, still-high stop threshold.",
219+
) # Implemented in InstantiateSite.bonsai as a third input merged ALONGSIDE the grace-distance and leave-site
220+
# sources (the CheckDistanceFromEntry groups under WaitDelay and WaitForLick), comparing
221+
# FilteredCurrentVelocity.Item1 -- the same signal used for stop detection -- against this value.
210222

211223

212224
class _PatchUpdateFunction(BaseModel):

src/packages/aind_behavior_vr_foraging_curricula/src/aind_behavior_vr_foraging_curricula/single_site/stages.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ def _probability_grid_blocks(
151151
# grace_distance_threshold raised to 50 cm (a full reward-site length, vs the 10 cm
152152
# default) so the spatial source does not also clip that creep -- here velocity and
153153
# leaving the site do the work, with grace only a far backstop.
154+
# The 15 sits safely above this stage's stop velocity threshold (a static 8 -- the grid
155+
# stages carry no STOP_VELOCITY_THRESHOLD updater, so the gate does not shape up into it).
156+
# abort_velocity_threshold must stay >= the stop threshold or a locked stop would instantly
157+
# abort; that is why the abort is off on learn_to_stop, where the gate is still shaping 60->8.
158+
# See OperantLogic.abort_velocity_threshold for the full interaction.
154159
make_patch_kwargs = {
155160
**_POST_STOP_PATCH_KWARGS,
156161
"delay": delay,

0 commit comments

Comments
 (0)