Ubuntu18下安装ROS1&2

817
0
2020年7月8日 09时00分

记录下在Ubuntu18中同时安装ROS1&2的主要步骤以及一些小问题,之后遇到新的问题会更新

ROS Melodic

安装源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

安装ros-melodic-desktop-full

sudo apt update
sudo apt install ros-melodic-desktop-full

(可能会遇到没有rosdep的情况,安装即可)

sudo apt install python-rosdep

修改host文件以提高update的成功率

sudo nano /etc/hosts
199.232.28.133 raw.githubusercontent.com

初始化

sudo rosdep init
rosdep update

环境变量

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

其他依赖

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

ROS Dashing

语言环境

sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

安装源

sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://mirror.tuna.tsinghua.edu.cn/ros2/ubuntu/ bionic main" > /etc/apt/sources.list.d/ros2-latest.list'

安装ros-dashing-desktop

sudo apt update
sudo apt install ros-dashing-desktop

(添加ros2软件源后,update出现类似“N: Skipping acquire of configured file ‘main/binary-i386/Packages’ as repository ‘http://packages.ros.org/ros2/ubuntu bionic InRelease’ doesn’t support architecture ‘i386’”报错的解决办法)

sudo nano /etc/apt/sources.list.d/ros2-latest.list
deb http://packages.ros.org/ros2/ubuntu bionic main  
#改为  
deb [arch=amd64] http://packages.ros.org/ros2/ubuntu bionic main
sudo apt update

环境变量

echo "source /opt/ros/dashing/setup.bash" >> ~/.bashrc
source ~/.bashrc

其他依赖

sudo apt install python3-argcomplete ros-dashing-rmw-opensplice-cpp ros-dashing-rmw-connext-cpp ros-dashing-ros1-bridge python3-colcon-common-extensions

环境变量

使用张瑞雷老师的bash脚本,开启bash时手动选择ROS版本

修改~/.bashrc如下

#source /opt/ros/melodic/setup.bash
#source /opt/ros/dashing/setup.bash
# ROS 1.0 melodic or ROS 2.0 Dashing
echo ROS 1.0 or ROS 2.0? 1=Melodic 2=Dashing 
read ROS
if (($ROS==1));then
source /opt/ros/melodic/setup.bash
echo "Melodic"
elif (($ROS==2));then
source /opt/ros/dashing/setup.bash
echo "Dashing"
else
echo "Non-ROS"
fi

参考链接:

https://blog.csdn.net/feimeng116/article/details/106602562
https://blog.csdn.net/ZhangRelay/article/details/103868465

发表评论

后才能评论