4 from .
import numpy_msg
10 assert issubclass(msgtype, genpy.Message)
12 _to_numpy[msgtype, plural] = f
18 assert issubclass(msgtype, genpy.Message)
20 _from_numpy[msgtype, plural] = f
21 _from_numpy[
numpy_msg(msgtype), plural] = f
29 conv = _to_numpy.get((msg.__class__,
False))
30 if not conv
and isinstance(msg, collections.Sequence):
32 raise ValueError(
"Cannot determine the type of an empty Collection")
33 conv = _to_numpy.get((msg[0].__class__,
True))
37 raise ValueError(
"Unable to convert message {} - only supports {}".format(
38 msg.__class__.__name__,
39 ', '.join(cls.__name__ + (
"[]" if pl
else '')
for cls, pl
in _to_numpy.keys())
42 return conv(msg, *args, **kwargs)
44 def msgify(msg_type, numpy_obj, *args, **kwargs):
45 conv = _from_numpy.get((msg_type, kwargs.pop(
'plural',
False)))
47 raise ValueError(
"Unable to build message {} - only supports {}".format(
49 ', '.join(cls.__name__ + (
"[]" if pl
else '')
for cls, pl
in _to_numpy.keys())
51 return conv(numpy_obj, *args, **kwargs)
def numpify(msg, args, kwargs)
def converts_from_numpy(msgtype, plural=False)
def converts_to_numpy(msgtype, plural=False)
def msgify(msg_type, numpy_obj, args, kwargs)