双系统ubuntu20.04(neotic版本)从0实现Gazebo仿真slam建图

news/2025/2/22 0:48:06

双系统ubuntu20.04(neotic版本)从0实现Gazebo仿真slam建图

昨晚完成了ROS的多机通讯,还没来得及整理相关操作步骤,在进行实际小车的实验之前,还是先打算在仿真环境中进行测试,熟悉相关的操作步骤,计划通过虚拟机(笔记本)来操纵双系统(台式机)完成在仿真环境中的地图构建,导航等功能。
ps:别问为什么不直接通过向日葵远程操控,后面要进行实际环境中多机器人编队的测试,多机器人编队功能已经被写好了,但是需要安装在远程PC的工作空间中进行多机器人的控制
1、安装ROS(neotic)版本依赖

  sudo apt-get install ros-noetic-joy ros-noetic-teleop-twist-joy \
  ros-noetic-teleop-twist-keyboard ros-noetic-laser-proc \
  ros-noetic-rgbd-launch ros-noetic-rosserial-arduino \
  ros-noetic-rosserial-python ros-noetic-rosserial-client \
  ros-noetic-rosserial-msgs ros-noetic-amcl ros-noetic-map-server \
  ros-noetic-move-base ros-noetic-urdf ros-noetic-xacro \
  ros-noetic-compressed-image-transport ros-noetic-rqt* ros-noetic-rviz \
  ros-noetic-gmapping ros-noetic-navigation ros-noetic-interactive-markers

ROS1和ROS2其他版本安装相关依赖参考网址(ROS1&ROS2依赖包)注意☝的是一行指令,分行输入会报错的。

2、安装turtlebot3软件包
Install TurtleBot3 via Debian Packages.

 sudo apt install ros-noetic-dynamixel-sdk
 sudo apt install ros-noetic-turtlebot3-msgs
 sudo apt install ros-noetic-turtlebot3

3、设置环境变量

 source ~/.bashrc

4、创建工作空间安装TB3功能包

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src/
git clone -b noetic-devel http://ghproxy.com/https://github.com/ROBOTIS-GIT/DynamixelSDK.git
git clone -b noetic-devel http://ghproxy.com/https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone -b noetic-devel http://ghproxy.com/https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone -b noetic-devel http://ghproxy.com/https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ~/catkin_ws && catkin_make

ROS1其他版本的TB3功能包参考ROS1功能包
ROS2(foxy)版本功能包参考ROS2功能包
注意ROS1&ROS2的其他版本连接中改对应版本名称
编译成功
在这里插入图片描述5、Gazebo仿真
(1)选择启动的机器人模型

export TURTLEBOT3_MODEL=waffle_pi
export TURTLEBOT3_MODEL=burger

(2)启动gazebo仿真环境

roslaunch turtlebot3_gazebo turtlebot3_world.launch

可能会出现以下报错:
在这里插入图片描述
找到错误原因“环境变量设置有问题”
错误原因为环境变量设置有问题(后面进行优化)
运行下方代码后再执行roslaunch

source ~/catkin_ws/devel/setup.bash
 roslaunch turtlebot3_slam turtlebot3_slam.launch

turtlebot3_world.launch
在这里插入图片描述
(3)启动rviz进行建图
打开新的终端,还要在输入一边机器人选择模型的指令,在输入以下指令(后面进行优化)

roslaunch turtlebot3_slam turtlebot3_slam.launch

(4)控制小车移动实现建图
打开新的终端,还要在输入一边机器人选择模型的指令

roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

在这里插入图片描述
(5)保存地图:

rosrun map_server map_saver -f ~/map_world

在这里插入图片描述

地图自动保存在~/home/map目录下,名为map_world.yaml和map_world.pgm
在这里插入图片描述

优化

目前在启动机器人小车在仿真环境中的建图非常麻烦,每次启动新的节点都要输入指令选择一遍机器人的模型,且在启动turtlebot3_world.launch文件前还要进行以便环境的配置,总之是非常麻烦的!
下面把这些指令提前配置到source ~/.bashrc文件中
(1)手动配置
输入:

sudo gedit ~/.bashrc 

在文本的最后加入以下这些指令:

