一、安装ubuntu20.04
1.1、插入ubuntu20.04U盘启动盘,连续按F2进入BIOS界面,设置U盘启动;
1.2、在引导界面选择“ubuntu",按“e”进入编辑模式,找到''quite splash ---",删除“---”,添加“nomodeset”(nomodeset参数的作用是告诉内核不要加载显卡而用BIOS模式直到图形界面运行),按F10或CTRL+x进入ubuntu界面;
1.3、进入ubuntu安装界面,选择中文或英文,键盘布局选择Chinese,不连接网络,选择最小安装或完全安装,安装类型选择第一个选项,选择“现在安装”,市区选择“Shanghai”,设置用户名和密码,等待安装成功;
1.4、重启再拔下U盘。
1.5、在“Software & Updates” “Additional Drivers”标签下选择“nvidia-driver-520”,点击“Apply Changes” 安装显卡驱动;
1.6、换源
二、apt构建ros2 galactic
可参照官网:https://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Debians.html
2.1、添加ROS 2 GPG key
sudo apt update && sudo apt install curl
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
2.1.1、curl连接失败,解决办法:
- 解析raw.githubusercontent.com,复制粘贴到hosts文件末尾,保存并重启网络;
sudo gedit /etc/hosts
sudo /etc/init.d/networking restart
- 开启nscd服务缓存加速
sudo apt install nscd
sudo /etc/init.d/nscd start
- 配置代理,在.bashrc中添加以下内容,保存并source,其中端口号15732与设置->网络->Network Proxy保持一致:
alias proxy="export https_proxy=http://127.0.0.1:15732 http_proxy=http://127.0.0.1:15732 && curl ip.sb"
alias deproxy="unset http_proxy https_proxy all_proxy && echo proxy shutdown"
alias gitp="git config --global http.proxy http://127.0.0.1:15732 && git config --global https.proxy https://127.0.0.1:15732"
alias degitp="git config --global --unset http.proxy && git config --global --unset https.proxy"
- 打开终端,输入Proxy,重新curl。
2.2、add repository to sources list
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
2.3、install ROS2
sudo apt update
sudo apt upgrade
sudo apt install ros-galactic-desktop
2.4、设置环境变量
source /opt/ros/galactic/setup.bash
可以在.bashrc文件末尾加入source /opt/ros/galactic/setup.bash,保存,然后source ~/.bashrc。
三、配置Autoware.Universe
3.1、建立开发环境
3.1.1、clone
git clone https://github.com/autowarefoundation/autoware.git
cd autoware
解析github.com ,复制粘贴到hosts文件末尾,保存并重启网络;打开用“gitp”挂终端代理。
3.1.2、安装依赖项
使用脚本安装,执行下述命令。同样使用“proxy”挂终端代理,保证依赖项安装顺利。
./setup-dev-env.sh
3.2、构建工作空间
3.2.1、下载库
cd autoware
mkdir src
vcs import src < autoware.repos
3.2.2、安装ROS依赖
sudo pip install rosdepc
sudo rosdepc init
rosdepc update
source /opt/ros/galactic/setup.bash
rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
3.2.2.1、安装ros依赖报错
the following packages/stacks could not have their rosdep keys resolved to system dependencies
pacmod_interface: Cannot locate rosdep definition for [pacmod3_msgs]
解决办法:
sudo apt install apt-transport-https
sudo sh -c 'echo "deb [trusted=yes] https://s3.amazonaws.com/autonomoustuff-repo/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/autonomoustuff-public.list'
sudo apt update
rosdistro=galactic
sudo apt install ros-${rosdistro}-pacmod3
报错如下:
解决办法:
使用python3 -m pip install upgrade pip 更新pip。
3.2.3、编译autoware
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
- 注意事项:编译autoware需要很大的内存,需要给swap 扩容
# Optional: Check the current swapfile
free -h
# Remove the current swapfile
sudo swapoff /swapfile
sudo rm /swapfile
# Create a new swapfile
sudo fallocate -l 32G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Optional: Check if the change is reflected
free -h
- 如果编译过程中系统卡顿或者崩溃,一定不要强制关机,解决办法:
CTRL+c结束编译,一定要使用安全重启命令:同时按住CTRL和ALT不放,按一下PRTSC(SYSRQ),按一下R、按一下E、依次按下I、S、U、B;
- 内存不足,解决办法:
CTRL+ALT+F1~F6进入tty终端,使用系统账号和密码登陆,使用free -h指令查看系统分区使用情况,发现swap耗尽,写shell脚本查看swap分区被哪些进程占用,用kill -9 xxxx结束进程。
do_swap () {
SUM=0
OVERALL=0
#获取进程目录
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
#获取进程PID
PID=`echo $DIR | cut -d / -f 3`
#获取进程名称
PROGNAME=`ps -p $PID -o comm --no-headers`
#获取进程的所有分区中SWAP值
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
do
#进程swap值求和
let SUM=$SUM+$SWAP
done
echo "PID=$PID - Swap used: $SUM - $PROGNAME"
#总共swap分区值求和
let OVERALL=$OVERALL+$SUM
SUM=0
done
echo "Overall swap used: $OVERALL"
}
do_swap > tmp.txt
#查询结果排序并截取top10
cat tmp.txt |awk -F[\ \(] '{print $5,$1,$7}' | sort -n | tail -10
cat tmp.txt |tail -1
rm -rf tmp.txt
- pip install出错,解决办法:
镜像安装,清华大学镜像地址:https://pypi.tuna.tsinghua.edu.cn/simple,“-i 网址”就能切换到指定下载地址。
pip install gdown -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
四、安装vscode
4.1、下载安装文件,网址:Download Visual Studio Code - Mac, Linux, Windows
4.2、进入下载文件所在文件夹,使用命令sudo apt install ./xxxxx.deb
4.3、sudo apt update