Gazebo Virtual Simulation
Hint
The operating environment and software and hardware configurations are as follows:
- PC:Ubuntu (≥22.04) + ROS2 (≥humble)
Development environment configuration
Install Ubuntu+ROS2 system on PC, and download and compile the originbot_desktop code repository.
For detailed operation methods, please see: Download/Compile the PC Function Pack
3D model visualization
Run the following command on the PC:
You can load the 3D model of the robot, and start the visualization interface of the Rviz2 host computer to display the 3D model of the robot:
3D simulation environment
Install dependencies
Before running the simulation environment, now confirm that the following feature packs are installed on the PC:
sudo apt install ros-${ROS_DISTRO}-gazebo-ros
sudo apt install ros-${ROS_DISTRO}-gazebo-ros2-control
sudo apt install ros-${ROS_DISTRO}-gazebo-plugins
sudo apt install ros-${ROS_DISTRO}-ros2-control
sudo apt install ros-${ROS_DISTRO}-ros2-controllers
Start the simulation
Start the terminal, run the following command, and wait for the Gazebo simulation software to start:
Hint
- In order to ensure the smooth loading of the model, please download and place the offline model file library under ~/.gazebo/models, otherwise Gazebo may not start. Click to download the offline model
- If you can't display the robot model using the virtual machine, you need to turn off "Accelerate 3D graphics" in the virtual machine settings, add "export SVGA_VGPU10=0" to the .bashrc on Ubuntu system, and use the CPU to render Gazebo.
View simulation data
Whether the data in the current simulation environment has been successfully simulated, we can confirm through the topic list:
It can be seen that in the current simulation environment, speed control, odometer, camera images, lidar data, etc. have been successfully simulated.
Control robot movement
Start a new terminal and run the keyboard control node to control the robot motion in the simulation environment through the keyboard:
View sensor visualization data
先Start by putting some obstacles in the simulation environment:
Then launch Rviz:
Configure the display items of Image and LaserScan in Rviz, subscribe to the corresponding topic, and you can see the visualization effect: