致谢源代码网址:https://github.com/Tutorgaming/kamtoa-simulation

kamtoa simulation学习与示例分析(一)





源码学习与分析是学习ROS,包括RVIZ和Gazebo等必须的过程,大量代码的阅读能够提高加快理解熟练使用ROS Kinetic。

首先,先看文件组织:


一般README中有详细的使用说明,包括安装,使用和示例教程。

CMakeLists.txt:

# toplevel CMakeLists.txt for a catkin workspace
# catkin/cmake/toplevel.cmake

cmake_minimum_required(VERSION 2.8.3)

set(CATKIN_TOPLEVEL TRUE)

# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
execute_process(COMMAND ${_cmd}
  RESULT_VARIABLE _res
  OUTPUT_VARIABLE _out
  ERROR_VARIABLE _err
  OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_STRIP_TRAILING_WHITESPACE
)
if(NOT _res EQUAL 0 AND NOT _res EQUAL 2)
  # searching fot catkin resulted in an error
  string(REPLACE ";" " " _cmd_str "${_cmd}")
  message(FATAL_ERROR "Search for 'catkin' in workspace Failed (${_cmd_str}): ${_err}")
endif()

# include catkin from workspace or via find_package()
if(_res EQUAL 0)
  set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/${_out}/cmake")
  # include all.cmake without add_subdirectory to let it operate in same scope
  include(${catkin_EXTRAS_DIR}/all.cmake NO_POLICY_ScopE)
  add_subdirectory("${_out}")

else()
  # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
  # or CMAKE_PREFIX_PATH from the environment
  if(NOT DEFINED CMAKE_PREFIX_PATH)
    if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
      string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
    endif()
  endif()

  # list of catkin workspaces
  set(catkin_search_path "")
  foreach(path ${CMAKE_PREFIX_PATH})
    if(EXISTS "${path}/.catkin")
      list(FIND catkin_search_path ${path} _index)
      if(_index EQUAL -1)
        list(APPEND catkin_search_path ${path})
      endif()
    endif()
  endforeach()

  # search for catkin in all workspaces
  set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
  find_package(catkin QUIET
    NO_POLICY_ScopE
    PATHS ${catkin_search_path}
    NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  unset(CATKIN_TOPLEVEL_FIND_PACKAGE)

  if(NOT catkin_FOUND)
    message(FATAL_ERROR "find_package(catkin) Failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was sourced before.")
  endif()
endif()

catkin_workspace()

这里,先看kamtoa_gazebo文件夹下:


CMakeLists.txt中包含需要的功能包,如下截取部分代码片段:

cmake_minimum_required(VERSION 2.8.3)
project(kamtoa_gazebo)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin required COMPONENTS xyz)
## is used,also find other catkin packages
find_package(catkin required COMPONENTS
  gazebo_msgs
  gazebo_plugins
  gazebo_ros
  gazebo_ros_control
  kamtoa_description
)

## System dependencies are found with CMake's conventions
# find_package(Boost required COMPONENTS system)

需要的功能包如果不全,可以使用sudo apt-get install ros-kinetic-gazebo-msgs,以类似方式安装(catkin)。当然编译需要对应的功能包,运行也需要,这里缺一不可,请看package.xml:

<?xml version="1.0"?>
<package>
  <name>kamtoa_gazebo</name>
  <version>0.0.0</version>
  <description>The kamtoa_gazebo package</description>

  <!-- One maintainer tag required,multiple allowed,one person per tag --> 
  <!-- Example:  -->
  <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
  <maintainer email="c3mx@todo.todo">c3mx</maintainer>


  <!-- One license tag required,one license per tag -->
  <!-- Commonly used license strings: -->
  <!--   BSD,MIT,Boost Software License,GPLv2,GPLv3,LGPLv2.1,LGPLv3 -->
  <license>Todo</license>


  <!-- Url tags are optional,but mutiple are allowed,one per tag -->
  <!-- Optional attribute type can be: website,bugtracker,or repository -->
  <!-- Example: -->
  <!-- <url type="website">http://wiki.ros.org/kamtoa_gazebo</url> -->


  <!-- Author tags are optional,mutiple are allowed,one per tag -->
  <!-- Authors do not have to be maintianers,but Could be -->
  <!-- Example: -->
  <!-- <author email="jane.doe@example.com">Jane Doe</author> -->


  <!-- The *_depend tags are used to specify dependencies -->
  <!-- Dependencies can be catkin packages or system dependencies -->
  <!-- Examples: -->
  <!-- Use build_depend for packages you need at compile time: -->
  <!--   <build_depend>message_generation</build_depend> -->
  <!-- Use buildtool_depend for build tool packages: -->
  <!--   <buildtool_depend>catkin</buildtool_depend> -->
  <!-- Use run_depend for packages you need at runtime: -->
  <!--   <run_depend>message_runtime</run_depend> -->
  <!-- Use test_depend for packages you need only for testing: -->
  <!--   <test_depend>gtest</test_depend> -->
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>gazebo_msgs</build_depend>
  <build_depend>gazebo_plugins</build_depend>
  <build_depend>gazebo_ros</build_depend>
  <build_depend>gazebo_ros_control</build_depend>
  <build_depend>kamtoa_description</build_depend>
  <run_depend>gazebo_msgs</run_depend>
  <run_depend>gazebo_plugins</run_depend>
  <run_depend>gazebo_ros</run_depend>
  <run_depend>gazebo_ros_control</run_depend>
  <run_depend>kamtoa_description</run_depend>


  <!-- The export tag contains other,unspecified,tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->

  </export>
</package>

