add prototype fake robot, more debug logging

This commit is contained in:
Olivier R-D
2013-04-20 19:12:55 +02:00
parent 8e0538ab09
commit ddbd6e9ce1
6 changed files with 94 additions and 8 deletions

View File

@ -11,8 +11,6 @@ __author__ = "Olivier Roulet-Dubonnet"
__copyright__ = "Copyright 2011-2012, Olivier Roulet-Dubonnet"
__credits__ = ["Olivier Roulet-Dubonnet"]
__license__ = "GPLv3"
__version__ = "0.4"
__status__ = "Development"
from threading import Thread, Condition, Lock
import logging
@ -159,12 +157,17 @@ class ParserUtils(object):
returns None if none found
"""
counter = 0
limit = 10
while True:
if len(data) >= 5:
psize, ptype = self.get_header(data)
if psize < 5 or psize > 2000 or ptype != 16:
data = data[1:]
counter += 1
if counter > limit:
self.logger.warn("tried {} times to find a packet in data, advertised packet size: {}, type: {}".format(counter, psize, ptype))
self.logger.warn("Data length: {}".format(len(data)))
limit = limit * 10
elif len(data) >= psize:
self.logger.debug("Got packet with size {0} and type {1}".format(psize, ptype))
if counter:
@ -265,6 +268,7 @@ class SecondaryMonitor(Thread):
returns something that looks like a packet, nothing is guaranted
"""
while True:
#self.logger.debug("data queue size is: {}".format(len(self._dataqueue)))
ans = self._parser.find_first_packet(self._dataqueue[:])
if ans:
self._dataqueue = ans[1]

View File

@ -43,7 +43,7 @@ class URRobot(object):
The RT interfaces is only used for the get_force related methods
Rmq: A program sent to the robot i executed immendiatly and any running program is stopped
"""
def __init__(self, host, useRTInterface=False, logLevel=logging.WARN):
def __init__(self, host, useRTInterface=False, logLevel=logging.WARN, parserLogLevel=logging.WARN):
self.logger = logging.getLogger(self.__class__.__name__)
if len(logging.root.handlers) == 0: #dirty hack
logging.basicConfig()
@ -51,7 +51,7 @@ class URRobot(object):
self.host = host
self.logger.info("Opening secondary monitor socket")
self.secmon = ursecmon.SecondaryMonitor(self.host, logLevel=logLevel, parserLogLevel=logging.WARN) #data from robot at 10Hz
self.secmon = ursecmon.SecondaryMonitor(self.host, logLevel=logLevel, parserLogLevel=parserLogLevel) #data from robot at 10Hz
if useRTInterface:
self.logger.info("Opening real-time monitor socket")
@ -381,8 +381,8 @@ class Robot(URRobot):
Compare to the URRobot class, this class adds the possibilty to work directly with matrices
and includes support for calibrating the robot coordinate system
"""
def __init__(self, host, useRTInterface=False, logLevel = logging.WARN):
URRobot.__init__(self, host, useRTInterface, logLevel=logLevel)
def __init__(self, host, useRTInterface=False, logLevel = logging.WARN, parserLogLevel=logging.WARN):
URRobot.__init__(self, host, useRTInterface, logLevel=logLevel, parserLogLevel=parserLogLevel)
self.default_linear_acceleration = 0.01
self.default_linear_velocity = 0.01