编译安装ROS2

编译安装ROS2

添加 ROS 2 apt 存储库#

Copy
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 -

然后将存储库添加到源列表

Copy
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'

安装开发工具和ROS工具#

Copy
sudo apt update sudo apt install -y \ build-essential \ cmake \ git \ python3-colcon-common-extensions \ python3-pip \ python-rosdep \ python3-vcstool \ wget # install some pip packages needed for testing python3 -m pip install -U \ argcomplete \ flake8 \ flake8-blind-except \ flake8-builtins \ flake8-class-newline \ flake8-comprehensions \ flake8-deprecated \ flake8-docstrings \ flake8-import-order \ flake8-quotes \ pytest-repeat \ pytest-rerunfailures \ pytest \ pytest-cov \ pytest-runner \ setuptools # install Fast-RTPS dependencies sudo apt install --no-install-recommends -y \ libasio-dev \ libtinyxml2-dev # install Cyclone DDS dependencies sudo apt install --no-install-recommends -y \ libcunit1-dev

获取 ROS 2 代码#

创建工作区并克隆所有存储库

Copy
mkdir -p ~/ros2_eloquent/src cd ~/ros2_eloquent wget https://raw.githubusercontent.com/ros2/ros2/eloquent/ros2.repos vcs import src < ros2.repos

使用 rosdep 安装依赖项

Copy
sudo rosdep init rosdep update rosdep install --from-paths src --ignore-src --rosdistro eloquent -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69 rti-connext-dds-5.3.1 urdfdom_headers"

在工作区中构建代码#

Copy
cd ~/ros2_eloquent/ colcon build --symlink-install

注意:如果出现了下载失败的问题

Copy
CMake Error at uncrustify-0.68.1-stamp/download-uncrustify-0.68.1.cmake:159 (message): Each download failed! error: downloading 'https://github.com/uncrustify/uncrustify/archive/45b836cff040594994d364ad6fd3f04adc890a26.tar.gz' failed status_code: 1 status_string: "Unsupported protocol" log: --- LOG BEGIN --- Protocol "https" not supported or disabled in libcurl Closing connection -1

是cmake和curl的问题,请重新编译cmake

Copy
wget https://github.com/Kitware/CMake/releases/download/v3.13.2/cmake-3.13.2.tar.gz tar -zxvf cmake-3.13.2.tar.gz cd cmake-3.13.2 ./bootstrap --system-curl -- -DCMAKE_BUILD_TYPE:STRING=Release make -j128 sudo make install

编译完成设置环境变量#

Copy
echo "source ~/ros2_galactic/install/local_setup.bash" >> ~/.bashrc source ~/.bashrc

此时已经完成编译和环境变量设置

测试#

Copy
ros2 run demo_nodes_cpp talker # 打开另一种终端 ros2 run demo_nodes_py listener
posted @   nanmi  阅读(293)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示
CONTENTS