注意这里的<build_depend>和<run_depend>,分别对应编译和运行, 有时编译没有问题,运行却报错,请务必注意。

world文件夹下存放gazebo模型,打开可以看到:


building1.world和whiz_ex.world,具体解析可以参考博客中GazeboSim中内容,具体的模型文件为sdf 1.6对应Gazebo7,以whiz_ex_window为例,分为model.config和model.sdf如下:

model.sdf:

<?xml version='1.0'?>
<sdf version='1.6'>
  <model name='whiz_ex_window'>
    <pose frame=''>0.232213 1.38881 0 0 -0 0</pose>
    <link name='Door_6'>
      <collision name='Door_6_Collision'>
        <geometry>
          <Box>
            <size>0.9 0.17 2</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1 0 -0 0</pose>
      </collision>
      <visual name='Door_6_Visual'>
        <pose frame=''>0 0 1 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.9 0.17 2</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
        </material>
      </visual>
      <pose frame=''>0.29567 1.0429 0 0 0 -3.12055</pose>
    </link>
    <link name='Door_7'>
      <collision name='Door_7_Collision'>
        <geometry>
          <Box>
            <size>0.949838 0.2 2</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1 0 -0 0</pose>
      </collision>
      <visual name='Door_7_Visual'>
        <pose frame=''>0 0 1 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.949838 0.2 2</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
        </material>
      </visual>
      <pose frame=''>-0.776238 1.0429 0 0 -0 3.14159</pose>
    </link>
    <link name='Door_8'>
      <collision name='Door_8_Collision'>
        <geometry>
          <Box>
            <size>0.9 0.17 2</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1 0 -0 0</pose>
      </collision>
      <visual name='Door_8_Visual'>
        <pose frame=''>0 0 1 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.9 0.17 2</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
        </material>
      </visual>
      <pose frame=''>-4.14363 1.09228 0 0 -0 0</pose>
    </link>
    <link name='Door_9'>
      <collision name='Door_9_Collision'>
        <geometry>
          <Box>
            <size>0.9 0.17 2</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1 0 -0 0</pose>
      </collision>
      <visual name='Door_9_Visual'>
        <pose frame=''>0 0 1 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.9 0.17 2</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
        </material>
      </visual>
      <pose frame=''>-1.75347 -0.819856 0 0 0 -3.12358</pose>
    </link>
    <link name='Wall_0'>
      <pose frame=''>-1.6817 -3.67821 0 0 -0 0</pose>
      <visual name='Wall_0_Visual_0'>
        <pose frame=''>-1.17971 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>5.89059 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_0_Collision_0'>
        <geometry>
          <Box>
            <size>5.89059 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>-1.17971 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_0_Visual_1'>
        <pose frame=''>3.9453 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.35941 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_0_Collision_1'>
        <geometry>
          <Box>
            <size>0.35941 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>3.9453 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_0_Visual_2'>
        <pose frame=''>2.76559 0 0 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2 0.15 0</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_0_Collision_2'>
        <geometry>
          <Box>
            <size>2 0.15 0</size>
          </Box>
        </geometry>
        <pose frame=''>2.76559 0 0 0 -0 0</pose>
      </collision>
      <visual name='Wall_0_Visual_3'>
        <pose frame=''>2.76559 0 2.45 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2 0.15 0.1</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_0_Collision_3'>
        <geometry>
          <Box>
            <size>2 0.15 0.1</size>
          </Box>
        </geometry>
        <pose frame=''>2.76559 0 2.45 0 -0 0</pose>
      </collision>
    </link>
    <link name='Wall_1'>
      <collision name='Wall_1_Collision'>
        <geometry>
          <Box>
            <size>3.75 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_1_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>3.75 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>2.3683 -1.87821 0 0 -0 1.5708</pose>
    </link>
    <link name='Wall_13'>
      <collision name='Wall_13_Collision'>
        <geometry>
          <Box>
            <size>9.25 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_13_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>9.25 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-1.19255 3.74668 0 0 -0 3.14159</pose>
    </link>
    <link name='Wall_15'>
      <pose frame=''>-4.65794 2.07148 0 0 0 -1.5708</pose>
      <visual name='Wall_15_Visual_0'>
        <pose frame=''>-1.67569 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.148611 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_15_Collision_0'>
        <geometry>
          <Box>
            <size>0.148611 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>-1.67569 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_15_Visual_1'>
        <pose frame=''>1.07431 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>1.35139 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_15_Collision_1'>
        <geometry>
          <Box>
            <size>1.35139 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>1.07431 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_15_Visual_2'>
        <pose frame=''>-0.601389 0 2.4 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2 0.15 0.2</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_15_Collision_2'>
        <geometry>
          <Box>
            <size>2 0.15 0.2</size>
          </Box>
        </geometry>
        <pose frame=''>-0.601389 0 2.4 0 -0 0</pose>
      </collision>
    </link>
    <link name='Wall_16'>
      <collision name='Wall_16_Collision'>
        <geometry>
          <Box>
            <size>1.25 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_16_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>1.25 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-5.20794 0.396477 0 0 -0 3.14159</pose>
    </link>
    <link name='Wall_17'>
      <pose frame=''>-5.75794 -1.65352 0 0 0 -1.5708</pose>
      <visual name='Wall_17_Visual_0'>
        <pose frame=''>-1.07794 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2.09412 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_17_Collision_0'>
        <geometry>
          <Box>
            <size>2.09412 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>-1.07794 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_17_Visual_1'>
        <pose frame=''>1.04706 0 0.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2.15588 0.15 0.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_17_Collision_1'>
        <geometry>
          <Box>
            <size>2.15588 0.15 0.5</size>
          </Box>
        </geometry>
        <pose frame=''>1.04706 0 0.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_17_Visual_2'>
        <pose frame=''>2.01762 0 1.5 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.214766 0.15 2</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_17_Collision_2'>
        <geometry>
          <Box>
            <size>0.214766 0.15 2</size>
          </Box>
        </geometry>
        <pose frame=''>2.01762 0 1.5 0 -0 0</pose>
      </collision>
      <visual name='Wall_17_Visual_3'>
        <pose frame=''>0.939679 0 1.9 0 -0 0</pose>
        <geometry>
          <Box>
            <size>1.94111 0.15 1.2</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_17_Collision_3'>
        <geometry>
          <Box>
            <size>1.94111 0.15 1.2</size>
          </Box>
        </geometry>
        <pose frame=''>0.939679 0 1.9 0 -0 0</pose>
      </collision>
    </link>
    <link name='Wall_19'>
      <collision name='Wall_19_Collision'>
        <geometry>
          <Box>
            <size>2.5 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_19_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2.5 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-2.53404 1.06604 0 0 -0 0</pose>
    </link>
    <link name='Wall_20'>
      <collision name='Wall_20_Collision'>
        <geometry>
          <Box>
            <size>2 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_20_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-1.35904 0.141035 0 0 0 -1.5708</pose>
    </link>
    <link name='Wall_21'>
      <collision name='Wall_21_Collision'>
        <geometry>
          <Box>
            <size>0.25 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_21_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.25 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-1.40904 -0.783965 0 0 -0 3.14159</pose>
    </link>
    <link name='Wall_23'>
      <collision name='Wall_23_Collision'>
        <geometry>
          <Box>
            <size>3.5 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_23_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>3.5 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-3.91607 -0.818528 0 0 -0 3.14159</pose>
    </link>
    <link name='Wall_24'>
      <collision name='Wall_24_Collision'>
        <geometry>
          <Box>
            <size>0.25 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_24_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.25 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-5.64107 -0.818528 0 0 -0 3.14159</pose>
    </link>
    <link name='Wall_26'>
      <collision name='Wall_26_Collision'>
        <geometry>
          <Box>
            <size>2 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_26_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-3.31229 0.121197 0 0 0 -1.5708</pose>
    </link>
    <link name='Wall_28'>
      <collision name='Wall_28_Collision'>
        <geometry>
          <Box>
            <size>1.75 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_28_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>1.75 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-1.86043 2.95447 0 0 0 -1.5708</pose>
    </link>
    <link name='Wall_30'>
      <collision name='Wall_30_Collision'>
        <geometry>
          <Box>
            <size>0.75 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_30_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.75 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-1.56043 2.15447 0 0 -0 0</pose>
    </link>
    <link name='Wall_32'>
      <collision name='Wall_32_Collision'>
        <geometry>
          <Box>
            <size>2.75 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_32_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2.75 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-0.228595 2.39065 0 0 0 -1.5708</pose>
    </link>
    <link name='Wall_35'>
      <collision name='Wall_35_Collision'>
        <geometry>
          <Box>
            <size>2.75 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_35_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2.75 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>1.29304 2.34692 0 0 0 -1.5708</pose>
    </link>
    <link name='Wall_37'>
      <collision name='Wall_37_Collision'>
        <geometry>
          <Box>
            <size>1.5 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_37_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>1.5 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>1.36463 1.03216 0 0 -0 0</pose>
    </link>
    <link name='Wall_4'>
      <pose frame=''>4.05869 -2.66379 0 0 -0 0</pose>
      <visual name='Wall_4_Visual_0'>
        <pose frame=''>-1.38368 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.732645 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_4_Collision_0'>
        <geometry>
          <Box>
            <size>0.732645 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>-1.38368 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_4_Visual_1'>
        <pose frame=''>1.61632 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.267355 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_4_Collision_1'>
        <geometry>
          <Box>
            <size>0.267355 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>1.61632 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_4_Visual_2'>
        <pose frame=''>0.232645 0 2.45 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2.5 0.15 0.1</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_4_Collision_2'>
        <geometry>
          <Box>
            <size>2.5 0.15 0.1</size>
          </Box>
        </geometry>
        <pose frame=''>0.232645 0 2.45 0 -0 0</pose>
      </collision>
    </link>
    <link name='Wall_41'>
      <collision name='Wall_41_Collision'>
        <geometry>
          <Box>
            <size>0.25 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_41_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.25 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-0.228595 1.04065 0 0 0 -1.5708</pose>
    </link>
    <link name='Wall_44'>
      <collision name='Wall_44_Collision'>
        <geometry>
          <Box>
            <size>3.75 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_44_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>3.75 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>-0.233629 -1.95772 0 0 0 -1.5708</pose>
    </link>
    <link name='Wall_50'>
      <pose frame=''>5.74567 0.386841 0 0 0 -1.57472</pose>
      <visual name='Wall_50_Visual_0'>
        <pose frame=''>-2.83254 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.586231 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_50_Collision_0'>
        <geometry>
          <Box>
            <size>0.586231 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>-2.83254 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_50_Visual_1'>
        <pose frame=''>1.30211 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>3.64708 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_50_Collision_1'>
        <geometry>
          <Box>
            <size>3.64708 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>1.30211 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_50_Visual_2'>
        <pose frame=''>-1.53042 0 2.4 0 -0 0</pose>
        <geometry>
          <Box>
            <size>2.018 0.15 0.2</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_50_Collision_2'>
        <geometry>
          <Box>
            <size>2.018 0.15 0.2</size>
          </Box>
        </geometry>
        <pose frame=''>-1.53042 0 2.4 0 -0 0</pose>
      </collision>
    </link>
    <link name='Wall_52'>
      <pose frame=''>4.58265 3.43747 0 0 -0 3.14159</pose>
      <visual name='Wall_52_Visual_0'>
        <pose frame=''>-0.530284 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>1.43943 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_52_Collision_0'>
        <geometry>
          <Box>
            <size>1.43943 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>-0.530284 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_52_Visual_1'>
        <pose frame=''>1.16972 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.160568 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_52_Collision_1'>
        <geometry>
          <Box>
            <size>0.160568 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>1.16972 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_52_Visual_2'>
        <pose frame=''>0.639432 0 2.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.9 0.15 0.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_52_Collision_2'>
        <geometry>
          <Box>
            <size>0.9 0.15 0.5</size>
          </Box>
        </geometry>
        <pose frame=''>0.639432 0 2.25 0 -0 0</pose>
      </collision>
    </link>
    <link name='Wall_53'>
      <collision name='Wall_53_Collision'>
        <geometry>
          <Box>
            <size>0.463251 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_53_Visual'>
        <pose frame=''>0 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.463251 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <pose frame=''>3.38255 3.59207 0 0 -0 1.73174</pose>
    </link>
    <link name='Wall_55'>
      <pose frame=''>1.06733 -0.11797 0 0 -0 0.030549</pose>
      <visual name='Wall_55_Visual_0'>
        <pose frame=''>-1.28558 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.181978 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_55_Collision_0'>
        <geometry>
          <Box>
            <size>0.181978 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>-1.28558 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_55_Visual_1'>
        <pose frame=''>0.540989 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>1.67116 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_55_Collision_1'>
        <geometry>
          <Box>
            <size>1.67116 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0.540989 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_55_Visual_2'>
        <pose frame=''>-0.744593 0 2.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.9 0.15 0.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_55_Collision_2'>
        <geometry>
          <Box>
            <size>0.9 0.15 0.5</size>
          </Box>
        </geometry>
        <pose frame=''>-0.744593 0 2.25 0 -0 0</pose>
      </collision>
    </link>
    <link name='Wall_57'>
      <pose frame=''>-0.766361 -0.161298 0 0 -0 0.006708</pose>
      <visual name='Wall_57_Visual_0'>
        <pose frame=''>-0.534301 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.146885 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_57_Collision_0'>
        <geometry>
          <Box>
            <size>0.146885 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>-0.534301 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_57_Visual_1'>
        <pose frame=''>0.511599 0 1.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.19229 0.15 2.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_57_Collision_1'>
        <geometry>
          <Box>
            <size>0.19229 0.15 2.5</size>
          </Box>
        </geometry>
        <pose frame=''>0.511599 0 1.25 0 -0 0</pose>
      </collision>
      <visual name='Wall_57_Visual_2'>
        <pose frame=''>-0.022702 0 2.25 0 -0 0</pose>
        <geometry>
          <Box>
            <size>0.876312 0.15 0.5</size>
          </Box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
          <ambient>1 1 1 1</ambient>
        </material>
      </visual>
      <collision name='Wall_57_Collision_2'>
        <geometry>
          <Box>
            <size>0.876312 0.15 0.5</size>
          </Box>
        </geometry>
        <pose frame=''>-0.022702 0 2.25 0 -0 0</pose>
      </collision>
    </link>
    <static>1</static>
  </model>
