ros2学习之资料准备与环境搭建

1.flag

因为之前使用的ros1还是ros2,自己学习的都比较片面,只是简单的实用主义,用到什么就去查什么,导致在真正的项目中,选用的方案太过单一和复杂,其实可以有更多实现方式,只是自己不太了解,所以决定快速的学习ros2,并记录在本专栏里: ros2 学习

2.资料准备

  1. 官方gitub https://github.com/ros2
  2. 官方文档 https://index.ros.org/doc/ros2/
  3. colcon 使用文档 https://colcon.readthedocs.io/en/released/
  4. 官方demo https://github.com/ros2/demos
  5. 官方api接口 c++ http://docs.ros2.org/dashing/api/rclcpp/index.html
  6. 官方api接口 python http://docs.ros2.org/dashing/api/rclpy/index.html
  7. Core Stack Developer Overview http://docs.ros2.org/dashing/developer_overview.html#core-stack-developer-overview
  8. CMAKE3.5文档 https://cmake.org/cmake/help/latest/release/3.5.html
    这些网站最好收藏下,官方文档,官方源码才是真道理,有编程基础和linux基础,可以用python3了

3.环境搭建

① 系统准备

准备使用ubuntu18.04版本,使用虚拟机安装,具体如何安装,自行搜索,VMware安装18.04 需要注意一下,选 稍后安装操作系统,自动安装会各种不成功
在这里插入图片描述

在这里插入图片描述

② 安装ide

这边C++安装的是clion,python安装的是pycharm
官网https://www.jetbrains.com/
active 参考我的博客https://blog.csdn.net/weixin_36628778/article/details/104937955

③ ros2安装

按照官方指导来https://index.ros.org/doc/ros2/Installation/Dashing/Linux-Install-Debians/

Ⅰ设置语言环境

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

Ⅱ 安装源

安装GPG密钥

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://mirror.tuna.tsinghua.edu.cn/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'

Ⅲ 安装ros2 软件包

我这边安装desktop版本

sudo apt update
sudo apt install ros-dashing-desktop

Ⅳ 环境设置

1.source 安装脚本

source /opt/ros/dashing/setup.bash

2.安装自动补全工具

工欲善其事必先利其器,很重要

扫描二维码关注公众号,回复: 10269537 查看本文章
sudo apt install python3-argcomplete

3.安装编译工具

sudo apt install python3-colcon-common-extensions

④ ros2 初体验

执行c++ talker demo

ros2 run demo_nodes_cpp talker

执行 python listener demo

ros2 run demo_nodes_py listener

在这里插入图片描述
取消了master,消息类型和ros1一样,命令保持不变

在这里插入图片描述

使用了colcon build 之后界面简单多了

发布了79 篇原创文章 · 获赞 153 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_36628778/article/details/105170234