ROS Ubuntu18.04 Melodic下Turtlebot功能包移植教程

本文介绍TurtleBot3功能包移植测试过程,包括多个功能包的编译及问题解决方法,如depthimage_to_laserscan和navigation等。同时提供键盘控制TurtleBot3的启动步骤。

TurtleBot-Tutorial教程移植测试

TurtleBot-Tutorial

本文根据对官方提供的TURTLEBOT功能包内的每一个功能包进行编译测试,并对出现问题的功能包纠错与更新实现了跨版本移植;

arbotix_ros 移植编译正常

ar_track_alvar 移植编译正常

depthimage_to_laserscan 移植测试失败,终端提示错误
TurtleBot-Tutorial/depthimage_to_laserscan/src/DepthImageToLaserScanNodelet.cpp

第60行代码
PLUGINLIB_DECLARE_CLASS(depthimage_to_laserscan, DepthImageToLaserScanNodelet, depthimage_to_laserscan::DepthImageToLaserScanNodelet, nodelet::Nodelet);
修订如下
PLUGINLIB_EXPORT_CLASS(depthimage_to_laserscan::DepthImageToLaserScanNodelet, nodelet::Nodelet)

修订完成后,移植编译正常


hector_slam 移植编译正常

m-explore 移植编译正常

navigation 移植测试失败,终端提示错误
替换navigation包
https://github.com/ros-planning/navigation.git
通过在终端中键入如下命令进行下载
git clone https://github.com/ros-planning/navigation.git

修订完成后,移植编译正常


rbx1 移植编译正常

robot_voice 移植测试失败,终端提示错误

下载科大迅飞 SDK 参考文章

  1. 首先需要进行账号注册方可下载SDK
  2. 进入控制台
  3. 创建新服务
  4. 服务创建完成后返回主页进入SDK下载
  5. 解压下载的SDK,并执行以下命令,将libmsc.so文件拷贝至/usr/lib路径下
cd Linux_iat1227_tts_online1227_5f7c3a77/libs/x64/
sudo cp libmsc.so /usr/lib/

修订完成后,移植编译正常


rosbag 移植编译正常

rplidar_ros 移植编译正常

slam_gmapping 移植编译正常

turtlebot 移植编译正常

turtlebot3 移植编译正常

turtlebot_apps 移植编译正常

vision_detector 移植编译正常

vision_tensorflow 移植编译正常

测试

在rviz上仿真

调出TurtleBot3机器人模型

/TurtleBot-Tutorial/turtlebot3/turtlebot3_simulations/turtlebot3_fake/launch
roslaunch turtlebot3_fake turtlebot3_fake.launch

turtlebot3_fake.launch

<launch>
  <!-- Set the arg which name model and the default value from the enviroment TURTLEBOT3_MODEL -->
  <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>

 <!-- Set the param which name is tb3_model and the value is from the arg model -->
  <param name="tb3_model" value="$(arg model)"/>

 <!-- load the xml file which contain the turtlebot3_description patn -->
 <!-- Set the arg model which value from the arg model -->
  <include file="$(find turtlebot3_bringup)/launch/includes/description.launch.xml">
    <arg name="model" value="$(arg model)" />
  </include>

 <!-- Start a node which name turtlebot3_fake_node and pkg name is turtlebot3_fake and type is turtlebot3_fake_node , also output the log in the screen -->
  <node pkg="turtlebot3_fake" type="turtlebot3_fake_node" name="turtlebot3_fake_node" output="screen" />

 <!-- Start a node which name robot_state_publisher and pkg name is robot_state_publisher and type is robot_state_publisher , also output the log in the screen -->
 <!-- Set the param which name is publish_frequency and type is double , value is 50.0 -->
  <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen">
    <param name="publish_frequency" type="double" value="50.0" />
  </node>
 
 <!-- Start a node whic name rviz and pkg is rviz and type is rviz , and args is a rviz config where is in the /turtlebot3_fake/rviz/turtlebot3_fake.rviz -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find turtlebot3_fake)/rviz/turtlebot3_fake.rviz"/>
</launch>

description.launch.xml

<launch>
 <!-- Set arg name is model -->
  <arg name="model"/>

 <!-- Set arg name is urdf_file and default value is a path which point to /turtlebot3_description/urdf/turtlebot3_model(value).urdf.xacro -->
 <!-- Set param name is robot_description and load the arg urdf_file which is turtlebot3_description to the param server -->
  <arg name="urdf_file" default="$(find xacro)/xacro --inorder '$(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro'" />
  <param name="robot_description" command="$(arg urdf_file)" />
