試了下源碼編譯ROS2菇绵,覺得vcstool用著不順手,就改成了用repo來同步代碼蔓纠, 熟悉vcstool的同學(xué)請?zhí)^1直接2帅矗。
1. 使用vcstool下載源碼
ROS2官方文檔
https://github.com/ros2/ros2/wiki/Linux-Development-Setup
中使用vcstool來下載和管理源碼,
下載時(shí)需要先取得一個(gè)repo列表文件(ros2.repos)科吭,再使用vcs-import src來同步:
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
vcs-import src < ros2.repos
如果要更新代碼昏滴,
https://github.com/ros2/ros2/wiki/Maintaining-a-Source-Checkout
需要下載一個(gè)新的repo列表文件(手動(dòng)保存以前的版本),
cd ~/ros2_ws
mv -i ros2.repos ros2.repos.old
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
再通過:
vcs custom --args remote update
同步本地repos,然后:
vcs import src < ros2.repos
vcs pull src
如果理解的沒有偏差对人,基本步驟應(yīng)該就是上面說的這樣谣殊。
但實(shí)際情況可能會(huì)出現(xiàn)以下的問題:
Could not checkout ref 'release-beta2': error: Your local changes to the following files would be overwritten by checkout:
推測可能是之前編譯的時(shí)候,源碼在編譯過程中(src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install)被修改了牺弄。
沒有去查vcs工具是否有命令統(tǒng)一 reset --hard , 但如果不想手動(dòng)一一reset --hard姻几,就只能rm -rf重新來過了:P
也可能vcstool有其他的優(yōu)點(diǎn)(還支持hg,bzr, repo只支持git),
但經(jīng)過目前嘗試的這些势告,頓時(shí)覺得某移動(dòng)系統(tǒng)的repo工具用起來方便些蛇捌。
看了下repo列表文件ros2.repos文件,截至目前beta2版本中的50個(gè)repo(包括其中兩個(gè)被注釋掉的)都是都在github上咱台,于是就有了想改成manifest的沖動(dòng)络拌。
2. 使用repo工具下載源碼
心動(dòng)不如行動(dòng),50個(gè)repo和某系統(tǒng)的幾百個(gè)相比改起來還是相對(duì)容易的回溺。
最終版本放在了github上:https://github.com/rosports/ros2/blob/beta2/default.xml
下面就可以用repo來同步代碼啦(目前只有最新beta2版本)
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
repo init -u https://github.com/rosports/ros2.git -b beta2
repo sync
同步完成后就可以來編譯了春贸,后面更新版本只需要repo sync就可以了(遠(yuǎn)端已更新manifest)。
cd ~/ros2_ws/
src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install
試了下遗遵,編譯沒有問題萍恕。其實(shí)編譯的過程是一樣的,只是下載代碼的方式不同而已瓮恭。
關(guān)于repo工具的使用雄坪,請自行度娘或G厘熟。
暫記于此屯蹦,如有疏漏或錯(cuò)誤,還望不吝指點(diǎn)绳姨。
歡迎來freenode IRC #ros-cn 頻道一起討論登澜。