| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import serial | 5 import serial |
| 6 import time | 6 import time |
| 7 | 7 |
| 8 | 8 |
| 9 class RobotArm(): | 9 class RobotArm(): |
| 10 """Handles the serial communication with the servos/arm used for movement.""" | 10 """Handles the serial communication with the servos/arm used for movement.""" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 def StartMotophoMovement(self): | 38 def StartMotophoMovement(self): |
| 39 if not self._connection: | 39 if not self._connection: |
| 40 return | 40 return |
| 41 self._connection.write('9\n') | 41 self._connection.write('9\n') |
| 42 | 42 |
| 43 def StopAllMovement(self): | 43 def StopAllMovement(self): |
| 44 if not self._connection: | 44 if not self._connection: |
| 45 return | 45 return |
| 46 self._connection.write('0\n') | 46 self._connection.write('0\n') |
| 47 # The manual usage instructions are printed over the serial connection |
| 48 # every time we send a command - long test runs can result in the buffer |
| 49 # filling up and causing the arm to hang, so periodically clear the buffer. |
| 50 self._connection.flushInput() |
| OLD | NEW |