ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

roboearth detection_result listener

asked 2011-11-27 09:12:52 -0500

Sudarshan gravatar image


I am trying to write a Python program to listen the detection_results topic that is published by re_kinect_object_detector based on this tutorial. However, the datatype of the topics that I am subscribing to and the ones published do not seem to match up. I have tried different types after going through re_msgs and the auto-generated in re_kinect_object_detector but nothing seems to work. Here is my code:

#!/usr/bin/env python

import roslib; roslib.load_manifest('kinect_object_tracker')
import rospy
import re_kinect_object_detector

def callback(data):
    print "Got something"
    #rospy.loginfo(rospy.get_name() + "I heard %s",

def listener():
    rospy.Subscriber("re_kinect/detection_results", re_kinect_object_detector.DetectionResult, callback)

if __name__ == '__main__':

When I run this node, I get an error saying that DetectionResult is not a module in re_kinect_object_detector. I tried using DetectedObject from re_msgs but then re_kinect_object_detector gave me a red colored error saying:

[ERROR] [1322431132.952748877]: Client [/getObjectPose] wants topic /re_kinect/detection_results to have datatype/md5sum [re_msgs/DetectedObject/fbf421ad7ea115e18f287b539c57644a], but our version has [re_kinect_object_detector/DetectionResult/49fd3ba0170db3e28d61de95d1d6d5c8]. Dropping connection.

My question is, what is the type that I need to pass in the Subscriber call for getting the detection_results.

Thanks for your help!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-11-27 17:35:03 -0500

fergs gravatar image

Message definitions are found under a "package.msg.X" namespace, so:

import re_kinect_object_detector.msg


rospy.Subscriber("re_kinect/detection_results", re_kinect_object_detector.msg.DetectionResult, callback)
edit flag offensive delete link more

answered 2011-11-27 21:45:47 -0500

Sudarshan gravatar image

Thank you. I was able to get the DetectionResult object using your suggestion. The detection result is made up of 3 items: the Image, list of ObjectNames and list of DetectedObject called detections. I was able to print all three. The detectedObject is made up of the following:

# Information of object detected in an image by re_vision

# detected points in the image
Pixel[] points2d
# detected 3d points in the camera reference
geometry_msgs/Point[] points3d
# pose of the object in the camera reference
geometry_msgs/Pose pose
# detected 3d points in the model reference
geometry_msgs/Point[] points3d_model

Basically if I print data.Detections, I get each of those items in a nicely formated output. But I am not sure how to get access to those individual items. Example output:

    x: 394
    y: 49
    x: 395
    y: 49
    x: 387
    y: 48
    x: 0.0817023143172
    y: -0.208500802517
    z: 0.573309779167
    x: 0.082595653832
    y: -0.208231449127
    z: 0.573092222214
    x: 0.0
    y: 0.0
    z: 0.0
    x: 0.0
    y: 0.0
    z: 0.0
    w: 0.0
points3d_model: []%

I would like to get access to individual points2d, points3d, pose, points3d_model. When I tried print data.Detections.points2d, I got an error saying that the list detections does not have a attribute points2d. So how would I go about accessing those items? I was thinking if its a string I would have to parse it with some sort of regex to get the x's, y's etc but I might complicating it too much.

Thanks for your help!

edit flag offensive delete link more


Detections is an array of "DetectedObject" messages. Try printing e.g. data.Detections[0].points2d.
ddimarco gravatar image ddimarco  ( 2011-11-27 22:30:44 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-11-27 09:12:52 -0500

Seen: 275 times

Last updated: Nov 27 '11