Ubuntu 20.04 ROS2 Foxy安裝


參考博客

ROS2安裝

有的地方原博主打錯了,還沒改過來,我按我自己的改好了。
有的地方比如github和raw.githubusercontent.com訪問不了,我替換成能用的鏡像源了,只求一鍵復制粘貼完事。

在Ubuntu 20.04中安裝ROS2最新版本Foxy Fitzroy

上面那篇問題太多了,后來我又參考了這篇,棄用了清華源,就好了。

環境推薦

我用的是Ubuntu 20.04,參考的那篇博客也是。其他的環境不知道能不能用下列步驟,可以自行查閱官方文檔。

網站推薦

官方文檔: https://index.ros.org/doc/ros2/
清華鏡像站: https://mirrors.tuna.tsinghua.edu.cn/help/ros2/

設置語言環境

locale  # check for UTF-8

sudo apt update && sudo apt install 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

locale  # verify setting

設置源

sudo apt update && sudo apt install curl gnupg2 lsb-release -y
curl -s https://raw.fastgit.org/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/ bionic main" > /etc/apt/sources.list.d/ros2-latest.list'
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'

安裝ROS 2軟件包

sudo apt update
sudo apt upgrade
sudo apt-get update
sudo apt install ros-foxy-desktop

測試

source /opt/ros/foxy/setup.bash
ros2 run demo_nodes_cpp talker

結果如下圖:
在這里插入圖片描述

配置環境變量

gedit ~/.bashrc

在末尾添加

source /opt/ros/foxy/setup.bash

卸載ROS2

sudo apt remove ros-foxy-*
sudo apt autoremove


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM