ubuntu怎么查看版本编号:

需要用到语句:

$ lsb_release -a

目前遇到了ROS2无法安装的问题

经过排查,发现是虚拟机没有连接网络的问题

检查过程:

1.先通过ping语句,检查一下网络

比如说ping 8.8.8.8

linux终端会返回

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=187 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=186 ms

初步说明网络出口没问题,接下来我们进行双边通信的验证

2.之后ping一个网站,例如百度网站,看看会不会有信号的回传

u@u-virtual-machine:~$ ping baidu.com
PING baidu.com (111.63.65.247) 56(84) bytes of data.
64 bytes from 111.63.65.247 (111.63.65.247): icmp_seq=1 ttl=128 time=64.5 ms
64 bytes from 111.63.65.247 (111.63.65.247): icmp_seq=2 ttl=128 time=98.6 ms
64 bytes from 111.63.65.247 (111.63.65.247): icmp_seq=3 ttl=128 time=87.9 ms
64 bytes from 111.63.65.247 (111.63.65.247): icmp_seq=4 ttl=128 time=90.4 ms

也没有问题,说明网络方面的问题已经被排查完毕

export TURTLEBOT3_MODEL=waffle
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/humble/share/turtlebot3_gazebo/models

安装ROS2 Gazebo集成包

# 安装完整的Gazebo ROS集成包
sudo apt update
sudo apt install ros-humble-gazebo-ros-pkgs
sudo apt install ros-humble-gazebo-plugins

# 重新安装turtlebot3仿真包
sudo apt install --reinstall ros-humble-turtlebot3-gazebo


启动Gazebo仿真(服务端)

# 设置环境
source /opt/ros/humble/setup.bash
export TURTLEBOT3_MODEL=waffle

# 启动Gazebo服务器(等待它完全启动)
gzserver --verbose

linux终端返回

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 192.168.159.128
[Msg] Loading world file [/usr/share/gazebo-11/worlds/empty.world]

启用Gazebo仿真(客户端)

gzclient

生成TurtleBot3机器人

# 生成TurtleBot3机器人
ros2 run gazebo_ros spawn_entity.py \
  -entity turtlebot3_waffle \
  -file /opt/ros/humble/share/turtlebot3_gazebo/models/turtlebot3_waffle/model.sdf \
  -x -2.0 -y -0.5 -z 0.01

以上的步骤,还未实现,总是卡在Gazebo服务端开始之后,调用TurtleBot3机器人,无法生成

目前好用的方法,可以自行进行对比

# 新开一个终端
source /opt/ros/humble/setup.bash
export TURTLEBOT3_MODEL=waffle

# 启动Gazebo(包含图形界面)
ros2 launch turtlebot3_gazebo empty_world.launch.py

这个可以加载空的地图,就是只有一个机器人的地图,如果你想要加载带地图边缘的,可以使用语句

ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py

键盘控制

# 键盘控制
ros2 run turtlebot3_teleop teleop_keyboard