日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ROS消息格式-vision_msgs/Detection2DArray (后续创作中...)

發布時間:2024/4/18 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ROS消息格式-vision_msgs/Detection2DArray (后续创作中...) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. 終端中查看消息格式
? ~ rosmsg show vision_msgs/Detection2DArray std_msgs/Header header uint32 seqtime stampstring frame_id vision_msgs/Detection2D[] detectionsstd_msgs/Header headeruint32 seqtime stampstring frame_idvision_msgs/ObjectHypothesisWithPose[] resultsint64 idfloat64 scoregeometry_msgs/PoseWithCovariance posegeometry_msgs/Pose posegeometry_msgs/Point positionfloat64 xfloat64 yfloat64 zgeometry_msgs/Quaternion orientationfloat64 xfloat64 yfloat64 zfloat64 wfloat64[36] covariancevision_msgs/BoundingBox2D bboxgeometry_msgs/Pose2D centerfloat64 xfloat64 yfloat64 thetafloat64 size_xfloat64 size_ysensor_msgs/Image source_imgstd_msgs/Header headeruint32 seqtime stampstring frame_iduint32 heightuint32 widthstring encodinguint8 is_bigendianuint32 stepuint8[] data
2. 變量含義解讀:
Detection2DArray
# A list of 2D detections, for a multi-object 2D detector.Header header# A list of the detected proposals. A multi-proposal detector might generate # this list with many candidate detections generated from a single input. Detection2D[] detections
Detection2D[] detections
#Defines a 2D detection result. # #This is similar to a 2D classification, but includes position information, #allowing a classification result for a specific crop or image point to #to be located in the larger image.Header header#Class probabilities ObjectHypothesisWithPose[] results#2D bounding box surrounding the object. BoundingBox2D bbox#The 2D data that generated these results (i.e. region proposal cropped out of #the image). Not required for all use cases, so it may be empty. sensor_msgs/Image source_img

參考文檔:http://docs.ros.org/api/vision_msgs/html/msg/Detection2DArray.html/

3. 代碼實戰:(基于Python,實現一個簡單的人臉檢測):
3.1:訂閱話題
def main():rospy.init_node('track_node')rospy.Subscriber("/objects",Detection2DArray, trcakcallback)rospy.spin()

這里訂閱了"/object話題",從tensorflow相關節點中,獲得圖片信息,作為ROS的消息進行傳送PS:
2. 這里使用ROS信息傳輸,非常占用本地帶寬.雖然沒有上傳到云端.
3. 這里沒有使用基于MIT-Racecar的模擬環境,但是可以想象,一秒三四十兆的上傳和下載速率.同時開啟gazebo模擬激光雷達和相機節點,還有模擬小車模型及運動,以及目標檢測相關節點,就已經讓我的電腦變得十分卡慢了

3.2: 回調函數
#控制臺輸出速度和轉向參數 def vels(speed,turn):return "currently:\tspeed[ %s ]\tturn[ %s ]" % (speed,turn)def Add_vels(speed_add_once,turn_add_once):return "AddOnce:\tSpeed[ %s ]\tTurn[ %s ]" % (speed_add_once,turn_add_once)def trcakcallback(_msg_): rospy.loginfo("=========Msgs=========") rospy.loginfo(_msg_.header.seq) rospy.loginfo(_msg_.detections[-1].header.frame_id) rospy.loginfo(_msg_.detections[-1].results[-1].id) re_id = _msg_.detections[-1].results[-1].id;rospy.loginfo(_msg_.detections[-1].bbox) rospy.loginfo("=========Control=========") if(re_id == "1"):control_speed=(_msg_.detections[-1].bbox.size_x-550)/300control_turn=(_msg_.detections[-1].bbox.center.x-250)/90else:print("NO--------------------1")control_speed=0control_turn=0rospy.loginfo(control_speed) rospy.loginfo(control_turn) pub = rospy.Publisher('/cmd_vel', Twist, queue_size=5)# 創建并發布twist消息twist = Twist()twist.linear.x = control_speed; twist.linear.y = 0; twist.linear.z = 0twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = control_turnpub.publish(twist)

注意: 這里獲得的數據格式是"字符串"型的,而不是簡單的整數型.
函數說明: 簡單的獲得目標檢測結果,根據目標的位置以及框的大小控制小車運動

總結

以上是生活随笔為你收集整理的ROS消息格式-vision_msgs/Detection2DArray (后续创作中...)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。