38 from geometry_msgs.msg
import Point
39 from usv_msgs.msg
import RangeBearing
40 from visualization_msgs.msg
import Marker
42 """@package pinger_visualisation.py 43 This node takes a RangeBearing message and produces a corresponding Marker 44 message suitable for use with rviz. 49 """Class used to store the parameters and variables for the script. 52 """Initialise and run the class.""" 53 rospy.init_node(
"pinger_visualisation")
56 self.
markerPub = rospy.Publisher(
"/wamv/sensors/pingers/pinger/marker/signal", Marker,
57 queue_size=10, latch=
True)
60 self.
pingerSub = rospy.Subscriber(
"/wamv/sensors/pingers/pinger/range_bearing",
68 """Callback to handle receipt of a RangeBearing message.""" 75 visMsg.header.frame_id = msg.header.frame_id
76 visMsg.header.stamp = msg.header.stamp
81 visMsg.type = Marker.ARROW
82 visMsg.action = Marker.ADD
85 visMsg.pose.position.x = 0
86 visMsg.pose.position.y = 0
87 visMsg.pose.position.z = 0
88 visMsg.pose.orientation.x = 0.0
89 visMsg.pose.orientation.y = 0.0
90 visMsg.pose.orientation.z = 0.0
91 visMsg.pose.orientation.w = 1.0
111 visMsg.points.append(startPoint)
115 endPoint.x = msg.range*math.cos(msg.elevation)*math.cos(msg.bearing)
116 endPoint.y = msg.range*math.cos(msg.elevation)*math.sin(msg.bearing)
117 endPoint.z = msg.range*math.sin(msg.elevation)
118 visMsg.points.append(endPoint)
121 self.markerPub.publish(visMsg)
124 if __name__ ==
'__main__':
def pingerCallback(self, msg)