2

我遇到了一个问题,当无人机使用 ardrone_autonomy ardrone.launch 通过 ROS 连接时,我无法连接到 AR Drone 2 摄像头。

我认为问题是由于我在通过 ardrone_autonomy 连接时尝试使用 OpenCV 和 Python 通过 IP 地址访问无人机摄像头。下面是我如何完成此操作的代码片段。

video_capture = cv2.VideoCapture()

video_capture.open('tcp://192.168.1.1:5555')

vidWidth = video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)

vidHeight = video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT)

如您所见,我正在使用摄像机的 IP 地址。当无人机没有通过本质上类似于网络摄像头的 ROS 连接时,这非常有效。

我的最终目标是通过使用 OpenCV 从相机接收到的图像进行跟踪和导航,这意味着我必须发出移动命令(cmd_vel),这需要根据 OpenCV 接收和处理的图像通过 ardrone_autonomy 进行连接。

无论如何,我可以在连接到 ROS 的同时使用无人机上的 IP 摄像头来实现这一点吗?

谢谢你的帮助!

4

1 回答 1

1

http://wiki.ros.org/video_stream_opencv可以从 HTTP/TCP URL 打开视频流:

<launch>  <!-- video stream from URL to ROS topic - see http://wiki.ros.org/video_stream_opencv  -->
   <include file="$(find video_stream_opencv)/launch/camera.launch" >        
        <arg name="camera_name" value="drone_webcam" /> <!-- node name and ros graph name -->        
        <arg name="video_stream_provider" value="http://192.168.1.227:8080/video?x.mjpeg" /> <!-- ?x.mjpeg see http://answers.opencv.org/question/13139/cvvideocapture-works-for-webcams-but-not-ip-cameras/ --> 
        <arg name="fps" value="10" /><!-- throttling the querying of frames to 10Hz -->        
        <arg name="frame_id" value="webcam" /> <!-- setting TF frame_id -->         
        <arg name="camera_info_url" value="file:///abc/xyz.yaml" /> <!-- camera info loading, take care as it needs the "file:///" at the start , e.g.:
        "file:///$(find your_camera_package)/config/your_camera.yaml" -->        
        <arg name="flip_horizontal" value="false" /> <!-- flip the image horizontally (mirror it) -->
        <arg name="flip_vertical" value="false" /> <!-- flip the image vertically -->        
        <arg name="visualize" value="true" /> <!-- visualize on an image_view window the stream generated -->
   </include>
</launch>

请注意/video?x.mjpegURL 末尾的 。

于 2016-12-05T17:20:32.403 回答