Get HZ & BW from Node using Rostopic

asked 2019-10-28 05:50:44 -0600

acp gravatar image

Dear people. I am trying to get a PointCloud2 info, I have the following python node. The information from cloud2_msg works quite well, however I do not get any bandwidth info from rostopic.ROSTopicBandwidth and r.print_bw(). Any help is apprciate it :)

#! /usr/bin/env python

from sensor_msgs.msg import PointCloud2
from sensor_msgs import point_cloud2
import rospy, rostopic
import time

def Cloud_Callback(cloud2_msg):

    print "----------PointCloud2 Info-------- "
    print "PointCloud2_width       = %d \n" %(cloud2_msg.width)
    print "PointCloud2_height      = %d \n" %(cloud2_msg.height)
    print "PointCloud2_step        = %d \n" %(cloud2_msg.point_step)
    print "PointCloud2_row_step    = %d \n" %(cloud2_msg.row_step)
    print "PointCloud2_data_       = %d \n" %(cloud2_msg.row_step*cloud2_msg.height)

    r = rostopic.ROSTopicBandwidth('/zed/rtabmap/cloud_map')
    r.print_bw()

def main():
    rospy.init_node('pointcloud2_show_info', anonymous=True)
    rospy.Subscriber("/zed/rtabmap/cloud_map", PointCloud2, Cloud_Callback)
    rospy.spin()

if __name__ == "__main__":
    main()
edit retag flag offensive close merge delete

Comments

I don't think you should have this in the callback. There, you instantiate r, have it print the bw, and then r is "destructed" again.

You should rather instantiate r in the main (beneath the subscriber), e.g. and call print_bw from within a while loop in the main. Then you'll get some results.

mgruhler gravatar imagemgruhler ( 2019-10-28 07:19:45 -0600 )edit