解决rosdep init 以及 rosdep update因(网络原因)失败或超时

参考资料
解决ROS系统 rosdep update超时问题的新方法
主要原理为在rosdep相关脚本中添加代理网址从根源上解决无法初始化和更新的问题

#!/usr/bin/env bash

GHPROXY='https:\/\/gh-proxy.com\/'
# 1
if [ -f /usr/lib/python3/dist-packages/rosdep2/sources_list.py.bak ]; then
	echo "PASS to EXIT!!!!!!"
	exit 0
else

	sudo cp -rvf /usr/lib/python3/dist-packages/rosdep2/sources_list.py \
	             /usr/lib/python3/dist-packages/rosdep2/sources_list.py.bak

	sudo sed -i "301s/^/        url=\"${GHPROXY}\"+url\n/" \
		/usr/lib/python3/dist-packages/rosdep2/sources_list.py
fi


# 2
sudo sed -i "68s/https:\/\//${GHPROXY}/" \
	/usr/lib/python3/dist-packages/rosdistro/__init__.py


# 3
sudo sed -i "34s/https:\/\//${GHPROXY}/" \
	/usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py


# 4
sudo sed -i "64s/https:\/\//${GHPROXY}/" \
	/usr/lib/python3/dist-packages/rosdep2/sources_list.py


# 5
sudo sed -i "36s/https:\/\//${GHPROXY}/" \
	/usr/lib/python3/dist-packages/rosdep2/rep3.py


# 6
sudo sed -i "68s/https:\/\//${GHPROXY}/" \
	/usr/lib/python3/dist-packages/rosdistro/manifest_provider/github.py

sudo sed -i "119s/https:\/\//${GHPROXY}/" \
	/usr/lib/python3/dist-packages/rosdistro/manifest_provider/github.py

# 7
sudo sed -i "202s/^/        gbpdistro_url=\"${GHPROXY}\"+gbpdistro_url\n/" \
	/usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py

你可能感兴趣的:(机器人)