shellsudo apt update && sudo apt install -y locales 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
shellsudo apt update sudo wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O /usr/share/keyrings/ros-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] https://mirrors.cloud.tencent.com/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
如遇报错“Failed to connect to raw.githubusercontent.com”,可参考
shellsudo apt update
# sudo apt install ros-iron-desktop # 最新发行版
sudo apt install -y ros-humble-desktop # 长期支持版
sudo apt install -y ros-humble-desktop-full # 全家桶
shellecho "source /opt/ros/humble/setup.bash" >> ~/.bashrc
至此,ROS2就已经在系统中安装好了。
shellsudo apt install -y ros-dev-tools git # 开发工具 sudo rosdep init && rosdep update
shellmkdir -p ~/dev_ws/src cd ~/dev_ws/src git clone https://gitee.com/guyuehome/ros2_21_tutorials.git
shellcd ~/dev_ws/
rosdep install -i --from-path src --rosdistro humble -y
colcon build
# 跳过测试
colcon build --catkin-skip-building-tests
shellsource install/local_setup.sh # 仅在当前终端生效 echo "source ~/dev_ws/install/local_setup.sh" >> ~/.bashrc # 所有终端均生效
至此,我们就完成了工作空间的创建、编译和配置。
本文作者:菜鸟
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 许可协议。转载请注明出处!