From ceed6b16972156f6b80d28a8fd27092a479f1b73 Mon Sep 17 00:00:00 2001 From: Wataru Kawai Date: Mon, 9 Oct 2017 17:12:23 +0900 Subject: [PATCH] created visualize_marker.py created visualize_marker.py to visualize tracking marker --- .../scripts/visualize_marker.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dxl_armed_turtlebot/scripts/visualize_marker.py diff --git a/dxl_armed_turtlebot/scripts/visualize_marker.py b/dxl_armed_turtlebot/scripts/visualize_marker.py new file mode 100644 index 00000000..b738e157 --- /dev/null +++ b/dxl_armed_turtlebot/scripts/visualize_marker.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +# import rospy module (ROS client library) +import rospy + +# import opencv_apps.msg.RotatedRectStamped class +from opencv_apps.msg import RotatedRectStamped + +# import image_view2.msg.ImageMarker2 class +from image_view2.msg import ImageMarker2 + +# import geometry_msgs.msg.Point class +from geometry_msgs.msg import Point + + +def cb(msg): + ''' + Callback function called when received message from topic '/camshift/track_box' + + parameters: + msg: ROS message + returns: + None + ''' + + # print information of marker + print msg.rect + + # instantiate ImageMarker2 object + marker = ImageMarker2() + + # set markers value + marker.type = 0 + marker.position = Point(msg.rect.center.x, msg.rect.center.y, 0) + + # publish marker message to ROS node + pub.publish(marker) + + +# register client node with name 'client' +rospy.init_node('client') + +# register as subscriber to topic '/camshift/track_box' with data class of message and callback function +rospy.Subscriber('/camshift/track_box', RotatedRectStamped, cb) + +# register as a publisher of ROS topic with data class of message +pub = rospy.Publisher('/image_marker', ImageMarker2) + +# blocks until ROS node is shutdown +rospy.spin()