aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzonedabone2011-05-09 02:48:42 +0000
committerzonedabone2011-05-09 02:48:42 +0000
commitd05a378100ce03b998160e5895ec35faade50ea2 (patch)
tree5d129d80c93b4137b9b024c85ad8c5aba8ba3522
parent19e6c53223a7d701bb2d56a3262d29cdafe0bd7a (diff)
Added threshold values for ip sockets to Motor class.
-rw-r--r--nxt/bluesock.py2
-rw-r--r--nxt/motor.py17
2 files changed, 10 insertions, 9 deletions
diff --git a/nxt/bluesock.py b/nxt/bluesock.py
index 5f334c0..6af38cb 100644
--- a/nxt/bluesock.py
+++ b/nxt/bluesock.py
@@ -23,7 +23,7 @@ class BlueSock(object):
bsize = 118 # Bluetooth socket block size
PORT = 1 # Standard NXT rfcomm port
- type = 'bt'
+ type = 'bluetooth'
def __init__(self, host):
self.host = host
diff --git a/nxt/motor.py b/nxt/motor.py
index 79f0c7d..a2f0040 100644
--- a/nxt/motor.py
+++ b/nxt/motor.py
@@ -161,11 +161,15 @@ class BaseMotor(object):
if tacho_limit < 0:
raise ValueError, "tacho_units must be greater than 0!"
-
+ #TODO Calibrate the new values for ip socket latency.
if self.method == 'bluetooth':
threshold = 70
elif self.method == 'usb':
threshold = 5
+ elif self.method == 'ipbluetooth':
+ threshold = 80
+ elif self.method == 'ipusb':
+ threshold = 15
else:
threshold = 30 #compromise
@@ -223,13 +227,10 @@ class Motor(BaseMotor):
self._read_state()
self.sync = 0
self.turn_ratio = 0
- if str(type(self.brick.sock)) == "<class 'nxt.bluesock.BlueSock'>":
- self.method = 'bluetooth'
- elif str(type(self.brick.sock)) == "<class 'nxt.usbsock.USBSock'>":
- self.method = 'usb'
- else:
- print "Warning: Socket object does not of a known type."
- print "The name is: " + str(type(self.brick.sock))
+ try:
+ self.method = brick.sock.type
+ except:
+ print "Warning: Socket did not report a type!"
print "Please report this problem to the developers!"
print "For now, turn() accuracy will not be optimal."
print "Continuing happily..."