【2022】Ubuntu18.04 installs Gazebo9 and connects with ROS (including various error reports and solutions)

Table of contents

1. Install Gazebo

STEP1 Set up your computer to accept software from package.osrfoundation.org

STEP2 Add key

STEP3 Install Gazebo

1. Update the software source, and then execute the command to install Gazebo

2. Download and install the Gazebo 9 version package

3. Install Gazebo 9 development library.

2. Connection between Gazebo and ROS

STEP4 Install ROS Melodic and Gazebo related packages

STEP5 Verify whether the connection is successful

1. Start the core node of ROS (Robot Operating System)

2. Start the Gazebo simulation environment

3. Error reporting and solutions

STEP6 If you find that Gazebo stays on the startup interface for a long time after opening in the previous step, and displays a black screen (no grid), turn off Gazebo, and execute the following statements in sequence

error 1

correct mistakes

error 2

correct mistakes

 STEP7 re-verify whether the connection is successful

connection succeeded:


1. Install Gazebo

Note: Ubuntu 18.04 needs to download the Gazebo9 version, don't mistake the version of Gazebo

If you have downloaded other versions of Gazebo, please execute the following command to uninstall

sudo apt-get remove gazebo-*

STEP 1 Set up your computer to accept software from package.osrfoundation.org

Terminal input:

sudo sh -c 'echo "deb 

show:

http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'

STEP 2 Add key

        Downloads a GPG key file ( gazebo.key) from the specified URL, pipes its contents (|) into  apt-key the command, and  sudo executes it with superuser privileges  apt-key add. This will add the key to the apt package manager's trusted keystore so that packages signed with that key can be installed and verified.

Terminal input:

wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

show:

--2022-10-16 20:28:26--  https://packages.osrfoundation.org/gazebo.key
Resolving packages.osrfoundation.org (packages.osrfoundation.org)... 52.52.171.73
Connecting to packages.osrfoundation.org (packages.osrfoundation.org)|52.52.171.73|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1772 (1.7K) [application/octet-stream]
Saving to: ‘STDOUT’

-                   100%[===================>]   1.73K  --.-KB/s    in 0s      

2022-10-16 20:28:27 (82.2 MB/s) - written to stdout [1772/1772]

OK

STEP 3 Install Gazebo

Enter the terminal in turn:

1. Update the software source, and then execute the command to install Gazebo

sudo apt-get update && sudo apt-get upgrade

2. Download and install the Gazebo 9 version package

sudo apt-get install gazebo9
  • Gazebo is a 3D robot simulator that can be used to test and display robot models.
  • To install Gazebo, you need to install some basic software that depends on it first, and the apt command will automatically install it.
  • After the installation is complete, you can use gazebothe command to start the Gazebo emulator in the terminal.

Gazebo 9 is a relatively stable old version. If it is a new project, it is recommended to install a newer version of Gazebo, for example:

  • Gazebo 11:
sudo apt-get install gazebo11
  • The latest version of Gazebo is the current version and the current version is Gazebo 12:
sudo apt-get install gazebo

(If the version of Gazebo has been installed before, installing the new version will not overwrite the previous version)

3. Install Gazebo 9 development library.

sudo apt-get install libgazebo9-dev

        The development library is a tool for compiling and developing Gazebo plug-ins, extensions and custom functions. The following command will download and install the Gazebo 9 development library and its dependencies from the Ubuntu repositories. After the installation is complete, you can start using the Gazebo 9 development library to develop your own projects.

2. Connection between Gazebo and ROS

STEP 4 Install ROS Melodic and Gazebo related packages

sudo apt install ros-melodic-gazebo-ros-pkgs  ros-melodic-gazebo-msgs  ros-melodic-gazebo-plugins  ros-melodic-gazebo-ros-control

There are:

  • ros-melodic-gazebo-ros-pkgs : ROS packages related to the Gazebo simulator

  • ros-melodic-gazebo-msgs : Gazebo message type definition

  • ros-melodic-gazebo-plugins : Gazebo插件

  • ros-melodic-gazebo-ros-control : ROS controller interface with Gazebo
    These packages allow ROS nodes to interact with the Gazebo environment, such as:

  • Subscribe to object information in Gazebo

  • Control objects in Gazebo

  • Communicating with the Gazebo physics engine

After the installation is complete, you can use the package in the ROS node gazebo_rosto interact with the Gazebo world.

STEP 5 verify whether the connection is successful

1. Start the core node of ROS (Robot Operating System)

 roscore

        Roscore provides the basic services required by the ROS system, including parameter servers, message transmission, and node communication. After executing the command in the terminal  roscore , ROS will start a  roscore process called This process will monitor each node in the ROS system and provide them with various services. After starting roscore, you can start running other ROS nodes and related programs, which will communicate with roscore and utilize the services it provides.

2. Start the Gazebo simulation environment

rosrun gazebo_ros gazebo

    This command runs the gazebo node from the Gazebo ROS package, which loads the Gazebo emulator and provides a ROS interface. Once the command is successfully executed, the Gazebo simulation environment starts and can use ROS messaging to control the simulation scene, robot model or other physical entities.

3. Error reporting and solutions

STEP 6 If you find that Gazebo stays on the startup interface for a long time after opening in the previous step, and displays a black screen (no grid), turn off Gazebo, and execute the following statements in sequence

~/.gazebo/ Create a directory under the directory          ,  models download the list of model files and unzip the files.

  • switch to  ~/.gazebo/ directory
cd ~/.gazebo/
  • Create a  models directory named . If the directory already exists, no error will be generated because  -p the option
mkdir -p models
  • switch to  ~/.gazebo/models/ directory
cd ~/.gazebo/models/
  • Use  wget the command to download  gazebo_models.txt the file to the current directory.
wget http://file.ncnynl.com/ros/gazebo_models.txt
  • Use  wget the command to read  gazebo_models.txt the model file URLs listed in the file and download those files to the current directory.
wget -i gazebo_models.txt
  • List  model.tar.g the files starting with in the current directory, and use  xargs the command to execute  tar xzvf commands one by one to decompress these files
 ls model.tar.g* | xargs -n1 tar xzvf

error 1

[ INFO] [1665923863.099798768]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1665923863.111388523]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1665923866.814475043]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1665923866.982214681]: Physics dynamic reconfigure ready.
[Err] [REST.cc:205] Error in REST request

libcurl: (51) SSL: no alternative certificate subject name matches target host name 'api.ignitionfuel.org'
VMware: vmw_ioctl_command error Invalid argument.
^[aAborted (core dumped)

correct mistakes

 sudo gedit ~/.ignition/fuel/config.yaml

error 2

[ INFO] [1665929397.262289602]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1665929397.264244460]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1665929399.188514866]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1665929399.243283924, 0.004000000]: Physics dynamic reconfigure ready.
VMware: vmw_ioctl_command error Invalid argument.
Aborted (core dumped)

correct mistakes

Set the environment variable to 0 under the terminal

temporary:

export SVGA_VGPU10=0

permanent:

echo "export SVGA_VGPU10=0" >> ~/.bashrc

 STEP 7 re-verifies whether the connection is successful

roscore
 rosrun gazebo_ros gazebo

connection succeeded:

Guess you like

Origin blog.csdn.net/m0_63834988/article/details/132020603