zoukankan      html  css  js  c++  java
  • 12.27-ros-gazebo基础

    gazebo与ROS的连接

    前言

    • 仿真平台搭建的参考

    参考

    connect to ROS
    Using roslaunch to start Gazebo, world files and URDF models

    学习记录

    与ROS的集成

    • gazebo7是独立的软件,与ROS的连接是通过gazebo_ros_pkgs包来完成的,这些包完成了很多工作,包括依赖关系,catkin支持,URDF和SDF文件的兼容,对ros_control的支持。
    • 这些接口主要包括:
    gazebo_ros
    gazebo_msgs
    gazebo_plugins
    gazebo_tests
    gazebo_worlds
    gazebo_tools
    gazebo_ros_api_plugin
    gazebo_ros_paths_plugin

    从旧版本升级

    • 查看网页吧,这里不赘述
    • 一个较大的变化是gazebo变成的gazebo_ros

    Launch Files

    CMakeLists.txt

    package.xml

    安装gazebo_ros_pkgs

    sudo apt-get install ros-kinetic-gazebo-ros-pkgs ros-kinetic-gazebo-ros-control
    • 测试安装
    roscore &
    rosrun gazebo_ros gazebo

    启动一个环境

    <launch>
      <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
      <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="worlds/mud.world"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable -->
        <arg name="paused" value="false"/>
        <arg name="use_sim_time" value="true"/>
        <arg name="gui" value="true"/>
        <arg name="headless" value="false"/>
        <arg name="debug" value="false"/>
      </include>
    </launch>
    • 环境文件是一个sdf描述文件
    <sdf version="1.4">
        <world name="default">
          <include>
            <uri>model://sun</uri>
          </include>
          <include>
            <uri>model://ground_plane</uri>
          </include>
          <include>
            <uri>model://double_pendulum_with_base</uri>
            <name>pendulum_thick_mud</name>
            <pose>-2.0 0 0 0 0 0</pose>
          </include>
          ...
        </world>
      </sdf>

    创建项目

    实际操作

    roslaunch来渲染你的URDF格式的机器人模型

    • 调用ROS service
    rosrun gazebo_ros spawn_model -file `rospack find MYROBOT_description`/urdf/MYROBOT.urdf -urdf -x 0 -y 0 -z 1 -model MYROBOT
    rosrun gazebo_ros spawn_model -file `rospack find baxter_description`/urdf/baxter.urdf -urdf -z 1 -model baxter
    • 使用roslaunch
    <!-- Spawn a robot into Gazebo -->
    <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-file $(find baxter_description)/urdf/baxter.urdf -urdf -z 1 -model baxter" />
    • XACRO 例子
    <!-- Convert an xacro and put on parameter server -->
    <param name="robot_description" command="$(find xacro)/xacro.py $(find pr2_description)/robots/pr2.urdf.xacro" />
    
    <!-- Spawn a robot into Gazebo -->
    <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model pr2" />

    使用机器人模型库中的模型

    需要实际操作

    在package.xml中声明model paths

    <export>
      <gazebo_ros gazebo_model_path="${prefix}/models"/>
      <gazebo_ros gazebo_media_path="${prefix}/models"/>
    </export>

    使用插件

    • 插件可以根据需要添加到sdf文件中,可以添加到等元素下。如果需要添加定义到URDF文件下,你需要先用元素包裹元素。

    将插件插入到元素下

    <gazebo>
      <plugin name="differential_drive_controller" filename="libdiffdrive_plugin.so">
        ... plugin parameters ...
      </plugin>
    </gazebo>
    • 如果是URDF文件下,有一个特性支持自动转化为SDF下的元素下
    <model name="your_robot_model">
      <plugin name="differential_drive_controller" filename="libdiffdrive_plugin.so">
        ... plugin parameters ...
      </plugin>
    </model>

    将插件插入到元素下(同理)

    <gazebo reference="your_link_name">
      <plugin name="your_link_laser_controller" filename="libgazebo_ros_laser.so">
        ... plugin parameters ...
      </plugin>
    </gazebo>

    如果 reference没有值,则默认为整个机器人

  • 相关阅读:
    分享jQuery的常用技巧12招
    浅析淘宝数据魔方技术架构
    JavaScript的跨域共享的方法
    PHP实现QQ达人信息抓取
    Dreamweaver CS5.5试用小感和破解方法附下载地址
    ExtJS 4应用架构设计
    webkit webApp 开发技术要点总结
    用delphi编写ISAPI过滤器
    1020卡免费共享测试!
    一些有用的網站
  • 原文地址:https://www.cnblogs.com/lizhensheng/p/11117522.html
Copyright © 2011-2022 走看看