</sdf>

主要是Gazebo仿真场景中各类物体的具体属性参数。

model.config:

<?xml version="1.0" ?>
<model>
    <name>whiz_ex_window</name>
    <version>1.0</version>
    <sdf version="1.6">model.sdf</sdf>
    <author>
        <name></name>
        <email></email>
    </author>
    <description></description>
</model>

可以做一些署名,邮箱,说明等。

launch:


以gazebo_kamtoa.launch为例,具体说明:

<?xml version="1.0"?>
<!--
    ENTRY FILE FOR LAUNCHING FULL SIMULATION
    Company : Obodroid Corporation
    Author : Theppasith N. <theppasith@gmail.com>
-->

<launch>

  <!-- Parameters by Console Arguments -->
  <arg name="model_name" default="kamtoa_robot"/>
  <arg name="urdf_path"  default="$(find kamtoa_description)/urdf/kamtoa_prototype/$(arg model_name).xacro"/>
  <arg name="world_name" default="building1.world"/>

  <!-- ROBOT Description file for RVIZ and Gazebo [Globally Set]-->
  <param name ="robot_description" command="$(find xacro)/xacro --inorder $(arg urdf_path)" />

  <!-- Initialize RVIZ for visualize sensing system -->
  <!-- use model from robot_description param-->
  <include file="$(find som_o_description)/launch/rviz_gui.launch" />

  <!-- Initialize Gazebo World -->
  <include file="$(find kamtoa_gazebo)/launch/world.launch">
      <arg name="world_name" value="$(arg world_name)"/>
  </include>

  <!-- Spawn URDF in the gazebo world -->
  <!-- use model from robot_description param-->
  <include file="$(find kamtoa_gazebo)/launch/spawner.launch">
      <arg name="model_name" value="$(arg model_name)"/>
      <!-- Param name robot_description (global) -->
  </include>

