gazebo安装_【ROS 学习笔记】Gazebo

0. 简介

官网镇楼:

Gazebo​gazebosim.org
gazebo安装_【ROS 学习笔记】Gazebo_第1张图片

Gazebo 同我们常用的 vrep, adams 一样,都是内置物理引擎(Physics Engine)的动力学仿真软件,只不过 ROS 直接集成了 Gazebo,像其他开源软件(OpenCV,OMPL)一样。

By the way,vrep 也是提供了 ros 接口的,不过我一般用内置的 lua 脚本、外部的 python、甚至 matlab 来实现 vrep 仿真。

先看下 gazebo 官方教程有哪些版块,如下:

gazebo安装_【ROS 学习笔记】Gazebo_第2张图片
Gazebo tutorial: overview

再看下与 ROS 相关的版块有哪些,如下:

gazebo安装_【ROS 学习笔记】Gazebo_第3张图片
Gazebo_ros: overview

1. gazebo_ros_pkgs 元功能包

Gazebo 通过 gazebo_ros_pkgs元功能包与 ROS 建立连接。

https://github.com/ros-simulation/gazebo_ros_pkgs

gazebo_ros_pkgs is a set of ROS packages that provide the necessary interfaces to simulate a robot in the Gazebo 3D rigid body simulator for robots. It integrates with ROS using ROS messages, services and dynamic reconfigure.
From https:// wiki.ros.org/gazebo_ros _pkgs

gazebo_ros_pkgs 元功能包默认安装路径 opt/ros/kinetic/share,里面只有一个 package.xml 文件,看下里面的内容:



  gazebo_ros_pkgs 
  2.5.19
  Interface for using ROS with the Gazebo simulator.

  Jose Luis Rivero

  BSD,LGPL,Apache 2.0

  http://gazebosim.org/tutorials?cat=connect_ros
  https://github.com/ros-simulation/gazebo_ros_pkgs/issues
  https://github.com/ros-simulation/gazebo_ros_pkgs

  John Hsu, Nate Koenig, Dave Coleman

  catkin

  gazebo_dev
  gazebo_msgs
  gazebo_plugins
  gazebo_ros

  
    
  

gazebo_ros_pkgs 元功能包包含了gazebo_ros, gazebo_plugins, gazebo_msgs 子功能包,如下图所示:

gazebo安装_【ROS 学习笔记】Gazebo_第4张图片
gazebo_ros_pkgs interface
  • gazebo_ros: provides ROS plugins that offer message and service publishers for interfacing with Gazebo through ROS.
  • gazebo_plugins: robot-independent Gazebo plugins for sensors, motors and dynamic reconfigurable components.
  • gazebo_msgs: message and service data structures for interacting with Gazebo from ROS.

2. gazebo_ros

Usage:

rosrun gazebo_ros debug
rosrun gazebo_ros gazebo    # launch both the Gazebo server and GUI.
rosrun gazebo_ros gbdrun
rosrun gazebo_ros server
rosrun gazebo_ros client    # launch the Gazebo GUI
rosrun gazebo_ros spawn_model
rosrun gazebo_ros perf

(1)Using roslaunch to Open World Models

  • pkg="gazebo_ros"
  • 启动 empty Gazebo world
roslaunch gazebo_ros empty_world.launch

参数(Arguments):

  • paused: start Gazebo in a paused state (default false)
  • use_sim_time: tells ROS nodes asking for time to get the Gazebo-published simulation time, published over the ROS topic /clock (default true)
  • gui: Launch the user interface window of Gazebo (default true)
  • recording: enable gazebo state log recording
  • debug: start gzserver (Gazebo Server) in debug mode using gdb (default false)
  • verbose: run gzserver and gzclient with --verbose, printing errors and warnings to the terminal (default false)

其他的 Demo Worlds:

roslaunch gazebo_ros willowgarage_world.launch
roslaunch gazebo_ros mud_world.launch
roslaunch gazebo_ros shapes_world.launch
roslaunch gazebo_ros rubble_world.launch

其中,mud_world.launch文件内容如下:


  
  
     
    
    
    
    
    
  
  • CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(YOURROBOT_gazebo_plugins)

find_package(catkin REQUIRED COMPONENTS
  gazebo_ros
)

# Depend on system install of Gazebo
find_package(gazebo REQUIRED)

include_directories(include ${catkin_INCLUDE_DIRS} ${GAZEBO_INCLUDE_DIRS} ${SDFormat_INCLUDE_DIRS})

# Build whatever you need here
add_library(...) # TODO

catkin_package(
    DEPENDS
      gazebo_ros
    CATKIN_DEPENDS
    INCLUDE_DIRS
    LIBRARIES
)
  • package.xml
gazebo_ros
gazebo_ros

(2)Using roslaunch to Spawn URDF Robots

"ROS Service Call" Robot Spawn Method
This method uses a small python script called spawn_modelto make a service call request to the gazebo_rosROS node (named simply "gazebo" in the rostopic namespace) to add a custom URDF into Gazebo.
rosrun gazebo_ros spawn_model -file `rospack find MYROBOT_description`/urdf/MYROBOT.urdf -urdf -x 0 -y 0 -z 1 -model MYROBOT

# -file 指定 model xml 文件的路径
# -urdf 显示地指定 xml 文件是 urdf 文件
# -x -y -z 初始 pose

gazebo安装_【ROS 学习笔记】Gazebo_第5张图片
spawn_model

3. gazebo_plugins

(1)Plugins 类型

  • ModelPlugins: provide access to the physics::Model API
  • SensorPlugins: provide access to the sensors::Sensor API
  • VisualPlugins: provide access to the rendering::Visual API

(2)添加 ModelPlugins

ModelPluginis inserted in the URDF inside the element. It is wrapped with the pill, to indicate information passed to Gazebo.

例如:


  ... robot description ...
  
    
      ... plugin parameters ...
    
  
  ... robot description ...

(3)添加 SensorPlugins

Sensors in Gazebo are meant to be attached to links, so the element describing that sensor must be given a reference to that link.

例如:


  ... robot description ...
  
    ... link description ...
  

  
    
      ... sensor parameters ...
      
        ... plugin parameters ..
      
    
  

4. gazebo && ros_control

移步至之前的博客:

丁洪凯:【ROS 学习笔记】ros_control​zhuanlan.zhihu.com
gazebo安装_【ROS 学习笔记】Gazebo_第6张图片

gazebo安装_【ROS 学习笔记】Gazebo_第7张图片

你可能感兴趣的:(gazebo安装)