Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 from math import degrees, radians
00036
00037
00038
00039 import rospy
00040 from tf import TransformBroadcaster
00041
00042 from visualization_msgs.msg import Marker, MarkerArray
00043
00044 from starmac_roslib.timers import Timer
00045
00046
00047 class VizModuleBase(object):
00048 """
00049 Abstract Base Class
00050
00051 Visualization modules should inherit from this class.
00052 """
00053
00054 latest_odom = None
00055 latest_controller_status = None
00056 modules = {}
00057 mpub = None
00058 mapub = None
00059 tfbr = None
00060
00061 def __init__(self, id=""):
00062 self.id = id
00063 if id in VizModuleBase.modules:
00064 raise Error("Visualization module with id '%s' already exists" % id)
00065 VizModuleBase.modules[id] = self
00066 self.init_params()
00067 self.init_publishers()
00068 self.init_vars()
00069 self.init_viz()
00070 self.init_subscribers()
00071 self.init_timers()
00072
00073 def init_params(self):
00074 self.publish_freq = rospy.get_param("~publish_freq", 15.0)
00075 self.subscriber_topic_prefix = rospy.get_param("~subscriber_topic_prefix", 'downlink/')
00076
00077 def init_timers(self):
00078 self.publish_timer = Timer(rospy.Duration(1/self.publish_freq), self.publish_timer_callback)
00079
00080 def init_publishers(self):
00081 VizModuleBase.mpub = rospy.Publisher('flyer_viz', Marker)
00082 VizModuleBase.mapub = rospy.Publisher('flyer_viz_array', MarkerArray)
00083 VizModuleBase.tfbr = TransformBroadcaster()
00084
00085 def publish(self, stamp):
00086 self.mg.publish(stamp)
00087
00088
00089 def init_vars(self):
00090 raise NotImplementedError
00091
00092 def init_viz(self):
00093 raise NotImplementedError
00094
00095 def init_subscribers(self):
00096 raise NotImplementedError
00097
00098 def publish_timer_callback(self, event):
00099 raise NotImplementedError
00100
00101
00102
00103