</launch>

分为基本参数,机器人描述(RVIZ和Gazebo),RVIZ初始化,Gazebo初始化等。这时,如果在终端运行:

~$ roslaunch kamtoa_gazebo gazebo_kamtoa.launch

可以启动roscore,rviz和gazebo如下:

relaybotBox@relaybotBox-desktop:~$ roslaunch kamtoa_gazebo gazebo_kamtoa.launch ... logging to /home/relaybotBox/.ros/log/e9deba26-9786-11e6-be4d-00e0b4159b08/roslaunch-relaybotBox-desktop-5005.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://relaybotBox-desktop:41694/

SUMMARY
========

ParaMETERS
 * /robot_description: <?xml version="1....
 * /rosdistro: kinetic
 * /rosversion: 1.12.5
 * /use_gui: True
 * /use_sim_time: True

NODES
  /
    gazebo (gazebo_ros/gazebo)
    joint_state_publisher (joint_state_publisher/joint_state_publisher)
    robot_state_publisher (robot_state_publisher/state_publisher)
    rviz (rviz/rviz)
    urdf_spawner (gazebo_ros/spawn_model)

auto-starting new master
process[master]: started with pid [5019]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to e9deba26-9786-11e6-be4d-00e0b4159b08
process[rosout-1]: started with pid [5033]
started core service [/rosout]
process[joint_state_publisher-2]: started with pid [5046]
process[robot_state_publisher-3]: started with pid [5054]
process[rviz-4]: started with pid [5059]
process[gazebo-5]: started with pid [5066]
process[urdf_spawner-6]: started with pid [5090]
spawn_model script started
[INFO] [WallTime: 1477051642.645687] [0.000000] Loading model xml from ros parameter
[INFO] [WallTime: 1477051642.655133] [0.000000] Waiting for service /gazebo/spawn_urdf_model
[ INFO] [1477051642.933367561]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1477051642.935174498]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised,waiting...
[INFO] [WallTime: 1477051643.878953] [0.000000] Calling service /gazebo/spawn_urdf_model
[INFO] [WallTime: 1477051643.975877] [1288.802000] Spawn status: SpawnModel: Model pushed to spawn queue,but spawn service timed out waiting for model to appear in simulation under the name kamtoa_robot
Warning [parser.cc:778] XML Element[visualize],child of element[link] not defined in SDF. Ignoring[visualize]. You may have an incorrect SDF file,or an sdformat version that doesn't support this element.
[urdf_spawner-6] process has finished cleanly
log file: /home/relaybotBox/.ros/log/e9deba26-9786-11e6-be4d-00e0b4159b08/urdf_spawner-6*.log
[ INFO] [1477051645.070944164,1288.802000000]: Camera Plugin (robotNamespace = /),Info: Using the 'robotNamespace' param: '/'
[ INFO] [1477051645.096626172,1288.802000000]: Camera Plugin (ns = /)  <tf_prefix_>,set to ""
[ INFO] [1477051645.459096731,1288.802000000]: Laser Plugin (robotNamespace = /),Info: Using the 'robotNamespace' param: '/'
[ INFO] [1477051645.459748522,1288.802000000]: Starting Laser Plugin (ns = /)!
[ INFO] [1477051645.476788533,1288.802000000]: Laser Plugin (ns = /)  <tf_prefix_>,set to ""
[ INFO] [1477051645.565133751,1288.802000000]: Starting plugin Diffdrive(ns = //)!
[ INFO] [1477051645.565451828,1288.802000000]: Diffdrive(ns = //): <rosDebugLevel> = Debug
[ INFO] [1477051645.568106826,1288.802000000]: Diffdrive(ns = //): <tf_prefix> = 
[DEBUG] [1477051645.568619326,1288.802000000]: Diffdrive(ns = //): <commandTopic> = cmd_vel
[DEBUG] [1477051645.568724979,1288.802000000]: Diffdrive(ns = //): <odometryTopic> = odom
[DEBUG] [1477051645.568867307,1288.802000000]: Diffdrive(ns = //): <odometryFrame> = odom
[DEBUG] [1477051645.568927646,1288.802000000]: Diffdrive(ns = //): <robotBaseFrame> = base_footprint
[DEBUG] [1477051645.569256884,1288.802000000]: Diffdrive(ns = //): <publishWheelTF> = false
[DEBUG] [1477051645.569338164,1288.802000000]: Diffdrive(ns = //): <publishWheelJointState> = false
[DEBUG] [1477051645.569393655,1288.802000000]: Diffdrive(ns = //): <legacyMode> = ture
[DEBUG] [1477051645.569843607,1288.802000000]: Diffdrive(ns = //): <wheelSeparation> = 0.29999999999999999
[DEBUG] [1477051645.569951337,1288.802000000]: Diffdrive(ns = //): <wheelDiameter> = 0.082000000000000003
[DEBUG] [1477051645.570012696,1288.802000000]: Diffdrive(ns = //): <wheelacceleration> = 1.8
[DEBUG] [1477051645.570077175,1288.802000000]: Diffdrive(ns = //): <wheelTorque> = 30
[DEBUG] [1477051645.570139351,1288.802000000]: Diffdrive(ns = //): <updaterate> = 100
[ WARN] [1477051645.570811579,1288.802000000]: Diffdrive(ns = //): <odometrySource> no matching key to 1
[DEBUG] [1477051645.571414503,1288.802000000]: Diffdrive(ns = //): <odometrySource> = default := 1
[DEBUG] [1477051645.572053861,1288.802000000]: Diffdrive(ns = //): <leftJoint> = front_left_wheel_joint
[DEBUG] [1477051645.572185748,1288.802000000]: Diffdrive(ns = //): <rightJoint> = front_right_wheel_joint
[ INFO] [1477051645.576771098,1288.802000000]: Diffdrive(ns = //): Try to subscribe to cmd_vel!
[ INFO] [1477051645.593900394,1288.802000000]: Diffdrive(ns = //): Subscribe to cmd_vel!
[ INFO] [1477051645.597711053,1288.802000000]: Diffdrive(ns = //): Advertise odom on odom !
[ INFO] [1477051645.648506913,1288.825000000]: waitForService: Service [/gazebo/set_physics_properties] is Now available.
[ INFO] [1477051645.836105586,1288.862000000]: Physics dynamic reconfigure ready.





可以用如下工具进行分析:

rqt_action           rqt_logger_level     rqt_robot_monitor
rqt_bag              rqt_moveit           rqt_robot_steering
rqt_bag_plugins      rqt_msg              rqt_runtime_monitor
rqt_console          rqt_nav_view         rqt_rviz
rqt_dep              rqt_plot             rqt_service_caller
rqt_graph            rqt_pose_view        rqt_shell
rqt_gui              rqt_publisher        rqt_srv
rqt_gui_cpp          rqt_py_common        rqt_tf_tree
rqt_gui_py           rqt_py_console       rqt_top
rqt_image_view       rqt_reconfigure      rqt_topic
rqt_launch           rqt_robot_dashboard  rqt_web

以rqt_topic为例,可以参看全部主题:

~$ rosrun rqt_topic rqt_topic

如果需要查看camera_rgb,可以运行如下命令:

~$ rosrun rqt_image_view rqt_image_view


运行rosrun rqt_graph rqt_graph


此时,gazebo与其他节点并无通信,然后启动如下命令:

~$ roslaunch kamtoa_teleop teleop_keyboard.launch


<launch>
    <node pkg="kamtoa_teleop" type="kamtoa_keyboard.py" name="kamtoa_keyboard" output="screen" />
</launch>


这时,就可以使用键盘通过/cmd_vel控制gazebo中的机器人在环境中运动,当然键盘控制还有其他一些功能,请看如下源码。

#!/usr/bin/env python

# copyright (c) 2011,Willow Garage,Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms,with or without
# modification,are permitted provided that the following conditions are met:
#
#    * Redistributions of source code must retain the above copyright
#      notice,this list of conditions and the following disclaimer.
#    * Redistributions in binary form must reproduce the above copyright
#      notice,this list of conditions and the following disclaimer in the
#      documentation and/or other materials provided with the distribution.
#    * Neither the name of the Willow Garage,Inc. nor the names of its
#      contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE copYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES,INCLUDING,BUT NOT LIMITED TO,THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND fitness FOR A PARTIculaR PURPOSE
# ARE disCLaimED. IN NO EVENT SHALL THE copYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,OR
# CONSEQUENTIAL damAGES (INCLUDING,PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA,OR PROFITS; OR BUSInesS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN
# CONTRACT,STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH damAGE.

import rospy

from geometry_msgs.msg import Twist

import sys,select,termios,tty

msg = """
Control Your Turtlebot!
---------------------------
Moving around:
   u    i    o
   j    k    l
   m,.
q/z : increase/decrease max speeds by 10%
w/x : increase/decrease only linear speed by 10%
e/c : increase/decrease only angular speed by 10%
space key,k : force stop
anything else : stop smoothly
CTRL-C to quit
"""
lightSwitches = {
    '1':'light0','2':'light1','3':'light2','4':'light3','5':'light4'
}

moveBindings = {
        'i':(1,0),'o':(1,-1),'j':(0,1),'l':(0,'u':(1,',':(-1,'.':(-1,'m':(-1,}

speedBindings={
        'q':(1.1,1.1),'z':(.9,.9),'w':(1.1,'x':(.9,'e':(1,'c':(1,}

def getKey():
    tty.setraw(sys.stdin.fileno())
    rlist,_,_ = select.select([sys.stdin],[],0.1)
    if rlist:
        key = sys.stdin.read(1)
    else:
        key = ''

    termios.tcsetattr(sys.stdin,termios.TCSADRAIN,settings)
    return key

speed = .2
turn = 1

def vels(speed,turn):
    return "currently:\tspeed %s\tturn %s " % (speed,turn)

if __name__=="__main__":
    settings = termios.tcgetattr(sys.stdin)

    rospy.init_node('Kamtoa_teleop_keyboard')
    pub = rospy.Publisher('cmd_vel',Twist,queue_size=5)

    light_select = ''
    x = 0
    th = 0
    status = 0
    count = 0
    acc = 0.1
    target_speed = 0
    target_turn = 0
    control_speed = 0
    control_turn = 0
    try:
        print msg
        print vels(speed,turn)
        while(1):
            key = getKey()
            if key in moveBindings.keys():
                x = moveBindings[key][0]
                th = moveBindings[key][1]
                count = 0
            elif key in speedBindings.keys():
                speed = speed * speedBindings[key][0]
                turn = turn * speedBindings[key][1]
                count = 0

                print vels(speed,turn)
                if (status == 14):
                    print msg
                status = (status + 1) % 15
            elif key == ' ' or key == 'k' :
                x = 0
                th = 0
                control_speed = 0
                control_turn = 0
            elif key in lightSwitches.keys():
                print "lightSwitch pressed!"

            else:
                count = count + 1
                if count > 4:
                    x = 0
                    th = 0
                if (key == '\x03'):
                    break

            target_speed = speed * x
            target_turn = turn * th

            if target_speed > control_speed:
                control_speed = min( target_speed,control_speed + 0.02 )
            elif target_speed < control_speed:
                control_speed = max( target_speed,control_speed - 0.02 )
            else:
                control_speed = target_speed

            if target_turn > control_turn:
                control_turn = min( target_turn,control_turn + 0.1 )
            elif target_turn < control_turn:
                control_turn = max( target_turn,control_turn - 0.1 )
            else:
                control_turn = target_turn

            twist = Twist()
            twist.linear.x = control_speed; twist.linear.y = 0; twist.linear.z = 0
            twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = control_turn
            pub.publish(twist)

    except:
        print e

    finally:
        twist = Twist()
        twist.linear.x = 0; twist.linear.y = 0; twist.linear.z = 0
        twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = 0
        pub.publish(twist)

    termios.tcsetattr(sys.stdin,settings)


使用手机控制机器人运动也很方便,先查询一下地址:

relaybotBox@relaybotBox-desktop:~$ ifconfig -a
enp3s0    Link encap:以太网  硬件地址 00:e0:b4:15:9b:08  
          inet 地址:192.168.3.23  广播:192.168.3.255  掩码:255.255.255.0
          inet6 地址: fe80::3805:e5fe:19f0:19e2/64 Scope:Link
          UP broADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
          接收数据包:32257 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:41654 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:1000 
          接收字节:23057526 (23.0 MB)  发送字节:17828352 (17.8 MB)

enp4s0    Link encap:以太网  硬件地址 00:e0:b4:15:9b:09  
          UP broADCAST MULTICAST  MTU:1500  跃点数:1
          接收数据包:0 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:0 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:1000 
          接收字节:0 (0.0 B)  发送字节:0 (0.0 B)

lo        Link encap:本地环回  
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet6 地址: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  跃点数:1
          接收数据包:8314866 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:8314866 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:1 
          接收字节:671600054 (671.6 MB)  发送字节:671600054 (671.6 MB)

在手机设置IP:192.168.3.23。连接成功后可以看到:


如何让机器人在环境中进行导航呢?运行下面命令:

~$ roslaunch kamtoa_navigation kamtoa_navigation.launch

其中代码如下:

<?xml version="1.0"?>
<!-- Fully Autonomous Navigation Launch file-->
<launch>

  <!-- Map server -->
  <arg name="map" default="sim_world"/>
  <node name="map_server" pkg="map_server" type="map_server" args="$(find kamtoa_navigation)/maps/$(arg map).yaml"/>


  <!-- Initial pose for the Localizer -->
  <arg name="initial_pose_x" default="0.0"/>
  <arg name="initial_pose_y" default="0.0"/>
  <arg name="initial_pose_a" default="0.0"/>

  <!-- Localizaer : AMCL -->
  <include file="$(find kamtoa_navigation)/launch/modules/amcl.launch.xml">
    <arg name="initial_pose_x" value="$(arg initial_pose_x)"/>
    <arg name="initial_pose_y" value="$(arg initial_pose_y)"/>
    <arg name="initial_pose_a" value="$(arg initial_pose_a)"/>
  </include>

  <!-- VeLocity Smoother -->
  <include file="$(find kamtoa_navigation)/launch/modules/veLocity_smoother.launch.xml"/>

  <!-- Navigation Stack (move_base's path planner,costmaps & obstacles manager) -->
  <include file="$(find kamtoa_navigation)/launch/modules/move_base.launch.xml"/>


</launch>

是不是有很多眼熟的内容,导入Map,机器人位置初值,AMCL,速度平滑,导航等。


这是再看下rqt_graph:


各个节点之间联系清晰可见。


路径规划效果如下:



其他内容后续补充。

ROS_Kinetic_29 kamtoa simulation学习与示例分析一的更多相关文章

  1. ios – 使用简洁的NSManagedObjectID URI形式?

    我想避免字符串操作,因为感觉到icky,但我会考虑它,如果这是唯一的方法.我唯一的混淆是在上面的例子中“EE13EA1E-D5F4-4E38-986D-3F4B0B03AEE4”部分来自哪里.为了重建一个有效的URI,我该如何访问该值?

  2. swift – 如何URI编码图像?

    究竟是什么意思?这是否意味着将图像转换为base64字符串,然后将其传递给请求?

  3. 如何在Android 4.0中的HTML5VFullScreen $SurfaceVideoView中获取HTML5视频URI?

    我想在用户点击视频控制栏中的全屏按钮时获取HTML5视频URI.根据this,Android4.0中的HTML5视频视图是SurfaceView,而不是VideoView.有人能告诉我如何在SurfaceVideoView中获取URI吗?这是我的代码.非常感谢.解决方法容易,使用反射.把它放在onShowCustomView()方法中:

  4. uri – 将android手机号码标签ID翻译成字符串

    嗨,我正在写一个小型的Android应用程序,密切工作的白色手机标签,但我不明白我是如何调整翻译Documentation中描述的uri值.我想要做的是将TYPE_HOME转换为Home等等.我目前的解决方案是列出所有已翻译的字符串,但它已经提出了很多问题.但我希望能够像地址簿和其他应用程序一样使用它.解决方法Android有一个内置的方法来做到这一点……

  5. 如何在我的Android应用程序中获取SQLite数据库的URI?

    我有一个带有名为“myTestDB”的数据库的Android应用程序,其中包含一个名为“list_items”的表.我想使用CursorgetContentResolver().query()方法来获取要添加到SimpleCursorAdapter的游标.query()方法的第一个参数是一个URI,我不确定URI应该是什么样子.解决方法它是相当简单的方法调用看起来像这样mDataBase.quer

  6. android.database.CursorIndexOutOfBoundsException:索引-1请求

    试试这个

  7. 在Android设备中使用ACTION_PICK意图仅显示电话号码的联系人

    我尝试浏览stackoverflow和其他网站中的所有线程,但找不到解决此问题的任何解决方案,尽管许多人已发布此问题.我没有在Android平台上工作太多,我可能错过了一些细微的细节,我相信必须有一个简单的方法来实现这一点.请建议.感谢您的帮助.谢谢.解决方法请使用以下代码

  8. android – 如何获取刚从相机捕获的图像路径

    下面是我的代码但是没有给我onActivity结果中的图像路径解决方法这对我有用……

  9. Android从Google云端硬盘获取Uri路径

    我有这个代码将文件上传到我的应用程序,当用文件管理器,dropBox或其他任何东西打开文件时,返回的路径是正确的,我可以访问它,我只是遇到谷歌驱动器的问题,它返回一些以“exposed_content”开头的路径,我不能以任何方式“解码”它,我搜索过并没有找到办法,任何人都有任何想法?解决方法使用附加的代码…从onActivity结果你将得到内容uri…将此uri传递给给定的方法…

  10. Android SyncAdapter回调

    我已经在SDK中的SimpleSyncAdapter示例项目中实现了SyncAdapter,AccountManager和私有ContentProvider.一切运作良好.现在,我想在从具有特定标志集的远程服务器下载新行时向用户显示一条消息.当Sync完成时,我需要从SyncAdapter进行回调,以便我可以执行查询并显示来自活动的消息.我在StackOverflow上看到了一些关于这个问题的问题

随机推荐

  1. crontab发送一个月份的电子邮件

    ubuntu14.04邮件服务器:Postfixroot收到来自crontab的十几封电子邮件.这些邮件包含PHP警告.>我已经解决了这些警告的原因.>我已修复每个cronjobs不发送电子邮件(输出发送到>/dev/null2>&1)>我删除了之前的所有电子邮件/var/mail/root/var/spool/mail/root但我仍然每小时收到十几封电子邮件.这些电子邮件来自cronjobs,

  2. 模拟两个ubuntu服务器计算机之间的慢速连接

    我想模拟以下场景:假设我有4台ubuntu服务器机器A,B,C和D.我想在机器A和机器C之间减少20%的网络带宽,在A和B之间减少10%.使用网络模拟/限制工具来做到这一点?

  3. ubuntu-12.04 – 如何在ubuntu 12.04中卸载从源安装的redis?

    我从源代码在Ubuntu12.04上安装了redis-server.但在某些时候它无法完全安装,最后一次makeinstallcmd失败.然后我刚刚通过apt包安装.现在我很困惑哪个安装正在运行哪个conf文件?实际上我想卸载/删除通过源安装的所有内容,只是想安装一个包.转到源代码树并尝试以下命令:如果这不起作用,您可以列出软件自行安装所需的步骤:

  4. ubuntu – “apt-get source”无法找到包但“apt-get install”和“apt-get cache”可以找到它

    我正在尝试下载软件包的源代码,但是当我运行时它无法找到.但是当我运行apt-cache搜索squid3时,它会找到它.它也适用于apt-getinstallsquid3.我使用的是Ubuntu11.04服务器,这是我的/etc/apt/sources.list我已经多次更新了.我尝试了很多不同的debs,并没有发现任何其他地方的错误.这里的问题是你的二进制包(deb)与你的源包(deb-src)不

  5. ubuntu – 有没有办法检测nginx何时完成正常关闭?

    &&touchrestarted),因为即使Nginx没有完成其关闭,touch命令也会立即执行.有没有好办法呢?这样的事情怎么样?因此,pgrep将查找任何Nginx进程,而while循环将让它坐在那里直到它们全部消失.你可以改变一些有用的东西,比如睡1;/etc/init.d/Nginx停止,以便它会休眠一秒钟,然后尝试使用init.d脚本停止Nginx.你也可以在某处放置一个计数器,这样你就可以在需要太长时间时发出轰击信号.

  6. ubuntu – 如何将所有外发电子邮件从postfix重定向到单个地址进行测试

    我正在为基于Web的应用程序设置测试服务器,该应用程序发送一些电子邮件通知.有时候测试是使用真实的客户数据进行的,因此我需要保证服务器在我们测试时无法向真实客户发送电子邮件.我想要的是配置postfix,以便它接收任何外发电子邮件并将其重定向到一个电子邮件地址,而不是传递到真正的目的地.我正在运行ubuntu服务器9.10.先感谢您设置本地用户以接收所有被困邮件:你需要在main.cf中添加:然后

  7. ubuntu – vagrant无法连接到虚拟框

    当我使用基本的Vagrantfile,只配置了两条线:我看到我的虚拟框打开,但是我的流氓日志多次显示此行直到超时:然后,超时后的一段时间,虚拟框框终于要求我登录,但是太久了!所以我用流氓/流氓记录.然后在我的物理机器上,如果我“流氓ssh”.没有事情发生,直到:怎么了?

  8. ubuntu – Nginx – 转发HTTP AUTH – 用户?

    我和Nginx和Jenkins有些麻烦.我尝试使用Nginx作为Jenkins实例的反向代理,使用HTTP基本身份验证.它到目前为止工作,但我不知道如何传递带有AUTH用户名的标头?}尝试将此指令添加到您的位置块

  9. Debian / Ubuntu – 删除后如何恢复/ var / cache / apt结构?

    我在ubuntu服务器上的空间不足,所以我做了这个命令以节省空间但是现在在尝试使用apt时,我会收到以下错误:等等显然我删除了一些目录结构.有没有办法做apt-getrebuild-var-tree或类似的?

  10. 检查ubuntu上安装的rubygems版本?

    如何查看我的ubuntu盒子上安装的rubygems版本?只是一个想法,列出已安装的软件包和grep为ruby或宝石或其他:)dpkg–get-selections

返回
顶部