source ~/catkin_ws/devel/setup.bash
export TURTLEBOT3_MODEL=waffle_pi//如果你要选择burger型机器人输入export TURTLEBOT3_MODEL=burger
export ROS_DOMAIN_ID=30 #TURTLEBOT3
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/catkin_ws/src/turtlebot3/turtlebot3_simulations/turtlebot3_gazebo/models

然后保存后关闭文件,打开终端输入source ~/.bashrc更新环境即可完成。
(2)输入指令配置
我参考其他配置环境指令,输入后可达到相同效果。

echo 'source ~/catkin_ws/devel/setup.bash' >> ~/.bashrc
echo 'export TURTLEBOT3_MODEL=waffle_pi' >> ~/.bashrc
echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc
echo 'export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/catkin_ws/src/turtlebot3/turtlebot3_simulations/turtlebot3_gazebo/models' >> ~/.bashrc

输入完成后打开新终端输入:

source ~/.bashrc

设置完成后,现在启动建图,仅需要输入:
(1)启动gazebo仿真环境

roslaunch turtlebot3_gazebo turtlebot3_world.launch

(2)启动RVIZ

roslaunch turtlebot3_slam turtlebot3_slam.launch

(3)启动键盘控制节点即可

roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

http://www.niftyadmin.cn/n/5029341.html

相关文章

python写代码过程中的坑230915

1.解释代码IndentationError: expected an indented block 这个错误通常是由于代码缩进错误导致的。 在Python中,代码块(如循环、条件语句、函数等)通常使用缩进来表示。因此,如果你在期望缩进的位置没有正确缩进代码,就会出现"IndentationError: expected an inden…

逆向-beginners之scanf

#include <stdio.h> int main() { int x; printf("Enter x:\n"); scanf("%d", &x); printf("you entered %d...\n", x); return 0; } #if 0 /* * x86 */ 在函数运行期间&#xff0c;EBP一直指向当前的栈帧(s…

PMC-LLaMA: Towards Building Open-source Language Models for Medicine

本文是LLM系列文章&#xff0c;针对《PMC-LLaMA: Towards Building Open-source Language Models for Medicine》的翻译。 PMC LLaMA&#xff1a;构建医学开源语言模型 摘要引言相关工作问题定义数据集构造实验结果结论 摘要 最近&#xff0c;大型语言模型&#xff08;LLM&am…

打包发布异常01

缺一不可 Build starting... Start: Fri Sep 15 08:07:01 UTC 2023 bfdf11d63b70 Git: 0.33-0-g6190381 commit 61903816b88ff5cf3e0848cd19fcb190af0801cd Author: 米伟强 Date: Fri Sep 15 15:57:28 2023 0800gradle插件版本Init SDKMan Found Android manifest Android …

【C语言】指针的进阶(一)

目录 前言 1. 字符指针 2. 指针数组 3. 数组指针 3.1 数组指针的定义 3.2 &数组名VS数组名 3.3 数组指针的使用 4. 数组参数、指针参数 4.1 一维数组传参 4.2 二维数组传参 4.3 一级指针传参 4.4 二级指针传参 5. 函数指针 前言 指针在C语言中可谓是有着举足轻重的…

Vulkan入门——编译Shaderc

编译 Vulkan-Samples时&#xff0c;遇到了如下shaderc编译报错。 ninja: error: /Users/xiaxl/Library/Android/sdk/ndk/21.1.6352462/sources/third_party/shaderc/libs/c_static/armeabi-v7a/libshaderc.a, needed by ../../../../build/intermediates/cmake/debug/obj/arme…

buildroot中C语言使用libconfig的实例

首先在buildroot中开启libconfig 在config中添加 BR2_PACKAGE_LIBCONFIGy 下面是官方给出来的3个实例 /* ----------------------------------------------------------------------------libconfig - A library for processing structured configuration filesCopyright (…

C++中使用嵌套循环遍历多维数组

C中使用嵌套循环遍历多维数组 一维数组&#xff1a;数组元素可以看做是一行数据。 二维数组&#xff1a;更像是一个表格&#xff0c;既有行数据又有列数据。 C没有提供二维数组类型&#xff0c;但用户可以创建每个元素本身都是数组的数组。例如&#xff0c;假设要存储 5 个城…