说明
介绍如何进行Turtlebot3-ROS2入门教程中的SBC安装
测试环境:树莓派 3B+ + Ubuntu Server 18.04.3
镜像安装
注意: 请勿安装最新的Ubuntu Server 18.04.4,其可能在使用过程中出现故障,请依照以下链接下载Ubuntu Server 18.04.3
网络配置
[TurtleBot] ubuntu 18.04 使用的是netplan方式配置网络
$ sudo touch /etc/netplan/01-netcfg.yaml
$ sudo vim /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
dhcp6: yes
optional: true
wifis:
wlan0:
dhcp4: yes
dhcp6: yes
access-points:
"wifi名称":
password: "wifi密码"
[TurtleBot] 固定IP设置示例
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses: [192.168.0.25/24]
gateway4: 192.168.0.1
nameservers:
addresses: [223.5.5.5, 8.8.8.8]
wifis:
wlan0:
dhcp4: no
dhcp6: no
addresses: [192.168.0.25/24]
gateway4: 192.168.0.1
nameservers:
addresses: [223.5.5.5, 8.8.8.8]
access-points:
ChuangKeZhiZao:
password: ChuangKeZhiZao
[TurtleBot] 应用修改好的设置后重启树莓派
$ sudo netplan apply
[TurtleBot] 避免网络延迟,禁止systemd进程
$ systemctl mask systemd-networkd-wait-online.service
[Remote PC] 测试使用ssh是否能连接上树莓派(在树莓派上执行ifconfig命令查看ip地址)
$ ssh 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 Dashing Diademata
[TurtleBot] 更新和升级软件
$ sudo apt update && sudo apt upgrade
[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-dashing-ros-base
[TurtleBot] 安装TurtleBot3包
$ sudo apt install python3-argcomplete python3-colcon-common-extensions libboost-system-dev
$ mkdir -p ~/turtlebot3_ws/src && cd ~/turtlebot3_ws/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 ~/turtlebot3_ws/src/turtlebot3
$ rm -r turtlebot3_cartographer turtlebot3_navigation2
$ cd ~/turtlebot3_ws/
$ source /opt/ros/dashing/setup.bash
$ colcon build --symlink-install --parallel-workers 1
[TurtleBot] 环境设置
$ echo 'source ~/turtlebot3_ws/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