自行上网搜索。
解决rosdep update失败
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
sudo apt update && sudo apt install curl gnupg2 lsb-release
curl http://repo.ros2.org/repos.key | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
桌面版 : 包含ROS, RViz, demos, tutorials [推荐]
sudo apt install ros-dashing-desktop
基础版:(包含通讯库、消息包、命令行工具,没有GUI工具)
sudo apt install ros-dashing-ros-base
ros2的命令行使用argcomplete工具进行补全:
sudo apt install python3-argcomplete
添加环境变量
echo "source /opt/ros/dashing/setup.bash" >> ~/.bashrc
如果出现
ROS_DISTRO was set to 'dashing' before. Please make sure that the environment does not mix paths from different distributions.
或
ROS_DISTRO was set to 'melodic' before . Please make sure that the environment does not mix paths from different distributions.
注释以下文件内的内容
sudo vim /opt/ros/melodic/share/ros_environment/catkin_env_hook/1.ros_distro.sh
sudo vim /opt/ros/dashing/share/ros_environment/environment/1.ros_distro.sh
sudo apt update
sudo apt install ros-dashing-ros1-bridge
ROS2软件包编译工具是colcon。ROS编译工具目前经历了三个阶段:1. catkin 2. ament 3. colcon。
使用以下命令进行安装:
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
sudo -H 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
# [Ubuntu 16.04] install extra packages not available or recent enough on Xenial
python3 -m pip install -U \
pytest \
pytest-cov \
pytest-runner \
setuptools
# install Fast-RTPS dependencies
sudo apt install --no-install-recommends -y \
libasio-dev \
libtinyxml2-dev
创建工作空间,Clone并编译
mkdir ~/ros2_ws
cd /ros2_ws
git clone https://github.com/zhangrelay/ros2_tutorials
cd ros2_tutorials
colcon build
第一个终端运行
ros2 run turtlesim turtlesim_node
第二个终端运行
ros2 run turtlesim draw_square