Gazebo仿真环境搭建(04)

Gazebo 中创建仿真实现方式有两种:
1.直接添加内置组件创建仿真环境
1.1启动 Gazebo 并添加组件
在这里插入图片描述
1.2保存仿真环境
添加完毕后,选择 file —> Save World as 选择保存路径(功能包下: worlds 目录),文件名自定义,后缀名设置为 .world
在这里插入图片描述
1.3 启动

<launch>

    <!-- 将 Urdf 文件的内容加载到参数服务器 -->
    <param name="robot_description" command="$(find xacro)/xacro $(find demo02_urdf_gazebo)/urdf/xacro/my_base_camera_laser.urdf.xacro" />
    <!-- 启动 gazebo -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(find demo02_urdf_gazebo)/worlds/hello.world" />
    </include>

    <!-- 在 gazebo 中显示机器人模型 -->
    <node pkg="gazebo_ros" type="spawn_model" name="model" args="-urdf -model mycar -param robot_description"  />
</launch>

核心代码: 启动 empty_world 后,再根据arg加载自定义的仿真环境

<include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find demo02_urdf_gazebo)/worlds/hello.world" />
</include>

2.自定义仿真环境
2.1 启动 gazebo 打开构建面板,绘制仿真环境
在这里插入图片描述在这里插入图片描述2.2 保存构建的环境

点击: 左上角 file —> Save (保存路径功能包下的: models)
然后 file —> Exit Building Editor

2.3 保存为 world 文件
可以像方式1一样再添加一些插件,然后保存为 world 文件(保存路径功能包下的: worlds)

在这里插入图片描述
2.4 启动
同方式1

3.使用官方提供的插件
当前 Gazebo 提供的仿真道具有限,还可以下载官方支持,可以提供更为丰富的仿真实现,具体实现如下:

3.1 下载官方模型库
git clone https://github.com/osrf/gazebo_models
之前是:hg clone https://bitbucket.org/osrf/gazebo_models但是已经不可用
注意: 此过程可能比较耗时

3.2 将模型库复制进 gazebo
将得到的gazebo_models文件夹内容复制到 /usr/share/gazebo-*/models

3.3 应用
重启 Gazebo,选择左侧菜单栏的 insert 可以选择并插入相关道具了

  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值