Skip to content

Commit 10e27ea

Browse files
author
scratch
committed
Clear the incision warning once a new incision point is set
INCISION_LOST stayed in note and warning after the operator took the documented way out and selected the incision group again, so diagnostics reported WARN for the rest of the session. Clearing happens on the reseed and only for that message, so any other warning still stands.
1 parent 65060d8 commit 10e27ea

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎waybionic_teleop/test/test_incision.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,34 @@ def test_selecting_the_group_again_sets_a_new_incision_point(teleop, arm):
131131
assert teleop.active_group.name == 'incision'
132132
assert math.dist(teleop.incision, first) > 0.02
133133
assert teleop.incision == pytest.approx(arm.forward(teleop.targets)[0])
134+
135+
136+
def test_choosing_the_group_again_clears_the_incision_warning(teleop, arm):
137+
run(teleop, 1.0, left_y=1.0)
138+
run(teleop, 0.3)
139+
teleop.update(*sample('b'), dict(teleop.targets), DT)
140+
teleop.update(*sample(), dict(teleop.targets), DT)
141+
moved = {**teleop.targets, 'joint_2': teleop.targets['joint_2'] + 0.1}
142+
teleop.update(*sample('start'), moved, DT)
143+
teleop.update(*sample(), moved, DT)
144+
run(teleop, 0.1, left_y=1.0)
145+
assert teleop.warning and 'press Y' in teleop.note
146+
# The documented way out: select the incision group again to set a new incision point.
147+
for _ in range(len(teleop.groups)):
148+
teleop.update(*sample('y'), dict(teleop.targets), DT)
149+
teleop.update(*sample(), dict(teleop.targets), DT)
150+
assert teleop.active_group.name == 'incision'
151+
run(teleop, 1.0, left_y=1.0)
152+
run(teleop, 0.3)
153+
assert not teleop.warning and teleop.note == '' and 'incision' not in teleop.blocked
154+
distance, depth = through(arm, teleop.targets, teleop.incision)
155+
assert distance < 1e-5 and depth > 0.005
156+
157+
158+
def test_a_new_incision_point_clears_only_the_incision_warning(teleop):
159+
# Any other warning belongs to whatever raised it, so reseeding must leave it standing.
160+
teleop.incision = None
161+
teleop.note, teleop.warning = 'Controller lost; press Start (Menu) to enable', True
162+
run(teleop, 0.1)
163+
assert teleop.incision is not None
164+
assert teleop.warning and teleop.note == 'Controller lost; press Start (Menu) to enable'

‎waybionic_teleop/waybionic_teleop/teleop.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,12 @@ def incise(self, axes, dt):
289289
before = {joint: self.targets[joint] for joint in kinematics.joints}
290290
tip, pitch = kinematics.forward(before)
291291
if self.incision is None:
292+
# Selecting the group again is the documented way out of INCISION_LOST, and it
293+
# takes the tool's own tip as the new incision point. Clear that warning, and
294+
# only that one, so a later warning is never hidden by this.
292295
self.incision = tip
296+
if self.note == INCISION_LOST:
297+
self.note, self.warning = '', False
293298
offset = [a - b for a, b in zip(tip, self.incision)]
294299
depth = sum(a * b for a, b in zip(offset, kinematics.axis(before)))
295300
if math.sqrt(max(sum(a * a for a in offset) - depth * depth, 0.0)) > INCISION_TOLERANCE:

0 commit comments

Comments
 (0)