33 from __future__
import print_function
45 from genpy
import Time, Duration
60 from genpy.message
import Message, strify_message, fill_message_args
62 yaml_text = strify_message(m)
64 loaded = yaml.load(yaml_text)
65 print(
"loaded", loaded)
66 new_inst = m.__class__()
67 if loaded
is not None:
68 fill_message_args(new_inst, [loaded])
70 fill_message_args(new_inst, [])
77 from std_msgs.msg
import String, Time, MultiArrayLayout, MultiArrayDimension
78 dims1 = [MultiArrayDimension(*args)
for args
in [(
'', 0, 0), (
'x', 1, 2), (
'y of z', 3, 4)]]
79 dims2 = [MultiArrayDimension(
'hello world', 91280, 1983274)]
80 times = [Time(genpy.Time(*args))
for args
in [(0,), (12345, 6789), (1, 1)]]
81 val = ArrayOfMsgs([String(
''), String(
'foo'), String(
'bar of soap')],
83 [MultiArrayLayout(dims1, 0), MultiArrayLayout(dims2, 12354)],
85 self.assertEquals(val, roundtrip(val))
89 from roslib.message
import get_message_class
92 self.assertEquals(
None, get_message_class(
'String'))
93 self.fail(
"should have thrown ValueError")
94 except ValueError:
pass 96 self.assertEquals(
None, get_message_class(
'fake/Fake'))
98 self.assertEquals(
None, get_message_class(
'roslib/Fake'))
100 self.assertEquals(
None, get_message_class(
'genmsg_cpp/Fake'))
102 import rosgraph_msgs.msg
104 self.assertEquals(std_msgs.msg.Header, get_message_class(
'Header'))
105 self.assertEquals(std_msgs.msg.Header, get_message_class(
'std_msgs/Header'))
106 self.assertEquals(rosgraph_msgs.msg.Log, get_message_class(
'rosgraph_msgs/Log'))
109 from roslib.message
import get_service_class
112 self.assertEquals(
None, get_service_class(
'fake/Fake'))
114 self.assertEquals(
None, get_service_class(
'roslib/Fake'))
116 self.assertEquals(
None, get_service_class(
'genmsg_cpp/Fake'))
119 self.assertEquals(std_srvs.srv.Empty, get_service_class(
'std_srvs/Empty'))
def test_strify_message(self)
def test_check_types_Header(self)
def test_get_service_class(self)
def test_get_message_class(self)