serialized_message.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 #
00003 # Copyright (C) 2012 Google Inc.
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
00006 # use this file except in compliance with the License. You may obtain a copy of
00007 # the License at
00008 #
00009 # http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00013 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00014 # License for the specific language governing permissions and limitations under
00015 # the License.
00016 
00017 """Prints the serialized bytese of a nav_msgs.Odometry message in hex.
00018 
00019 This can be modified slightly to print the serialized bytes in hex for
00020 arbitrary ROS messages and is useful for generating test cases for rosjava
00021 message serialization.
00022 """
00023 
00024 __author__ = 'damonkohler@google.com (Damon Kohler)'
00025 
00026 import StringIO
00027 
00028 import roslib; roslib.load_manifest('rosjava_test')
00029 import rospy
00030 
00031 import nav_msgs.msg as nav_msgs
00032 
00033 message = nav_msgs.Odometry()
00034 buf = StringIO.StringIO()
00035 message.serialize(buf)
00036 print ''.join('0x%02x,' % ord(c) for c in buf.getvalue())[:-1]
00037 


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49