电脑配置:R7-7840H 核显
结论:turtlebot3 运行失败。
turtlebot4 可以进入仿真环境,但是无法操作。
现在在用 ign gazebo 驱动简单的差分机器人
ign gazebo
简介
gazebo 有很多的版本,Gazebo 是最初的仿真平台,Gazebo 11 是 Gazebo 经典版的最后一个主要版本,在 ROS 1 系统中得到了广泛使用。
Ignition Gazebo 是 Gazebo 的 下一代版本,在架构上有着显著的改进,旨在提供更高的可扩展性、更好的性能、更强的 ROS 2 集成支持,并采用更现代的设计理念。Ignition Gazebo 是基于 Ignition Framework 进行开发的,这为其提供了更灵活和模块化的设计。
简单点说:Ignition Gazebo是Gazebo的未来。
而Ignition Gazebo又有好多个版本,ros2 humble自带的版本的版本名是 Gazebo Fortress,版本号是6.x;运行的时候,仿真窗口的窗口名是 Gazebo
Harmonic 版本号是 8.x;运行的时候,仿真窗口名是Gazebo Sim
Ignition Gazebo版本遵循 Gazebo Codename的形式,代号按字母顺序递增,并选择松散地属于架构领域。
gazebo版本
name | Data | EOL data | Notes |
---|---|---|---|
Jetty | Sep, 2025 | Sep, 2030 | LTS |
Ionic | Sep, 2024 | Sep, 2026 | |
Harmonic | Sep, 2023 | Sep, 2028 | LTS |
Garden | Sep, 2022 | Nov, 2024 | EOL |
Fortress | Sep, 2021 | Sep, 2026 | LTS |
Edifice | Mar, 2021 | Mar, 2022 | EOL |
Dome | Sep, 2020 | Dec, 2021 | EOL |
Citadel | Dec, 2019 | Dec, 2024 | EOL |
Blueprint | May, 2019 | Dec, 2020 | EOL |
Acropolis | Feb, 2019 | Sep, 2019 | EOL |
ign gazebo harmonic
gazebo sim version 8.8.0
安装
sudo apt-get update
sudo apt-get install curl lsb-release gnupg
sudo curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
sudo apt-get update
sudo apt-get install gz-harmonic
运行
# 打开一个包含三个简单形状的世界
gz sim shapes.sdf
# 运行雷达的仿真
gz sim -v 4 -r visualize_lidar.sdf
# 查看话题
gz topic -l
ign gazebo fortress
安装
sudo apt-get install ros-${ROS_DISTRO}-ros-gz
sudo apt install ros-humble-gazebo-ros-pkgs
# 桥接器 用于 ros2与gazebo Transport 之间交换信息
sudo apt-get install ros-humble-ros-ign-bridge
# 接受键盘信息并转为 twist
sudo apt-get install ros-humble-teleop-twist-keyboard
运行
# 运行仿真
ign gazebo -v 4 -r visualize_lidar.sdf
# 查看话题
ign topic -l
# 为/model/vehicle_blue/cmd_vel 创建桥接器
ros2 run ros_gz_bridge parameter_bridge /model/vehicle_blue/cmd_vel@geometry_msgs/msg/Twist]ignition.msgs.Twist
# 键盘控制节点
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=/model/vehicle_blue/cmd_vel
# lidar创建桥接器
ros2 run ros_gz_bridge parameter_bridge /lidar2@sensor_msgs/msg/LaserScan[ignition.msgs.LaserScan --ros-args -r /lidar2:=/laser_scan
# 深度相机仿真
ros2 launch ros_ign_gazebo_demos rgbd_camera_bridge.launch.py
turtlebot
安装
参考链接:https://turtlebot.github.io/turtlebot4-user-manual/software/turtlebot4_robot.html
git clone 慢
添加
https://ghfast.top/
git clone https://github.com/turtlebot/turtlebot4_robot.git -b humble
git clone https://ghfast.top/https://github.com/turtlebot/turtlebot4_robot.git -b humble
turtlebot3
gazebo 启动问题
export SVGA_VGPU10=0
export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:/home/ly/.gazebo/models
# 设置TurtleBot3模型
export TURTLEBOT3_MODEL=burger
# 启动TurtleBot3 World环境
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
turtlebot4
gazebo 启动问题
export SVGA_VGPU10=0
# 仿真launch
ros2 launch turtlebot4_ignition_bringup turtlebot4_ignition.launch.py
# 键盘控制节点
ros2 run teleop_twist_keyboard teleop_twist_keyboard
虚拟机打不开共享文件夹
sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other
ROS2_CAN
can_msgs::msg::Frame frame;
frame.id = 0x523;
frame.data = {0x03, 0x03, 0x01, 0x00, 0x00, 0x01};
frame.dlc = 6;
// 转换为发送需要的格式
const auto data_ptr = frame.data.data();
const auto data_size = frame.dlc;
RCLCPP_INFO(this->get_logger(), "frame.data.size(): %zu, frame.dlc: %zu",
frame.data.size(), frame.dlc);
// 正确调用发送接口
sender_->send(
data_ptr, 6,
CanId( frame.id,0,FrameType::DATA,StandardFrame_{}),
100ms
);