文章目录

  • world文件编写
    • 物理属性设置
  • model文件编写
  • gazebo中提供的服务

world文件编写

<?xml version="1.0"?>

<sdf version='1.6'>
  <world name=''>
  
    <!-- basic tag -->
  
    <physics>
    </physics>
    
    <scene>
    </scene>
    
	<light>
	</light>
	
	<!-- It is better to discribe the model in model file, and include the model file in <include> tag -->
    <!-- e.g. -->
    <include>
      <uri>model://sea_usrface</uri>
      <pose>0 0 0 0 0 0</pose>
    </include>

  </world>
</sdf>

这里要注意<uri>标签的使用:
In the package.xml of the package where you want to load the model (or just any package that gets loaded before your models are needed), declare the following export:

<export>
	<!-- gazebo_ros_paths_plugin automatically adds these to GAZEBO_PLUGIN_PATH and GAZEBO_MODEL_PATH 
	when you so this inside the package.xml file. 
	You can then use URIs of type model://my_package/stuff. -->
	<gazebo_ros gazebo_plugin_path="${prefix}/lib" gazebo_model_path="${prefix}/.." />
</export>

(The ${prefix} refers to the directory that package.xml is in.)

After doing this and loading the package (running a node from it? I don’t know exactly.), you are allowed to specify things like <uri>model://my_package/models/foo.dae</uri>. reference

物理属性设置

    <physics name="default_physics" default="true" type="ode">
      <max_step_size>0.01</max_step_size>
      <real_time_factor>1</real_time_factor>
      <real_time_update_rate>1000</real_time_update_rate>
      <ode>
        <solver>
          <type>quick</type>
          <iters>50</iters>
          <sor>1.2</sor>
        </solver>
      </ode>
    </physics>

下面逐个解释上面的标签:

<max_step_size>
这个参数指定了每个物理更新步骤的持续时间(秒)。
<real_time_factor>
<real_time_update_rate>
该参数以赫兹为单位指定每秒尝试的物理更新次数。如果这个数字设为0,它就会尽可能快地运行。注意,<real_time_update_rate>和<max_step_size>的乘积表示 the target <real_time_factor>,即模拟时间与实时的比率。
Gazebo官网对此部分的解释。

注意:
在三个参数是会动态调整的。

model文件编写
gazebo中提供的服务
/gazebo/set_model_state 和 /gazebo/get_model_state

/gazebo/reset_simulation