从官网下载mavlink(git clone https://github.com/mavlink/mavlink.git)
然后进入mavlink 目录执行 git submodule update --init --recursive 下载全部子模块
在本目录下执行python -m mavgenerate 提示:
$ python -m mavgenerate
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line , in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line , in _run_code
exec code in run_globals
File "/home/ev/work/px4/mavlink/mavgenerate.py", line , in <module>
from pymavlink.generator import mavgen
File "pymavlink/generator/mavgen.py", line , in <module>
from future import standard_library
ImportError: No module named future
ev@Ev-Mayca:~/work/px4/mavlink$ python -m mavgenerate
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line , in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line , in _run_code
exec code in run_globals
File "/home/ev/work/px4/mavlink/mavgenerate.py", line , in <module>
from pymavlink.generator import mavgen
File "pymavlink/generator/mavgen.py", line , in <module>
from future import standard_library
ImportError: No module named future
提示没有future模块,解决方案如下
1、安装python3
sudo apt-get install python3
2、安装
sudo apt-get install python3-tk
3、安装pip3
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
4、执行
sudo pip3 install future
5、执行
python3 -m mavgenerate
6、选择xml文件、选择输出文件夹、选择语言,点击确定
xml选择mavlink/message_definitions/v1.0/common.xml
另外个输出文件夹随便选
语言根据需要选择
7、测试
gcc -I ../../new-mavlink/common/ -o mavlink_udp mavlink_udp.c
编译无错误
我是将输出文件放在mavlink文件夹下的new-mavlink文件夹中