publish_backdrop.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest( 'rviz_backdrop' )
00004 from sensor_msgs.msg import Image
00005 from sensor_msgs.msg import CompressedImage
00006 import rospy
00007 
00008 # image_file = 'theater_red_curtains-wide.jpg'
00009 image_file = 'workshop-short.jpg'
00010 
00011 # Note: this is not doing a complete proper ROS image transport
00012 # publisher.  That doesn't support Python.  Instead, I'm publishing
00013 # directly on the /backdrop/compressed topic a
00014 # sensor_msgs/CompressedImage message, with the raw jpeg data just
00015 # loaded into it.  This way my python file doesn't have to decode or
00016 # convert the image data at all.  It does mean when you ask RViz for
00017 # the available image topics, this won't show up, you'll have to type
00018 # "/backdrop" directly into the topic field.  (RViz adds
00019 # "/compressed".)
00020 
00021 pub = rospy.Publisher( '/backdrop/compressed', CompressedImage )
00022 
00023 rospy.init_node( 'backdrop_node' )
00024 
00025 rate = rospy.Rate(1)
00026 
00027 dist = 3
00028 
00029 image = CompressedImage()
00030 image.header.frame_id = "/odom_combined"
00031 image.format = "jpeg"
00032 image.data = open( image_file ).read()
00033 
00034 while not rospy.is_shutdown():
00035 
00036     image.header.stamp = rospy.Time.now()
00037 
00038     pub.publish( image )
00039 
00040     print "published."
00041     rate.sleep()


rviz_backdrop
Author(s): Dave Hershberger
autogenerated on Thu Jun 6 2019 20:32:07