ubuntu 1604 安装ROS2并测试demo

ROS2官网:https://index.ros.org/doc/ros2/

https://index.ros.org/doc/ros2/Installation/Dashing/Linux-Development-Setup/

设置本地环境

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

 2.设置软件源

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 -

 sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'

3.通过二进制形式安装 

sudo apt update 

sudo apt install ros-dashing-desktop

4.安装一些ROS2开发工具和ros2工具 

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 CycloneDDS dependencies
sudo apt install --no-install-recommends -y \
  libcunit1-dev

5.安装自动补全功能包

 sudo apt install python3-pip

sudo apt install python3-argcomplete

sudo activate-global-python-argcomplet 

6.将环境变量听加到bashrc文件中去 

echo "source /opt/ros/dashing/setup.bash" >> ~/.bashrc

 

编写demo包并测试,官方代码连接

https://index.ros.org/doc/ros2/Tutorials/Creating-Your-First-ROS2-Package/

https://index.ros.org/doc/ros2/Tutorials/Writing-A-Simple-Cpp-Publisher-And-Subscriber/

cmakelist文件内容如下: (这里我把PROJECT_NAME写错导致了下面的运行错误,没有可执行文件)

cmake_minimum_required(VERSION 3.5)
project(cpp_pubsub)

# Default to C99

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)

add_executable(talker src/publisher_member_function.cpp)
ament_target_dependencies(talker rclcpp std_msgs)
add_executable(listener src/subscriber_member_function.cpp)
ament_target_dependencies(listener rclcpp std_msgs)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package( REQUIRED)

install(TARGETS
talker
listener
DESTINATION lib/${PROJECT_NAME})

ament_package()

http://docs.ros2.org/dashing/api/rclcpp/ 

ubuntu 1604 安装ROS2并测试demo_第1张图片
 

你可能感兴趣的:(linux文件系统)