-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOutputRobotBase.py
83 lines (58 loc) · 2.16 KB
/
OutputRobotBase.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from ObjectMotion import *
import logging
class RobotBaseException(Exception):
pass
class RobotBadMotionInstruction(RobotBaseException):
pass
class RobotCommunicationError(RobotBaseException):
pass
class RobotNotConnected(RobotCommunicationError):
pass
class RobotBase(object):
speed_default = 50
speed_max = 100
speed_min = 1
maximum_retry_count = 5
def __init__(self):
self._name = "Robot device"
self._connection_success = False
self._speed = 0
self._supported_motion_types=[]
def __report_initialisation(self):
logging.debug("Robot initialised: " + self.name)
@property
def name(self):
return self._name
@property
def supported_motion_types(self):
return self._supported_motion_types
def connect(self,maximumRetryCount=50):
raise NotImplemented()
def disconnect(self):
raise NotImplemented()
def report_connection_attempt(self):
logging.info(self.name + ' connection attempt')
def report_connection_fail_retry(self, connection_attempt_count, maximum_retry_count):
logging.info(self.name + ' connection error, retrying (' + str(connection_attempt_count) + '/' + str (maximum_retry_count)+ ')')
def report_connection_success(self):
logging.info(self.name + ' connection success')
def stop(self):
raise NotImplemented()
def output_motion(self, object_motion):
raise NotImplemented()
class BluetoothRobotBase(RobotBase):
def __init__(self,bluetooth_address):
super(BluetoothRobotBase, self).__init__()
self._name = 'Bluetooth Robot device'
self._bluetooth_socket = None
self._bluetooth_address = bluetooth_address
def __report_initialisation(self):
logging.debug('Bluetooth Robot initialised: ' + self.name)
@property
def name(self):
return self._name + ' ' + self._bluetooth_address
@property
def bluetooth_address(self):
return self._bluetooth_address
def connect(self,maximumRetryCount=50):
raise NotImplemented()