问题描述
我正在docker容器中使用dronekit-python,并尝试使用以下命令连接到在我的主机(Mac OSX)上运行的MAVProxy实例:
I am using dronekit-python in a docker container and am attempting to connect to an instance of MAVProxy running on my host machine (Mac OSX) using the following command:
vehicle = connect('udp:host.docker.internal:14551', wait_ready=True)
但出现以下错误:
File "/usr/local/lib/python3.7/site-packages/pymavlink/mavutil.py", line 1015, in __init__
self.port.bind((a[0], int(a[1])))
OSError: [Errno 99] Cannot assign requested address
有人知道这里的问题吗?我可以在主机上本地运行python脚本时使用上述命令成功连接,但是当我在docker容器中运行python脚本时无法连接.
Does anyone know what the issue is here? I am able to successfully connect using the above command when I run the python script locally on host but not when I have it running in a docker container.
我在此处找到了类似的stackoverflow问题,但是接受的答案对我不起作用.不知道我是否需要公开端口或类似的东西.
I found a similar stackoverflow question here but the accepted answer did not work for me. Not sure if I need to be exposing ports or something like that.
这是我在主机上运行的启动MAVProxy的命令: mavproxy.py --master = 127.0.0.1:14550 --out udp:127.0.0.1:14551 --out udp:10.55.222.120:14550 --out udp:127.0.0.1:14552
Here is the command that I am running on my host machine to kick off MAVProxy:mavproxy.py --master=127.0.0.1:14550 --out udp:127.0.0.1:14551 --out udp:10.55.222.120:14550 --out udp:127.0.0.1:14552
推荐答案
我最终在主机上正确安装了MAVProxy,并正确连接了docker flask容器中的dronekit-python.
I ended up getting MAVProxy on host and dronekit-python in the docker flask container properly connected.
在此 gitter线程中Seemus790的答案就可以解决问题.
Seemus790's answer in this gitter thread did the trick.
工作解决方案:主机上的MAVProxy(在我的情况下为Mac OS)
Working solution:MAVProxy on host machine (Mac OS in my case)
mavproxy.py --master=127.0.0.1:14550 --out udp:127.0.0.1:14551 --out udp:10.55.222.120:14550 --out=tcpin:0.0.0.0:14552
docker容器中的
dronekit-python命令:
dronekit-python command in docker container:
vehicle = connect('tcp:host.docker.internal:14552', wait_ready=True)
诀窍是mavproxy命令的--out = tcpin:0.0.0.0:14552部分,已记录在此处
The trick was the --out=tcpin:0.0.0.0:14552 part of the mavproxy command which is documented here
这篇关于在docker中运行的Dronekit-python连接到主机上的MAVProxy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!