I'm writing a python script to run with darknet_ros and bebop_autonomy package in order to take the bounding boxes of the detected objects and depending on the position of the detected objects send different flight commands (takeoff, landing, ecc) by using if elif statement.
I'm struggling as I don't know how to take the published data from darknet_ros topic (list with detected objects coordinates) and use it in the python script.
Do you have any suggestion on how to do this?
import rospy
from sensor_msgs.msg import Image
from darknet_ros_msgs.msg import BoundingBoxes
from std_msgs.msg import Header
from std_msgs.msg import String
def callback(data):
rospy.loginfo(rospy.get_caller_id() + 'I heard %s', data.data)
def main():
while not rospy.is_shutdown():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber('/darknet_ros/bounding_boxes', BoundingBoxes , callback)
rospy.spin()
if __name__ == '__main__':
try :
main()
except rospy.ROSInterruptException:
pass