Line: Add optional delay parameter
Again, we need some time to compress the foam before the pressure
reaches a reasonable level for the gesture recognizer.
BUG=chromium:332473
TEST=run with delay parameter
Change-Id: I2db68449d574f5603e363c71a4714bf2c6fe7206
Reviewed-on: https://chromium-review.googlesource.com/191126
Reviewed-by: Dennis Kempin <denniskempin@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@chromium.org>
Tested-by: Dennis Kempin <denniskempin@chromium.org>
diff --git a/touchbotII/line.py b/touchbotII/line.py
old mode 100644
new mode 100755
index 77293f6..add5c3a
--- a/touchbotII/line.py
+++ b/touchbotII/line.py
@@ -42,6 +42,9 @@
fingers = [int(arg) for arg in sys.argv[10:14]]
speed = float(sys.argv[14])
is_swipe = bool(sys.argv[15] == 'swipe')
+ delay = 0.0
+ if len(sys.argv) > 15:
+ delay = float(sys.argv[16])
except:
print (('Usage: python %s device.p start end finger_states speed ' +
'[swipe|basic]') % __file__)
@@ -65,6 +68,7 @@
print '\tFingers: %s' % str(fingers)
print '\tSpeed: %f' % speed
print '\tIs Swipe?: %s' % str(is_swipe)
+print '\tDelay: %f' % delay
# Connect to the robot and configure the profile
bot = Touchbot()
@@ -100,12 +104,12 @@
bot.SetFingerStates([0, 0, 0, 0])
bot.SetCartesian(abs_start, start.finger_distance, blocking=True)
-# Begin moving to the end point
-bot.SetCartesian(abs_end, end.finger_distance, blocking=False)
-
# Sort out what to do with the fingers as it moves depending on if it is a
# swipe or a regular, basic line.
if is_swipe:
+ # start moving to end point
+ bot.SetCartesian(abs_end, end.finger_distance, blocking=False)
+
distance_to_travel = abs_start.CartesianDistanceFrom(abs_end)
distance_traveled = 0.0
# Wait until 1/4 of the distance has been traveled to extend the fingers
@@ -121,6 +125,9 @@
distance_traveled = curr_pos.CartesianDistanceFrom(abs_start)
bot.SetFingerStates([0, 0, 0, 0])
else:
+ # put fingers down and wait for delay
bot.SetFingerStates(fingers)
- bot.Wait()
+ time.sleep(delay)
+ # Move to end point
+ bot.SetCartesian(abs_end, end.finger_distance, blocking=True)
bot.SetFingerStates([0, 0, 0, 0])