ArduPilot问题解决方式

写在前面

这个文章并非自己的原创,但要想看到这篇文章的原创要在外网才看得见。因此我决定把它搬运到这里,如果有侵犯,立删。以上。

一.错误集合

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 patch
Call 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_gen
gmake: *** 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_pkg


On MacOS please run:
 sudo pip install empy catkin_pkg


On 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' failed
CMakeFiles/Makefile2:2353: recipe for target 'src/firmware/nuttx/CMakeFiles/romfs.dir/all' failed
CMakeFiles/Makefile2:2466: recipe for target 'src/firmware/nuttx/CMakeFiles/build_firmware_px4fmu-v2.dir/rule' failed
Makefile:925: recipe for target 'build_firmware_px4fmu-v2' failed
Traceback (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.git
cd ardupilot
git 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 status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
[root@localhost ardupilot]# touch newfile && git add newfile
&& git status
On branch master
Your 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 HEAD
diff --git a/newfile b/newfile
new file mode 100644
index 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 image
stdout = 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("{😒}\nre:{😒}\n{😒}".format(
e, re_string, stdout))
except IndexError as e:
group0 = size_match.group(0)
raise RuntimeError("{😒}\ngroup 0:{😒}\n{😒}".format(
e, group0, stdout))

三:問題解決

使用官方指定的交叉編譯工具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
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值