pixhawk2.1之ArduPilot编译遇到各种问题

来源:互联网 发布:什么叫顶级域名 编辑:程序博客网 时间:2024/06/09 21:23

一:错误集合

 super(px4, self).configure_env(cfg, env) File "Tools/ardupilotwaf/boards.py", line 182, in configure_env cfg.srcnode.find_dir('modules/uavcan/libuavcan/include').abspath()AttributeError: 'NoneType' object has no attribute 'abspath'

   这个错误不熟悉python的人还真有点懵,实际上就是modules/uavcan/libuavcan/include目录没有找到,返回空nonetype

所以自然没有abspath的method。后面会有补充,如果用git clone 的虽然是主体分支,但是有些文件依然没有文件。是空

目录。后面会补充git submodule的知识。

  Waf: Leaving directory `/Users/bonney/dev_src/ardupilot/build/px4-v2'Build failed -> task in 'mavlink' failed (exit status 1): {task 4325797232: mavgen ardupilotmega.xml -> }
    使用pip install future lxml
  -- Configuring incomplete, errors occurred!CMake Error at cmake/toolchains/Toolchain-arm-none-eabi.cmake:62 (message):  could not find patchCall Stack (most recent call first):  /usr/share/cmake/Modules/CMakeDetermineSystem.cmake:98 (include)  CMakeLists.txt:204 (project)CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage[ 9/14] PX4: Copying rc.APM to px4-extra-files/ROMFS/init.d/rc.APM[10/14] PX4: Copying rc.error to px4-extra-files/ROMFS/init.d/rc.error[11/14] PX4: Copying rcS to px4-extra-files/ROMFS/init.d/rcS[12/14] PX4: Copying px4fmuv2_bl.bin to px4-extra-files/ROMFS/bootloader/fmu_bl.bin[13/14] CMake Build px4 msg_gengmake: *** No rule to make target 'msg_gen'.  Stop.Waf: Leaving directory `/root/dhuang/ardupilot/build/px4-v2'Build failed -> task in 'px4_msg_gen' failed (exit status 2):         {task 139857228209840: cmake_build_task  -> }
      没有装patch,yum install patch
CMake Error at cmake/toolchains/Toolchain-arm-none-eabi.cmake:62 (message):  could not find genromfs
      没有装genromfs, yum isntall genromfs
python import error:  No module named em Required python packages not installed.On a Debian/Ubuntu system please run:  sudo apt-get install python-empy  sudo pip install catkin_pkgOn MacOS please run:  sudo pip install empy catkin_pkgOn Windows please run:  easy_install empy catkin_pkg
        英文解释比较清楚,没有装python相关库,使用yum install python-empy,接着pip install catkin_pkg
src/firmware/nuttx/CMakeFiles/romfs.dir/build.make:64: recipe for target 'src/firmware/nuttx/romfs.o' failedCMakeFiles/Makefile2:2353: recipe for target 'src/firmware/nuttx/CMakeFiles/romfs.dir/all' failedCMakeFiles/Makefile2:2466: recipe for target 'src/firmware/nuttx/CMakeFiles/build_firmware_px4fmu-v2.dir/rule' failedMakefile:925: recipe for target 'build_firmware_px4fmu-v2' failedTraceback (most recent call last):  File "/root/dhuang/ardupilot/modules/PX4Firmware/cmake/nuttx/bin_to_obj.py", line 68, in <module>    e, re_string, stdout))RuntimeError: 'NoneType' object has no attribute 'group're:^([0-9A-Fa-f]+) .*_binary_romfs_bin_size 

         将在第二部分定位问题

二:错误相关的知识点学习

        2.1 Git submodule                   

Git submodules allow us to automatically bring in dependent git trees in the ArduPilot build. It replaces our old mechanism of having to separately clone the ArduPilot/PX4Firmware and ArduPilot/PX4NuttX tree when developers want to build for PX4 targets.
                   子模块的作用是对于一些公用repo,代替了以前我们手动一个一个git clone到我们project的我们想要的位置,而自动去做这些事情             
The approach we have implemented in ArduPilot is to use a single level of git submodules, with all modules stored in the modules/ directory. This approach was chosen as it makes for diagnosis of issues with submodules somewhat simpler.This means that the submodules from the upstream PX4Firmware tree are not used. Instead each required submodule is added as a direct submodule of the ArduPilot tree.You may also note that the URLs used for the submodules use the old git:// protocol. This was done to make it less likely we will get accidental commits on the master repositories while developers are getting used to git submodules (as the git:// protocol is read-only). Developers with commit access to the submodules should add a new ardupilot remote with a writeable protocol as needed.
                     ardupilot的git tree,把子模块放在modules里面,而其当你在Git clone https://github.com/ArduPilot/ardupilot.git,子模块是没有clone进来的
                  2.1.1 正确的使用方式          
git clone https://github.com/ArduPilot/ardupilot.gitcd ardupilotgit submodule update --init --recursive
                        问题: git  diff head 是本地和远程库的修改对比吗?
                        答:
git diff [--options] <commit> [--] [<path>…​]This form is to view the changes you have in your working tree relative to the named <commit>. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.
                          简单测试:
[root@localhost ardupilot]# git statusOn branch masterYour branch is up-to-date with 'origin/master'.nothing to commit, working tree clean[root@localhost ardupilot]# touch newfile && git add newfile && git statusOn branch masterYour branch is up-to-date with 'origin/master'.Changes to be committed:  (use "git reset HEAD <file>..." to unstage)        new file:   newfile[root@localhost ardupilot]# git diff HEADdiff --git a/newfile b/newfilenew file mode 100644index 0000000..e69de29
                           应该是和本地stage area做比较,change 没有stage的时候git diff HEAD也是没有任何输出的。而HEAD此时
指向最新的commit。和git diff --cached 效果一样,是为了确认staged 而没有commit的change和最近的一次commit或者
指定commit的区别。

        2.2 python re模块基本学习

                           看下pyhton中re正则模块的用法:
re.search(pattern, string, flags=0)Scan through string looking for the first location where the regular expression pattern produces a match, and return a corresponding match object. Return None if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string.
                           截取出来/root/..../bin_to_obj.py的68行前后上下文
# get size of imagestdout = run_cmd("{nm:s} -p --radix=x {obj:s}.bin.o", locals())re_string = r"^([0-9A-Fa-f]+) .*{sym:s}_size".format(**locals())re_size = re.compile(re_string, re.MULTILINE)size_match = re.search(re_size, stdout.decode())try:    size = size_match.group(1)except AttributeError as e:    raise RuntimeError("{:s}\nre:{:s}\n{:s}".format(        e, re_string, stdout))except IndexError as e:    group0 = size_match.group(0)    raise RuntimeError("{:s}\ngroup 0:{:s}\n{:s}".format(        e, group0, stdout))
                         这个牵扯到的Python内容较多,需要从头追溯,非一蹴而就。先留下来

三:问题解决

          使用官方指定的交叉编译工具http://firmware.ap.ardupilot.org/Tools/PX4-tools/
          解压缩,并修改个人登录配置文件,source .bashrc使生效,就是添加环境变量。
          更具体的官网都有,不在赘述
          http://ardupilot.org/dev/docs/building-px4-for-linux-with-make.html#building-px4-for-linux-with-make
          交叉编译工具版本不同都可能导致失败,并非越新的工具越好。

0 0
原创粉丝点击