Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/test/vr/perf/latency/robot_arm.py

Issue 2823883003: Make VR latency results compatible with perf dashboard, refactor into classes (Closed)
Patch Set: Address nits Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import serial
6 import time
7
8
9 class RobotArm():
10 """Handles the serial communication with the servos/arm used for movement."""
11 def __init__(self, device_name, num_tries=5, baud=115200, timeout=3.0):
12 self._connection = None
13 connected = False
14 for _ in xrange(num_tries):
15 try:
16 self._connection = serial.Serial('/dev/' + device_name,
17 baud,
18 timeout=timeout)
19 except serial.SerialException as e:
20 pass
21 if self._connection and 'Enter parameters' in self._connection.read(1024):
22 connected = True
23 break
24 if not connected:
25 raise serial.SerialException('Failed to connect to the robot arm.')
26
27 def ResetPosition(self):
28 if not self._connection:
29 return
30 # If the servo stopped very close to the desired position, it can just
31 # vibrate instead of moving, so move away before going to the reset
32 # position
33 self._connection.write('5 300 0 5\n')
34 time.sleep(0.5)
35 self._connection.write('5 250 0 5\n')
36 time.sleep(0.5)
37
38 def StartMotophoMovement(self):
39 if not self._connection:
40 return
41 self._connection.write('9\n')
42
43 def StopAllMovement(self):
44 if not self._connection:
45 return
46 self._connection.write('0\n')
OLDNEW
« no previous file with comments | « chrome/test/vr/perf/latency/motopho_thread.py ('k') | chrome/test/vr/perf/latency/run_latency_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698