Skip to content
Snippets Groups Projects
Commit 04197800 authored by gavanderhoorn's avatar gavanderhoorn
Browse files

Ignore unknown pkt types, instead of erroring out.

This change modifies the behaviour of the driver in case an
unknown packet type is encountered. Previously, the deserialisation
routine would raise an exception, which would cause the driver
to print an error and exit.

In the current implementation the unknown packet type(s) are
stored, their payload ignored, and the driver reports the fact that
unknown type(s) was/were received (with a request to report the
warning, ideally to the package maintainer).

This is not a solution for #16, although that issue prompted this
change.
parent 88ddbc3a
Branches
Tags
No related merge requests found
......@@ -199,10 +199,11 @@ class RobotState(object):
__slots__ = ['robot_mode_data', 'joint_data', 'tool_data',
'masterboard_data', 'cartesian_info',
'kinematics_info', 'configuration_data',
'force_mode_data', 'additional_info']
'force_mode_data', 'additional_info',
'unknown_ptypes']
def __init__(self):
pass
self.unknown_ptypes = []
@staticmethod
def unpack(buf):
......@@ -242,7 +243,7 @@ class RobotState(object):
elif ptype == PackageType.ADDITIONAL_INFO:
rs.additional_info = AdditionalInfo.unpack(package_buf)
else:
raise Exception("Unknown package type: %i" % ptype)
rs.unknown_ptypes.append(ptype)
return rs
def pstate(o, indent=''):
......
......@@ -184,6 +184,12 @@ class UR5Connection(object):
self.__trigger_halted()
self.robot_state = self.CONNECTED
# Report on any unknown packet types that were received
if len(state.unknown_ptypes) > 0:
s_unknown_ptypes = [str(ptype) for ptype in state.unknown_ptypes]
rospy.logwarn("Ignoring unknown pkt type(s): %s. "
"Please report." % ",".join(s_unknown_ptypes))
def __run(self):
while self.__keep_running:
r, _, _ = select.select([self.__sock], [], [], self.TIMEOUT)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment