一.安装turtlebot3及其依赖
1.安装依赖包
终端运行:
sudo apt install ros-melodic-desktop-full ros-melodic-joy ros-melodic-teleop-twist-joy ros-melodic-teleop-twist-keyboard ros-melodic-laser-proc ros-melodic-rgbd-launch ros-melodic-depthimage-to-laserscan ros-melodic-rosserial-arduino ros-melodic-rosserial-python ros-melodic-rosserial-server ros-melodic-rosserial-client ros-melodic-rosserial-msgs ros-melodic-amcl ros-melodic-map-server ros-melodic-move-base ros-melodic-urdf ros-melodic-xacro ros-melodic-compressed-image-transport ros-melodic-rqt-image-view ros-melodic-gmapping ros-melodic-navigation ros-melodic-interactive-markers ros-melodic-turtlebot3-gazebo
sudo apt install ros-melodic-desktop-full ros-melodic-joy ros-melodic-teleop-twist-joy ros-melodic-teleop-twist-keyboard ros-melodic-laser-proc ros-melodic-rgbd-launch ros-melodic-depthimage-to-laserscan ros-melodic-rosserial-arduino ros-melodic-rosserial-python ros-melodic-rosserial-server ros-melodic-rosserial-client ros-melodic-rosserial-msgs ros-melodic-amcl ros-melodic-map-server ros-melodic-move-base ros-melodic-urdf ros-melodic-xacro ros-melodic-compressed-image-transport ros-melodic-rqt-image-view ros-melodic-gmapping ros-melodic-navigation ros-melodic-interactive-markers ros-melodic-turtlebot3-gazebo
2.下载turtlebot3源码
(1)创建工作空间
mkdir -p ~/catkin_ws/src
(2)进入src文件夹下面,将其初始化为ROS工作空间
cd ~/catkin_ws/src
catkin_init_workspace
(3)编译工作空间
cd ..
catkin_make
(4)设置环境变量
source devel/setup.bash
gedit ~/.bashrc
source ~/catkin_ws/devel/setup.bash
下载源码到src文件中:
终端运行:
cd ~/catkin_ws/src
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
编译源码:
cd ~/catkin_ws && catkin_make
3.设置turtlebot相关的bashrc配置
设置机型burger、waffle或waffle pi,写入bashrc中:
终端运行:
gedit ~/.bashrc
写入:
export TURTLEBOT3_MODEL=burger
二.虚拟机与机器人之间的网络配置
前提:turtlebot3、主机需要在一个局域网中!!!(解释:turtlebot3连接wifi、主机连接从wifi出来的网线或wifi)
主机:自己电脑;从机:turtlebot3;
1.查看自己的ip地址和hostname
终端输入:
ifconfig
IP:inet 192.168.3.16
hostname
2.配置主机bashrc文件
终端运行:
gedit ~/.bashrc
写入:
export ROS_MASTER_URI=http://192.168.3.16:11311 注意:这里是主机IP
export ROS_HOSTNAME=192.168.3.16 注意:这里是主机IP
3.配置主机hosts文件
终端运行:
sudo gedit /etc/hosts
写入turtlebot3的IP和hostname:
192.168.3.13 robot
source ~/.bashrc
4.查看turtlebot3 ip地址
5.配置turtlebot3的host文件
终端运行:
sudo nano /etc/hosts
写入 主机的IP和hostname:
192.168.3.16 w19-19a405
6.配置turtlebot3的bashrc文件
终端运行:
nano ~/.bashrc
写入:
export ROS_MASTER_URI=http://192.168.3.16:11311 注意:这里是主机IP
export ROS_HOSTNAME=192.168.3.13 注意:这里是turtlebot3的IP
终端运行:
source ~/.bashrc
三.测试机器人Cartographer建图
1.安装Cartographer
成功Ubuntu18.04 ROS melodic安装Cartograhper+Ceres1.13.0,以及错误总结_静心、尽心-est的博客-CSDN博客_ros安装ceres
2.运行
(1)打开一个终端,运行roscore;
(2)打开一个终端,启动ssh、运行turtlebot3:
ssh
ssh robot@192.168.3.13
检查是否连接成功,查看是否订阅roscore话题:
rostopic list
roslaunch turtlebot3_bringup turtlebot3_robot.launch
(3)打开一个新终端,运行cartographer:
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer
(4)打开一个新终端,运行运动控制:
roslaunch mbot_teleop mbot_teleop.launch
(5)结束,开始测试!
(6)退出ssh
Ctrl+D
或文章来源:https://www.toymoban.com/news/detail-489038.html
exit文章来源地址https://www.toymoban.com/news/detail-489038.html
到了这里,关于Ubuntu18.04 实现:安装turtlebot3功能包、虚拟机与机器人之间的网络配置、测试机器人Cartographer建图的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!