zoukankan      html  css  js  c++  java
  • 20.04搭建ROS2


    1)修改源文件source.list为阿里云

    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

    2)卸载全部ros:

    sudo apt-get autoremove --purge ros-*

    3)设置编码

    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

    4)添加key

    sudo apt update && sudo apt install curl gnupg2 lsb-release

    WINDOWS下打开并下载https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc
    把文件另存为ros.asc文件,然后用U盘传到ubuntu系统,然后在文件录下运行命令行:

    sudo apt-key add ros.asc

    5)添加ros源

    sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://mirror.tuna.tsinghua.edu.cn/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'

     6)删除sources.list.d其他的源

    7)安装ros

    sudo apt update
    sudo apt install ros-foxy-desktop

    8)加载ros2

    source /opt/ros/foxy/setup.bash

    9) 自动补全

    sudo apt install python3-argcomplete

     10)安装开发工具和ros工具

    sudo apt update && sudo apt install -y \
      build-essential \
      cmake \
      git \
      python3-colcon-common-extensions \
      python3-pip \
      python3-rosdep \
      python3-vcstool \
      wget
    python3 -m pip install -U \
    argcomplete \
    flake8-blind-except \
    flake8-builtins \
    flake8-class-newline \
    flake8-comprehensions \
    flake8-deprecated \
    flake8-docstrings \
    flake8-import-order \
    flake8-quotes \
    pytest-repeat \
    pytest-rerunfailures \
    pytest
    sudo apt install --no-install-recommends -y \
    libasio-dev \
    libtinyxml2-dev
    sudo apt install --no-install-recommends -y \
    libcunit1-dev

    11)加入到bashrc: 

    echo “source /opt/ros/foxy/setup.bash” >> ~/.bashrc

    12)测试验证

    新开终端,发布话题

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

    新开终端,订阅话题

    source /opt/ros/foxy/setup.bash
    ros2 run demo_nodes_py listener

    坑1RMW问题需要添加环境变量

    export RMW_IMPLEMENTATION=rmw_connext_cpp

     坑2注意用户下的.bash文件

  • 相关阅读:
    OK335x mksd.sh hacking
    Qt jsoncpp 对象拷贝、删除、函数调用 demo
    OK335xS 256M 512M nand flash make ubifs hacking
    Qt QScrollArea and layout in code
    JsonCpp Documentation
    Qt 4.8.5 jsoncpp lib
    Oracle数据库生成UUID
    freemarker得到数组的长度
    FreeMarker中if标签内的判断条件
    freemarker语法
  • 原文地址:https://www.cnblogs.com/baolixin/p/15697621.html
Copyright © 2011-2022 走看看