Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created visualize_marker.py #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions dxl_armed_turtlebot/scripts/visualize_marker.py
Original file line number Diff line number Diff line change
@@ -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()