• Ubuntu18.04 实现:安装turtlebot3功能包、虚拟机与机器人之间的网络配置、测试机器人Cartographer建图


    一.安装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文件中:

    终端运行:

    1. cd ~/catkin_ws/src
    2. 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

    exit

  • 相关阅读:
    《QEMU/KVM源码分析与应用》读书笔记3 —— 第一章 QEMU与KVM概述
    详细解读字节跳动视频生成模型StoryDiffusion:连环画创作和长视频生成
    网康科技 NS-ASG 应用安全网关 SQL注入漏洞复现(CVE-2024-2022)
    spring 如何获取当前类在容器中的beanname呢?
    电子元器件B2B电商平台建设方案:优化企业商流,拓宽B2B交易渠道
    Python中的pytest的使用
    Vite-Wechat网页聊天室|vite5.x+vue3+pinia+element-plus仿微信客户端
    机器学习算法——集成学习4(Bagging)
    添加过的PDF注释可以修改吗?怎么修改PDF注释?
    java-php-python-springboot携手助学助学交流平台计算机毕业设计
  • 原文地址:https://blog.csdn.net/weixin_44190648/article/details/127666451