木叶飞舞之【机器人ROS2】篇章_第二节、turtlebot3安装

没有真实小车的情况下,利用gazebo的仿真,操作小乌龟来学习ros2。废话不多说,直接上命令。

Install Gazebo

sudo apt install ros-humble-gazebo-*

Install Cartographer

假如前一节未安装源码版本的cartographer,那就安装apt版本的。

sudo apt install ros-humble-cartographer
sudo apt install ros-humble-cartographer-ros

Install Navigation2

sudo apt install ros-humble-navigation2
sudo apt install ros-humble-nav2-bringup

Install TurBot3 Packages

source ~/.bashrc
sudo apt install ros-humble-dynamixel-sdk
sudo apt install ros-humble-turtlebot3-msgs
sudo apt install ros-humble-turtlebot3
sudo apt install ros-humble-turtlebot3-gazebo

Install Teleop

sudo apt-get install ros-humble-teleop-twist-keyboard

打开终端,启动机器人gazebo

ros2 launch turtlebot3_gazebo turtlebot3_house.launch.py

另开终端,再启动cartographer启动节点

ros2 launch turtlebot3_cartographer cartographer.launch.py 

另开终端,启动键盘启动节点,控制机器人

ros2 run teleop_twist_keyboard teleop_twist_keyboard

另开终端,结束构图,停止接受新数据

ros2 service call /finish_trajectory cartographer_ros_msgs/srv/FinishTrajectory "{trajectory_id: 0}"

序列化保存其当前状态

ros2 service call /write_state cartographer_ros_msgs/srv/WriteState "{filename: '/home/develop/bags/mymap.pbstream'}"

将pbstream转化为pgm和yaml,在cartographer_pbstream_to_ros_map目录下执行

cd /opt/ros/humble/lib/cartographer_ros
./cartographer_pbstream_to_ros_map -map_filestem=${HOME}/bags/mymap -pbstream_filename=${HOME}/bags/mymap.pbstream -resolution=0.05

你可能感兴趣的:(机器人,自动驾驶,人工智能,ros,ubuntu)