< >
Home » Dashing版Turtlebot3-burger入门教程 » Turtlebot3-ROS2入门教程-SBC安装(ubuntu20.04+foxy)

Turtlebot3-ROS2入门教程-SBC安装(ubuntu20.04+foxy)

Turtlebot3-ROS2入门教程-SBC安装(ubuntu20.04+foxy)

相关设备:

说明

  • 介绍如何进行Turtlebot3-ROS2入门教程中的SBC安装

  • 测试环境:树莓派 3B+ ,ubuntu20.04 mate,foxy

镜像安装

  • 系统安装,参考安装教程

  • 默认的用户名和密码都是ubuntu,登录后系统会询问是否更改密码

网络配置

增加交换空间

  • [TurtleBot] 创建一个交换空间且赋予权限
$ sudo fallocate -l 1G /swapfile
$ sudo chmod 600 /swapfile
  • [TurtleBot] 使用mkswap命令设置Linux的交换空间
$ sudo mkswap /swapfile
  • [TurtleBot] 启用该交换空间
$ sudo swapon /swapfile
  • [TurtleBot] 设置开机挂载
$ sudo vim /etc/fstab
//将下面这句话添加到文件末
/swapfile swap swap defaults 0 0
  • [TurtleBot] 查看是否分配交换空间
$ sudo free -h
          total        used        free      shared  buff/cache   available
Mem:       912M         75M        254M        3.0M        582M        819M
Swap:      1.0G         35M        988M

安装ROS2 foxy

  • [TurtleBot] 更新和升级软件
$ sudo apt update  
  • [TurtleBot] 设置区域
$ 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
  • [TurtleBot] 设置源
$ 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 [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
  • [TurtleBot] 安装ROS2包
$ sudo apt update
$ sudo apt install ros-foxy-desktop
  • [TurtleBot] 安装TurtleBot3包
$ sudo apt install python3-argcomplete python3-colcon-common-extensions libboost-system-dev
$ mkdir -p ~/tb3_ws2/src && cd ~/tb3_ws2/src
$ git clone -b ros2 https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver.git
$ git clone -b ros2 https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
$ git clone -b ros2 https://github.com/ROBOTIS-GIT/turtlebot3.git
$ git clone -b ros2 https://github.com/ROBOTIS-GIT/DynamixelSDK.git
$ cd ~/tb3_ws2/src/turtlebot3
$ rm -r turtlebot3_cartographer turtlebot3_navigation2
$ cd ~/tb3_ws2/
$ source /opt/ros/foxy/setup.bash
$ colcon build --symlink-install --parallel-workers 1
  • 设置udev规则
$ cd ~/tb3_ws2/src/turtlebot3/turtlebot3_bringup 
$ sudo cp ./99-turtlebot3-cdc.rules /etc/udev/rules.d/ 
$ sudo udevadm control --reload-rules 
$ sudo udevadm trigger
  • [TurtleBot] 环境设置
$ echo 'source ~/tb3_ws2/install/setup.bash' >> ~/.bashrc
$ echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc
$ source ~/.bashrc

在DDS通信中,远程PC和TurtleBot3之间的ROS_DOMAIN_ID必须要匹配上且需要两者都需要处于同一个网段下

  • [TurtleBot] 由于测试使用的是TurtleBot3-Buger,故配置模型的环境变量为burger
$ echo 'export TURTLEBOT3_MODEL=burger' >> ~/.bashrc

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: turtlebot3-ros2入门教程