ubuntu18.04 安装ros2教程及环境配置
ros2学习
·
ubuntu18.04 安装ros2教程及环境配置
1. ros2安装
1.1添加ros2 软件源
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 [arch=amd64] http://packages.ros.org/ros2/ubuntu bionic main" > /etc/apt/sources.list.d/ros2-latest.list'
执行第二句时报错:gpg: no valid OpenPGP data found
解决办法:上述命令中有管道符号,curl是个类似下载的命令,因此尝试将上述命令分开两步执行
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc
sudo apt-key add ros.asc
第三句相比官网做了修改,避免后面链接国外源失败的情况
1.2安装ros-eloquent和相关依赖
sudo apt update
sudo apt install ros-eloquent-desktop
1.3安装python3库
sudo apt install -y libpython3-dev python3-pip
pip3 install -U argcomplete
1.4环境变量设置
- ROS2单独存在
echo "source /opt/ros/eloquent/setup.bash" >> ~/.bashrc
source ~/.bashrc
- ROS1和ROS2共存
echo "ros melodic(1) or ros2 dashing(2)?"
read edition
if [ "$edition" -eq "1" ];then
source /opt/ros/melodic/setup.bash
#在这里继续添加source ROS1的工作空间
else
source /opt/ros/eloquent/setup.bash
#source ~/ros2_ws/install/local_setup.bash
fi
2.ROS2依赖配置
2.1解决功能包依赖
sudo apt-get install python3-pip
sudo pip3 install rosdepc
sudo rosdepc init & rosdepc update
2.2安装colcon编译工具
sudo apt-get install python3-colcon-ros
3.使用ros2
3.1创建ros2工作空间
mkdir -p ros2_ws/src
3.2创建功能包
ros2 pkg creat --build-type ament_cmake pkc_name # c++功能包
ros2 pkg creat --build-type ament_python pkg_name # python功能包
这里与ros1有区别,创建功能包需要指定语言
3.3编译
colcon build
更多推荐
已为社区贡献1条内容
所有评论(0)