how to use massage type information [closed]

asked 2019-08-26 02:50:24 -0500

updated 2019-08-26 03:43:06 -0500

gvdhoorn gravatar image

the code is:

import rospy
from std_msgs.msg import String , Header
from vision_msgs.msg import Detection2D, Detection2DArray, ObjectHypothesisWithPose
import object_detection

def trcakcallback(detections):
    #rospy.loginfo(detections.header.frame_id)
    rospy.loginfo(detections.results.id)    

def main():
    rospy.init_node('track_node')
    rospy.Subscriber("/objects",Detection2DArray, trcakcallback)
    rospy.spin()   

if __name__ == '__main__':
    main()

I want to publish the information about topic /objects . When i try to use rospy.loginfo(detections.header.frame_id) ,it works. But when i use rospy.loginfo(detections.results.id), it fails.

the massage vision_msgs/Detection2DArray type is:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
vision_msgs/Detection2D[] detections
  std_msgs/Header header
    uint32 seq
    time stamp
    string frame_id
  vision_msgs/ObjectHypothesisWithPose[] results
    string id
    float64 score
    geometry_msgs/PoseWithCovariance pose
      geometry_msgs/Pose pose
        geometry_msgs/Point position
          float64 x
          float64 y
          float64 z
        geometry_msgs/Quaternion orientation
          float64 x
          float64 y
          float64 z
          float64 w
      float64[36] covariance
  vision_msgs/BoundingBox2D bbox
    geometry_msgs/Pose2D center
      float64 x
      float64 y
      float64 theta
    float64 size_x
    float64 size_y
  sensor_msgs/Image source_img
    std_msgs/Header header
      uint32 seq
      time stamp
      string frame_id
    uint32 height
    uint32 width
    string encoding
    uint8 is_bigendian
    uint32 step
    uint8[] data
  bool is_tracking
  string tracking_id

i want to know how to use the massage type information .

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by kylin073
close date 2019-09-01 07:40:51.493805