一、安装ubuntu系统镜像
1.前期准备
在软件包中找到烧录软件rufus-3.9p.exe和Ubuntu Mate SD.img文件
注:软件包链接在评论区
2.烧录镜像
将内SD卡在电脑上读取,打开rufus-3.9p.exe软件,执行下面操做,进行镜像烧录
二、安装ros环境
1.进行基础设置
将内存卡插入树莓派读取,执行语言/用户名/网络相关配置操做
**注:**执行完后树莓派会进行一次自重启,重启之后搜不到可用无线网,此时将树莓派关机手动重启。
2.安装源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
或来自中国的源:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
3.设置key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
4.更新
sudo apt-get update
5.Desktop-Full安装: (Recommended) : ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception
sudo apt-get install ros-kinetic-desktop-full
6.环境设置
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
7.安装rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
三、安装turtlebot3相关包
1.下载turtlebot3代码包
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver.git
$ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
$ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3.git
**注1**:新安装系统,需先执行
sudo apt install git
**注2:**下载速度慢,可以换手机热点下载或者使用U盘拷贝然后编译
2.编译
$ source /opt/ros/kinetic/setup.bash
$ cd ~/catkin_ws && catkin_make -j1
$ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
3.添加模型声明
echo "export TURTLEBOT3_MODEL=burger" >> ~/.bashrc
四、网络配置
1.安装ssh
sudo apt install ssh
2.启用root
sudo passwd root # 提示输入两次密码
sudo passwd --unlock root #启用root
如果提示“passwd: password expiry information changed.”,
将
PermitRootLogin prohibit-password
改为
PermitRootLogin yes
3.开启ssh
sudo raspi-config
配置界面中选择3 Interfacing Options,回车确认,继续选择P2 SSH,选中Yes确认
4.设置SSH自启
apt-get install chkconfig 安装chkconfig
service ssh start
chkconfig |grep ssh #查看自启状态
chkconfig ssh on #设置自启
**注:**chkconfig命令安装报错,可以将软件包中的安装包拷贝至树莓派,手动安装
五、主从机连接
1.查看PC端和turtlebot3网络ip
ifconfig
假设 PC端ip为:192.168.30.100 turtlebot3 IP为:192.168.30.101
2.PC端配置
执行
gedit ~/.bashrc
在文档末尾添加
export ROS_MASTER_URI=http://192.168.30.100:11311 #可根据自己实际ip进行修改
export ROS_HOSTNAME=192.168.30.100
编译
source ~/.bashrc
3.turtlebot3配置
执行
gedit ~/.bashrc
在文档末尾添加
export ROS_MASTER_URI=http://192.168.30.100:11311 #可根据自己实际ip进行修改
export ROS_HOSTNAME=192.168.30.101
编译:
source ~/.bashrc
4.主从机连接测试
PC端执行
ssh name@192.168.30.101 #name为turtlebot3用户名
当上述命令可以正常运行,如上图所示,即网络配置成功。
**注1:**使用虚拟机时候要将网络连接方式选择“**桥接模式**”,如图所示
**注2:**PC端口ssh报如下错误:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:2ZRMvCNAyNzrHHoEZPkOQgeccmxbXG9Sbe7i+YqwRNI.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:1
remove with:
ssh-keygen -f "/root/.ssh/known_hosts" -R 192.168.XX.XX
ECDSA host key for 192.168.1.253 has changed and you have requested strict checking.
Host key verification failed.
1. *# hostname为你主机的用户名,-R后面接你要远程的ip地址*
2. ssh-keygen -f "/home/hostname/.ssh/known_hosts" -R 192.168.XX.XX
参考链接:
[1]https://www.ncnynl.com/archives/201707/1814.html
[2]https://blog.csdn.net/oHanYi1/article/details/90896900?spm=1001.2014.3001.5506