zoukankan      html  css  js  c++  java
  • Gazebo11的安装与启动

    Gazebo11的安装与启动
      iwehdio的博客园:https://www.cnblogs.com/iwehdio/

    1、安装Gazebo11

    • 因为之前虚拟机开Gazebo总闪退,参考了 https://blog.csdn.net/weixin_41754912/article/details/82861566 的方法可以打开,但是运行比较卡顿。

    • ROS Melodic 版本默认安装的是 Gazebo9,现在 Gazebo 最新版本是11,对 Gazebo 进行更新。

    • 首先,查看Gazebo版本。

      $ dpkg -l | grep gazebo
      
    • 应该出现的是 gazebo9 及其相关插件,卸载全部插件。

      $ sudo apt-get remove gazebo9 gazebo9-common gazebo9-plugin-base libgazebo9:amd64 libgazebo9-dev:amd64 ros-melodic-gazebo-*                   
      
    • 然后参考官网教程安装。设置镜像和 key 。

      $ sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
      $ wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
      
    • 安装 Gazebo11。

      $ sudo apt-get update
      $ sudo apt-get install gazebo11
      $ sudo apt-get install libgazebo11-dev
      
    • 输入 gazebo 即可运行。

    • 这样安装的问题是,单纯的安装 Gazebo,但没有安装 gazebo_ros_pkgs。之前 ROS-full 安装会自动安装,但是单独安装 Gazebo 还需要手动安装。

    • 官网上没有相关教程,查阅一些博客可知,gazebo_ros_pkgs 的官方仓库为 https://github.com/ros-simulation/gazebo_ros_pkgs
      记得选择 melodic-devel 分支。

    • 先创建工作空间,在 src 目录下克隆或者粘贴这些项目。

      $ cd ~/catkin_ws/src
      $ git clone https://github.com/ros-simulation/gazebo_ros_pkgs/tree/melodic-devel
      
    • 之前版本的 gazebo_ros 包中都会设置环境变量 gazebo_ros,现在也需要手动设置。在 home 下 ctrl + H 显示隐藏文件,在文件末尾加入环境变量。这样,就可以在 launch 文件中用 $(find gazebo_ros)指代这个路径。同时也加入工作空间的环境变量。

      export find gazebo_ros=/home/iwehdio/catkin_ws/src/gazebo_ros
      source /home/iwehdio/catkin_ws/devel/setup.bash
      

      如果不设置这个环境变量,也无法使用roslaunch gazebo_ros empty_world.launch等命令。

    2、用.world和launch文件启动Gazeb011

    • 使用之前 https://www.cnblogs.com/iwehdio/p/12751106.html 中的 model 模型文件。创建一个简单的 world ,smallcar.world。

      <?xml version="1.0" ?>
      <sdf version="1.7">
        <world name="default">
          <!-- 环境光 -->
          <include>
            <uri>model://sun</uri>
          </include>
          <!-- 地面 -->
          <include>
            <uri>model://ground_plane</uri>
            <script>
        <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/White</name>
            </script>
          </include>
          <!--模型 -->
          <model name='smallcar_demo'>
            <include>
              <uri>model://smallcar_demo</uri>
            </include>
          </model>
          
        </world>
      </sdf>
      
    • 将两个模型文件 model.config 和 model.sdf 放入 smallcar_demo 文件夹中。并将这个文件夹放入 .gazebo/model 下(.gazebo是隐藏文件夹)。

    • 在 smallcar.world 所在目录下打开终端,输入:

      $ gazebo smallcar.world
      

      即可打开世界:

    • 使用 launch 文件启动 world 文件,smallcar.launch的文件内容如下:

      <launch>
        <include file="$(find gazebo_ros)/launch/empty_world.launch">
          <arg name="world_name" value="~/Gazebo/smallcar.world"/>
        </include>
      </launch>
      

      如果之前没有设置gazebo_ros环境变量,将其完整路径键入也可。

    • 打开终端,输入:

      $ roslaunch smallcar smallcar.launch
      

      即可打开世界。

    • 如果需要直接打开 Gazebo,只需要在终端或者 alt+F2 弹出的对话框内输入 gazebo 回车即可。


    iwehdio的博客园:https://www.cnblogs.com/iwehdio/

  • 相关阅读:
    POJ 1988 Cube Stacking(带权并查集)
    POJ 1414 Life Line(搜索)
    POJ 3468 A Simple Problem with Integers (线段树多点更新模板)
    二叉树前序遍历+中序遍历->后序遍历
    POJ 1061 青蛙的约会(扩展欧几里得)
    XDOJ 1020 ACMer去刷题吧(基础dp)
    POJ 2823 Sliding Window (线段树区间查询)
    线段树学习(一)
    UVA 294 Divisors( 因子分解)
    YYN图论学习路线(推荐)
  • 原文地址:https://www.cnblogs.com/iwehdio/p/12756241.html
Copyright © 2011-2022 走看看