00001
00002 import struct
00003 import unittest
00004 import rospy
00005 from rospy_message_converter import message_converter
00006
00007 class TestMessageConverter(unittest.TestCase):
00008
00009 def test_ros_message_with_array(self):
00010 from rospy_message_converter.msg import TestArray
00011 expected_dictionary = {
00012 'data': [1.1, 2.2, 3.3]
00013 }
00014 message = TestArray(data = expected_dictionary['data'])
00015 message = serialize_deserialize(message)
00016 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00017 self.assertEqual(dictionary, expected_dictionary)
00018
00019 def test_ros_message_with_bool(self):
00020 from std_msgs.msg import Bool
00021 expected_dictionary = { 'data': True }
00022 message = Bool(data=expected_dictionary['data'])
00023 message = serialize_deserialize(message)
00024 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00025 self.assertEqual(dictionary, expected_dictionary)
00026
00027 def test_ros_message_with_byte(self):
00028 from std_msgs.msg import Byte
00029 expected_dictionary = { 'data': 5 }
00030 message = Byte(data=expected_dictionary['data'])
00031 message = serialize_deserialize(message)
00032 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00033 self.assertEqual(dictionary, expected_dictionary)
00034
00035 def test_ros_message_with_char(self):
00036 from std_msgs.msg import Char
00037 expected_dictionary = { 'data': 99 }
00038 message = Char(data=expected_dictionary['data'])
00039 message = serialize_deserialize(message)
00040 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00041 self.assertEqual(dictionary, expected_dictionary)
00042
00043 def test_ros_message_with_duration(self):
00044 from std_msgs.msg import Duration
00045 duration = rospy.rostime.Duration(33, 25)
00046 expected_dictionary = {
00047 'data': {
00048 'secs' : duration.secs,
00049 'nsecs' : duration.nsecs
00050 }
00051 }
00052 message = Duration(data=duration)
00053 message = serialize_deserialize(message)
00054 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00055 self.assertEqual(dictionary, expected_dictionary)
00056
00057 def test_ros_message_with_empty(self):
00058 from std_msgs.msg import Empty
00059 expected_dictionary = {}
00060 message = Empty()
00061 message = serialize_deserialize(message)
00062 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00063 self.assertEqual(dictionary, expected_dictionary)
00064
00065 def test_ros_message_with_float32(self):
00066 from std_msgs.msg import Float32
00067 expected_dictionary = { 'data': struct.unpack('<f', '\x7F\x7F\xFF\xFD')[0] }
00068 message = Float32(data=expected_dictionary['data'])
00069 message = serialize_deserialize(message)
00070 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00071 self.assertEqual(dictionary, expected_dictionary)
00072
00073 def test_ros_message_with_float64(self):
00074 from std_msgs.msg import Float64
00075 expected_dictionary = { 'data': struct.unpack('<d', '\x7F\xEF\xFF\xFF\xFF\xFF\xFF\xFD')[0] }
00076 message = Float64(data=expected_dictionary['data'])
00077 message = serialize_deserialize(message)
00078 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00079 self.assertEqual(dictionary, expected_dictionary)
00080
00081 def test_ros_message_with_header(self):
00082 from std_msgs.msg import Header
00083 from time import time
00084 now_time = rospy.Time(time())
00085 expected_dictionary = {
00086 'stamp': { 'secs': now_time.secs, 'nsecs': now_time.nsecs },
00087 'frame_id' : 'my_frame',
00088 'seq': 3
00089 }
00090 message = Header(
00091 stamp = now_time,
00092 frame_id = expected_dictionary['frame_id'],
00093 seq = expected_dictionary['seq']
00094 )
00095 message = serialize_deserialize(message)
00096 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00097 self.assertEqual(dictionary, expected_dictionary)
00098
00099 def test_ros_message_with_int8(self):
00100 from std_msgs.msg import Int8
00101 expected_dictionary = { 'data': -0x7F }
00102 message = Int8(data=expected_dictionary['data'])
00103 message = serialize_deserialize(message)
00104 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00105 self.assertEqual(dictionary, expected_dictionary)
00106
00107 def test_ros_message_with_uint8(self):
00108 from std_msgs.msg import UInt8
00109 expected_dictionary = { 'data': 0xFF }
00110 message = UInt8(data=expected_dictionary['data'])
00111 message = serialize_deserialize(message)
00112 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00113 self.assertEqual(dictionary, expected_dictionary)
00114
00115 def test_ros_message_with_uint8_array(self):
00116 from rospy_message_converter.msg import Uint8ArrayTestMessage
00117 from base64 import standard_b64encode
00118 expected_data = "".join([chr(i) for i in [97, 98, 99, 100]])
00119 message = Uint8ArrayTestMessage(data=expected_data)
00120 message = serialize_deserialize(message)
00121 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00122 self.assertEqual(dictionary["data"], standard_b64encode(expected_data))
00123
00124 def test_ros_message_with_3uint8_array(self):
00125 from rospy_message_converter.msg import Uint8Array3TestMessage
00126 from base64 import standard_b64encode
00127 expected_data = "".join([chr(i) for i in [97, 98, 99]])
00128 message = Uint8Array3TestMessage(data=expected_data)
00129 message = serialize_deserialize(message)
00130 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00131 self.assertEqual(dictionary["data"], standard_b64encode(expected_data))
00132
00133 def test_ros_message_with_int16(self):
00134 from std_msgs.msg import Int16
00135 expected_dictionary = { 'data': -0x7FFF }
00136 message = Int16(data=expected_dictionary['data'])
00137 message = serialize_deserialize(message)
00138 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00139 self.assertEqual(dictionary, expected_dictionary)
00140
00141 def test_ros_message_with_uint16(self):
00142 from std_msgs.msg import UInt16
00143 expected_dictionary = { 'data': 0xFFFF }
00144 message = UInt16(data=expected_dictionary['data'])
00145 message = serialize_deserialize(message)
00146 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00147 self.assertEqual(dictionary, expected_dictionary)
00148
00149 def test_ros_message_with_int32(self):
00150 from std_msgs.msg import Int32
00151 expected_dictionary = { 'data': -0x7FFFFFFF }
00152 message = Int32(data=expected_dictionary['data'])
00153 message = serialize_deserialize(message)
00154 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00155 self.assertEqual(dictionary, expected_dictionary)
00156
00157 def test_ros_message_with_uint32(self):
00158 from std_msgs.msg import UInt32
00159 expected_dictionary = { 'data': 0xFFFFFFFF }
00160 message = UInt32(data=expected_dictionary['data'])
00161 message = serialize_deserialize(message)
00162 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00163 self.assertEqual(dictionary, expected_dictionary)
00164
00165 def test_ros_message_with_int64(self):
00166 from std_msgs.msg import Int64
00167 expected_dictionary = { 'data': -0x7FFFFFFFFFFFFFFF }
00168 message = Int64(data=expected_dictionary['data'])
00169 message = serialize_deserialize(message)
00170 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00171 self.assertEqual(dictionary, expected_dictionary)
00172
00173 def test_ros_message_with_uint64(self):
00174 from std_msgs.msg import UInt64
00175 expected_dictionary = { 'data': 0xFFFFFFFFFFFFFFFF }
00176 message = UInt64(data=expected_dictionary['data'])
00177 message = serialize_deserialize(message)
00178 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00179 self.assertEqual(dictionary, expected_dictionary)
00180
00181 def test_ros_message_with_string(self):
00182 from std_msgs.msg import String
00183 expected_dictionary = { 'data': 'Hello' }
00184 message = String(data=expected_dictionary['data'])
00185 message = serialize_deserialize(message)
00186 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00187 self.assertEqual(dictionary, expected_dictionary)
00188
00189 def test_ros_message_with_time(self):
00190 from std_msgs.msg import Time
00191 from time import time
00192 now_time = rospy.Time(time())
00193 expected_dictionary = {
00194 'data': { 'secs': now_time.secs, 'nsecs': now_time.nsecs }
00195 }
00196 message = Time(data=now_time)
00197 message = serialize_deserialize(message)
00198 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00199 self.assertEqual(dictionary, expected_dictionary)
00200
00201 def test_ros_message_with_child_message(self):
00202 from std_msgs.msg import Float64MultiArray, MultiArrayLayout, MultiArrayDimension
00203 expected_dictionary = {
00204 'layout': {
00205 'dim': [
00206 { 'label': 'Dimension1', 'size': 12, 'stride': 7 },
00207 { 'label': 'Dimension2', 'size': 24, 'stride': 14 }
00208 ],
00209 'data_offset': 0
00210 },
00211 'data': [1.1, 2.2, 3.3]
00212 }
00213 dimension1 = MultiArrayDimension(
00214 label = expected_dictionary['layout']['dim'][0]['label'],
00215 size = expected_dictionary['layout']['dim'][0]['size'],
00216 stride = expected_dictionary['layout']['dim'][0]['stride']
00217 )
00218 dimension2 = MultiArrayDimension(
00219 label = expected_dictionary['layout']['dim'][1]['label'],
00220 size = expected_dictionary['layout']['dim'][1]['size'],
00221 stride = expected_dictionary['layout']['dim'][1]['stride']
00222 )
00223 layout = MultiArrayLayout(
00224 dim = [dimension1, dimension2],
00225 data_offset = expected_dictionary['layout']['data_offset']
00226 )
00227 message = Float64MultiArray(
00228 layout = layout,
00229 data = expected_dictionary['data']
00230 )
00231 message = serialize_deserialize(message)
00232 dictionary = message_converter.convert_ros_message_to_dictionary(message)
00233 self.assertEqual(dictionary, expected_dictionary)
00234
00235 def test_dictionary_with_array(self):
00236 from rospy_message_converter.msg import TestArray
00237 expected_message = TestArray(data = [1.1, 2.2, 3.3, 4.4])
00238 dictionary = { 'data': expected_message.data }
00239 message = message_converter.convert_dictionary_to_ros_message('rospy_message_converter/TestArray', dictionary)
00240 expected_message = serialize_deserialize(expected_message)
00241 self.assertEqual(message, expected_message)
00242
00243 def test_dictionary_with_bool(self):
00244 from std_msgs.msg import Bool
00245 expected_message = Bool(data = True)
00246 dictionary = { 'data': expected_message.data }
00247 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Bool', dictionary)
00248 expected_message = serialize_deserialize(expected_message)
00249 self.assertEqual(message, expected_message)
00250
00251 def test_dictionary_with_byte(self):
00252 from std_msgs.msg import Byte
00253 expected_message = Byte(data = 3)
00254 dictionary = { 'data': expected_message.data }
00255 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Byte', dictionary)
00256 expected_message = serialize_deserialize(expected_message)
00257 self.assertEqual(message, expected_message)
00258
00259 def test_dictionary_with_char(self):
00260 from std_msgs.msg import Char
00261 expected_message = Char(data = 99)
00262 dictionary = { 'data': expected_message.data }
00263 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Char', dictionary)
00264 expected_message = serialize_deserialize(expected_message)
00265 self.assertEqual(message, expected_message)
00266
00267 def test_dictionary_with_duration(self):
00268 from std_msgs.msg import Duration
00269 duration = rospy.rostime.Duration(33, 25)
00270 expected_message = Duration(data = duration)
00271 dictionary = {
00272 'data': {
00273 'secs' : duration.secs,
00274 'nsecs' : duration.nsecs
00275 }
00276 }
00277 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Duration', dictionary)
00278 expected_message = serialize_deserialize(expected_message)
00279 self.assertEqual(message, expected_message)
00280
00281 def test_dictionary_with_empty(self):
00282 from std_msgs.msg import Empty
00283 expected_message = Empty()
00284 dictionary = {}
00285 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Empty', dictionary)
00286 expected_message = serialize_deserialize(expected_message)
00287 self.assertEqual(message, expected_message)
00288
00289 def test_dictionary_with_float32(self):
00290 from std_msgs.msg import Float32
00291 expected_message = Float32(data = struct.unpack('<f', '\x7F\x7F\xFF\xFD')[0])
00292 dictionary = { 'data': expected_message.data }
00293 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Float32', dictionary)
00294 expected_message = serialize_deserialize(expected_message)
00295 self.assertEqual(message, expected_message)
00296
00297 def test_dictionary_with_float64(self):
00298 from std_msgs.msg import Float64
00299 expected_message = Float64(data = struct.unpack('<d', '\x7F\xEF\xFF\xFF\xFF\xFF\xFF\xFD')[0])
00300 dictionary = { 'data': expected_message.data }
00301 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Float64', dictionary)
00302 expected_message = serialize_deserialize(expected_message)
00303 self.assertEqual(message, expected_message)
00304
00305 def test_dictionary_with_header(self):
00306 from std_msgs.msg import Header
00307 from time import time
00308 now_time = rospy.Time(time())
00309 expected_message = Header(
00310 stamp = now_time,
00311 frame_id = 'my_frame',
00312 seq = 12
00313 )
00314 dictionary = {
00315 'stamp': { 'secs': now_time.secs, 'nsecs': now_time.nsecs },
00316 'frame_id' : expected_message.frame_id,
00317 'seq': expected_message.seq
00318 }
00319 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Header', dictionary)
00320 expected_message = serialize_deserialize(expected_message)
00321 self.assertEqual(message, expected_message)
00322
00323 def test_dictionary_with_header_with_no_prefix(self):
00324 from std_msgs.msg import Header
00325 from time import time
00326 now_time = rospy.Time(time())
00327 expected_message = Header(
00328 stamp = now_time,
00329 frame_id = 'my_frame',
00330 seq = 12
00331 )
00332 dictionary = {
00333 'stamp': { 'secs': now_time.secs, 'nsecs': now_time.nsecs },
00334 'frame_id' : expected_message.frame_id,
00335 'seq': expected_message.seq
00336 }
00337 message = message_converter.convert_dictionary_to_ros_message('Header', dictionary)
00338 expected_message = serialize_deserialize(expected_message)
00339 self.assertEqual(message, expected_message)
00340
00341 def test_dictionary_with_int8(self):
00342 from std_msgs.msg import Int8
00343 expected_message = Int8(data = -0x7F)
00344 dictionary = { 'data': expected_message.data }
00345 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Int8', dictionary)
00346 expected_message = serialize_deserialize(expected_message)
00347 self.assertEqual(message, expected_message)
00348
00349 def test_dictionary_with_uint8(self):
00350 from std_msgs.msg import UInt8
00351 expected_message = UInt8(data = 0xFF)
00352 dictionary = { 'data': expected_message.data }
00353 message = message_converter.convert_dictionary_to_ros_message('std_msgs/UInt8', dictionary)
00354 expected_message = serialize_deserialize(expected_message)
00355 self.assertEqual(message, expected_message)
00356
00357 def test_dictionary_with_int16(self):
00358 from std_msgs.msg import Int16
00359 expected_message = Int16(data = -0x7FFF)
00360 dictionary = { 'data': expected_message.data }
00361 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Int16', dictionary)
00362 expected_message = serialize_deserialize(expected_message)
00363 self.assertEqual(message, expected_message)
00364
00365 def test_dictionary_with_uint16(self):
00366 from std_msgs.msg import UInt16
00367 expected_message = UInt16(data = 0xFFFF)
00368 dictionary = { 'data': expected_message.data }
00369 message = message_converter.convert_dictionary_to_ros_message('std_msgs/UInt16', dictionary)
00370 expected_message = serialize_deserialize(expected_message)
00371 self.assertEqual(message, expected_message)
00372
00373 def test_dictionary_with_int32(self):
00374 from std_msgs.msg import Int32
00375 expected_message = Int32(data = -0x7FFFFFFF)
00376 dictionary = { 'data': expected_message.data }
00377 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Int32', dictionary)
00378 expected_message = serialize_deserialize(expected_message)
00379 self.assertEqual(message, expected_message)
00380
00381 def test_dictionary_with_uint32(self):
00382 from std_msgs.msg import UInt32
00383 expected_message = UInt32(data = 0xFFFFFFFF)
00384 dictionary = { 'data': expected_message.data }
00385 message = message_converter.convert_dictionary_to_ros_message('std_msgs/UInt32', dictionary)
00386 expected_message = serialize_deserialize(expected_message)
00387 self.assertEqual(message, expected_message)
00388
00389 def test_dictionary_with_int64(self):
00390 from std_msgs.msg import Int64
00391 expected_message = Int64(data = -0x7FFFFFFFFFFFFFFF)
00392 dictionary = { 'data': expected_message.data }
00393 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Int64', dictionary)
00394 expected_message = serialize_deserialize(expected_message)
00395 self.assertEqual(message, expected_message)
00396
00397 def test_dictionary_with_uint64(self):
00398 from std_msgs.msg import UInt64
00399 expected_message = UInt64(data = 0xFFFFFFFFFFFFFFFF)
00400 dictionary = { 'data': expected_message.data }
00401 message = message_converter.convert_dictionary_to_ros_message('std_msgs/UInt64', dictionary)
00402 expected_message = serialize_deserialize(expected_message)
00403 self.assertEqual(message, expected_message)
00404
00405 def test_dictionary_with_string(self):
00406 from std_msgs.msg import String
00407 expected_message = String(data = 'Hello')
00408 dictionary = { 'data': expected_message.data }
00409 message = message_converter.convert_dictionary_to_ros_message('std_msgs/String', dictionary)
00410 expected_message = serialize_deserialize(expected_message)
00411 self.assertEqual(message, expected_message)
00412
00413 def test_dictionary_with_unicode(self):
00414 from std_msgs.msg import String
00415 expected_message = String(data = 'Hello')
00416 dictionary = { 'data': unicode(expected_message.data) }
00417 message = message_converter.convert_dictionary_to_ros_message('std_msgs/String', dictionary)
00418 expected_message = serialize_deserialize(expected_message)
00419 self.assertEqual(message.data,expected_message.data)
00420 self.assertEqual(type(message.data),type(expected_message.data))
00421
00422 def test_dictionary_with_time(self):
00423 from std_msgs.msg import Time
00424 from time import time
00425 now_time = rospy.Time(time())
00426 expected_message = Time(data=now_time)
00427 dictionary = {
00428 'data': {
00429 'secs' : now_time.secs,
00430 'nsecs' : now_time.nsecs
00431 }
00432 }
00433 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Time', dictionary)
00434 expected_message = serialize_deserialize(expected_message)
00435 self.assertEqual(message, expected_message)
00436
00437 def test_dictionary_with_child_message(self):
00438 from std_msgs.msg import Float64MultiArray, MultiArrayLayout, MultiArrayDimension
00439 expected_message = Float64MultiArray(
00440 layout = MultiArrayLayout(
00441 dim = [
00442 MultiArrayDimension(label = 'Dimension1', size = 12, stride = 7),
00443 MultiArrayDimension(label = 'Dimension2', size = 90, stride = 8)
00444 ],
00445 data_offset = 1
00446 ),
00447 data = [1.1, 2.2, 3.3]
00448 )
00449 dictionary = {
00450 'layout': {
00451 'dim': [
00452 {
00453 'label' : expected_message.layout.dim[0].label,
00454 'size' : expected_message.layout.dim[0].size,
00455 'stride' : expected_message.layout.dim[0].stride
00456 },
00457 {
00458 'label' : expected_message.layout.dim[1].label,
00459 'size' : expected_message.layout.dim[1].size,
00460 'stride' : expected_message.layout.dim[1].stride
00461 }
00462 ],
00463 'data_offset': expected_message.layout.data_offset
00464 },
00465 'data': expected_message.data
00466 }
00467 message = message_converter.convert_dictionary_to_ros_message('std_msgs/Float64MultiArray', dictionary)
00468 expected_message = serialize_deserialize(expected_message)
00469 self.assertEqual(message, expected_message)
00470
00471 def test_dictionary_with_invalid_message_fields(self):
00472 self.assertRaises(ValueError,
00473 message_converter.convert_dictionary_to_ros_message,
00474 'std_msgs/Empty',
00475 {'invalid_field': 1})
00476
00477 def test_dictionary_with_empty_service(self):
00478 from std_srvs.srv import Empty, EmptyRequest, EmptyResponse
00479 expected_req = EmptyRequest()
00480 expected_res = EmptyResponse()
00481 dictionary_req = {}
00482 dictionary_res = {}
00483 message = message_converter.convert_dictionary_to_ros_message('std_srvs/Empty', dictionary_req,
00484 'request')
00485 expected_req = serialize_deserialize(expected_req)
00486 self.assertEqual(message, expected_req)
00487 message = message_converter.convert_dictionary_to_ros_message('std_srvs/Empty', dictionary_res,
00488 'response')
00489 expected_res = serialize_deserialize(expected_res)
00490 self.assertEqual(message, expected_res)
00491
00492 def test_dictionary_with_setbool_service(self):
00493 from std_srvs.srv import SetBool, SetBoolRequest, SetBoolResponse
00494 expected_req = SetBoolRequest(data=True)
00495 expected_res = SetBoolResponse(success=True, message='Success!')
00496 dictionary_req = { 'data': True }
00497 dictionary_res = { 'success': True, 'message': 'Success!' }
00498 message = message_converter.convert_dictionary_to_ros_message('std_srvs/SetBool', dictionary_req,
00499 'request')
00500 expected_req = serialize_deserialize(expected_req)
00501 self.assertEqual(message, expected_req)
00502 message = message_converter.convert_dictionary_to_ros_message('std_srvs/SetBool', dictionary_res,
00503 'response')
00504 expected_res = serialize_deserialize(expected_res)
00505 self.assertEqual(message, expected_res)
00506
00507 def test_dictionary_with_trigger_service(self):
00508 from std_srvs.srv import Trigger, TriggerRequest, TriggerResponse
00509 expected_req = TriggerRequest()
00510 expected_res = TriggerResponse(success=True, message='Success!')
00511 dictionary_req = {}
00512 dictionary_res = { 'success': True, 'message': 'Success!' }
00513 message = message_converter.convert_dictionary_to_ros_message('std_srvs/Trigger', dictionary_req,
00514 'request')
00515 expected_req = serialize_deserialize(expected_req)
00516 self.assertEqual(message, expected_req)
00517 message = message_converter.convert_dictionary_to_ros_message('std_srvs/Trigger', dictionary_res,
00518 'response')
00519 expected_res = serialize_deserialize(expected_res)
00520 self.assertEqual(message, expected_res)
00521
00522
00523 def serialize_deserialize(message):
00524 """
00525 Serialize and then deserialize a message. This simulates sending a message
00526 between ROS nodes and makes sure that the ROS messages being tested are
00527 actually serializable, and are in the same format as they would be received
00528 over the network. In rospy, it is possible to assign an illegal data type
00529 to a message field (for example, `message = String(data=42)`), but trying
00530 to publish this message will throw `SerializationError: field data must be
00531 of type str`. This method will expose such bugs.
00532 """
00533 from StringIO import StringIO
00534 buff = StringIO()
00535 message.serialize(buff)
00536 result = message.__class__()
00537 result.deserialize(buff.getvalue())
00538 return result
00539
00540
00541 PKG = 'rospy_message_converter'
00542 NAME = 'test_message_converter'
00543 if __name__ == '__main__':
00544 import rosunit
00545 rosunit.unitrun(PKG, NAME, TestMessageConverter)