</launch>

在启动的终端中可以看到如下输出

SUMMARY
========

PARAMETERS
 * /robot_description: <?xml version="1....
 * /robot_state_publisher/publish_frequency: 50.0
 * /rosdistro: melodic
 * /rosversion: 1.14.9
 * /tb3_model: waffle_pi

NODES
  /
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
    rviz (rviz/rviz)
    turtlebot3_fake_node (turtlebot3_fake/turtlebot3_fake_node)

使TurtleBot3可以通过键盘控制

roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
turtlebot3_teleop_key.launch
<launch>
 <!-- Set arg which name is model and default value from the enviroment TURTLEBOT3_MODEL -->
 <!-- Set param which name is model and value from the arg which name is model -->
  <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
  <param name="model" value="$(arg model)"/>

 <!-- turtlebot3_teleop_key already has its own built in velocity smoother -->
 <!-- Start a node which name turtlebot3_teleop_keyboard and pkg name is turtlebot3_teleop and type is turtlebot3_teleop_key , also output the log in the screen -->
  <node pkg="turtlebot3_teleop" type="turtlebot3_teleop_key" name="turtlebot3_teleop_keyboard"  output="screen">
  </node>
</launch>
<think>好的,用户想在Ubuntu 18.04上使用TurtleBot3进行仿真建图,需要指南或教程。首先,我需要回忆一下TurtleBot3的相关知识,以及ROS的版本兼容性。因为Ubuntu 18.04通常对应ROS Melodic,所以需要确认TurtleBot3是否支持Melodic。 接下来,用户提到的安装步骤可能ROS的安装、TurtleBot3的依赖、仿真环境如Gazebo的设置,以及建图工具比如SLAM的算法(如gmapping)。需要确保每个步骤的命令正确,并且适用于Ubuntu 18.04。比如,安装ROS Melodic的步骤是否正确,是否需要添加特定的软件源。 然后,用户可能需要运行仿真的命令,例如启动Gazebo环境和TurtleBot3的节点。这里需要检查是否有常见的错误,比如模型加载问题或依赖缺失。例如,TurtleBot3的模型文件是否正确安装,环境变量是否设置。 建图部分可能需要使用SLAM工具,比如启动gmapping节点,然后通过键盘或导航指令控制机器人移动以生成地图。最后保存地图的步骤是否正确,比如使用map_server。 另外,用户提供的引用中有提到GitLab的安装指南和TensorFlow的例子,但可能和当前问题关联不大,不过引用[3]提到了Ubuntu、bash、ROS相关工具,可能需要参考这些环境配置。需要确保安装过程中的依赖项,比如python、库文件等是否满足要求。 用户可能遇到的问题括环境变量未设置、软件未找到、仿真启动失败等,需要提供常见问题解决方法,比如source setup.bash,或者安装额外的依赖。 最后,生成相关问题时要考虑用户可能的后续需求,比如实际机器人部署、不同SLAM算法比较、导航功能实现等,这些可以作为相关问题提出。</think>在Ubuntu 18.04上使用TurtleBot3进行仿真建图需要结合ROS Melodic和Gazebo环境。以下是分步指南: ### 一、环境准备 1. 安装ROS Melodic ```bash sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 sudo apt update sudo apt install ros-melodic-desktop-full echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc ``` 2. 安装TurtleBot3依赖 ```bash sudo apt install ros-melodic-turtlebot3 ros-melodic-turtlebot3-simulations ``` ### 二、配置环境变量 ```bash echo "export TURTLEBOT3_MODEL=burger" >> ~/.bashrc source ~/.bashrc ``` ### 三、启动仿真建图 1. 启动Gazebo环境 ```bash roslaunch turtlebot3_gazebo turtlebot3_world.launch ``` 2. 启动SLAM节点(新终端) ```bash roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping ``` 3. 启动键盘控制(新终端) ```bash roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch ``` ### 四、保存地图 ```bash rosrun map_server map_saver -f ~/turtlebot3_map ``` ### 常见问题解决 - 若出现模型加载错误,需安装额外模型: ```bash sudo apt install ros-melodic-turtlebot3-msgs ros-melodic-turtlebot3-description ``` - Gazebo启动缓慢时可尝试更换镜像源[^3]
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值