目录

安装Gazebo

1.添加源

2.安装gazebo

使用Gazepo 实现摄像头仿真

 1.工作空间与功能包的创建

 2)Gazebo配置文件

3)车体urdf建模与控制程序

4)launch文件

5)执行launch文件运行程序

使用Gazepo 实现雷达仿真

1)Launch文件

2) 执行

使用Gazepo 实现Kinect仿真

1)launch文件

2)执行


安装Gazebo

Gazeop是一款仿真软件,和ROS有非常好的兼容性,通常来说使用rviz就可以满足绝大部分需求,但是要考虑真实世界的物理属性的话(比如摩擦力,空气阻力,湿度,地面凹凸程度等),就需要用到Gazepo

1.添加源

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'

wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

2.安装gazebo

sudo apt-get update

sudo apt-get install gazebo7

sudo apt-get install libgazebo7-dev

 

使用Gazepo 实现摄像头仿真

 1.工作空间与功能包的创建


//创建工作空间
$ source /opt/ros/kinetic/setup.zsh
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace
$ cd ~/catkin_ws
$ catkin_make 
$ souce ~/catkiin_ws/devel/setup.zsh
$ cd ~/catkin_ws/src

//创建功能包
$ catkin_create_pkg my_gazebo gazebo_plugins gazebo_ros gazebo_ros_control roscpp rospy
$ cd ~/catkin_ws
$ catkin_make
$ source devel/setup.zsh

//创建目录结构
$ cd ~/catkin_ws/src/my_gazebo 
$ mkdir worlds launch 

 2)Gazebo配置文件

请按照下列方式命名,或修改launch文件

$ cd world

$ touch playground.world

该文件由Gazebo界面配置后导出,非手动编写,复制即可

<sdf version='1.4'>
  <world name='default'>
    <light name='sun' type='directional'>
      <cast_shadows>1</cast_shadows>
      <pose>0 0 10 0 -0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.9</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>0.5 0.1 -0.9</direction>
    </light>
    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.7 0.7 0.7 1</background>
      <shadows>1</shadows>
    </scene>
    <physics type='ode'>
      <max_step_size>0.01</max_step_size>
      <real_time_factor>1</real_time_factor>
      <real_time_update_rate>100</real_time_update_rate>
      <gravity>0 0 -9.8</gravity>
    </physics>
    <model name='bookshelf'>
      <static>1</static>
      <link name='link'>
        <inertial>
          <mass>1</mass>
        </inertial>
        <collision name='back'>
          <pose>0 0.005 0.6 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.9 0.01 1.2</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual1'>
          <pose>0 0.005 0.6 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.9 0.01 1.2</size>
            </box>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Wood</name>
            </script>
          </material>
        </visual>
        <collision name='left_side'>
          <pose>0.45 -0.195 0.6 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.02 0.4 1.2</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual2'>
          <pose>0.45 -0.195 0.6 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.02 0.4 1.2</size>
            </box>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Wood</name>
            </script>
          </material>
        </visual>
        <collision name='right_side'>
          <pose>-0.45 -0.195 0.6 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.02 0.4 1.2</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual3'>
          <pose>-0.45 -0.195 0.6 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.02 0.4 1.2</size>
            </box>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Wood</name>
            </script>
          </material>
        </visual>
        <collision name='bottom'>
          <pose>0 -0.195 0.03 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.88 0.4 0.06</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual4'>
          <pose>0 -0.195 0.03 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.88 0.4 0.06</size>
            </box>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Wood</name>
            </script>
          </material>
        </visual>
        <collision name='top'>
          <pose>0 -0.195 1.19 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.88 0.4 0.02</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual5'>
          <pose>0 -0.195 1.19 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.88 0.4 0.02</size>
            </box>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Wood</name>
            </script>
          </material>
        </visual>
        <collision name='low_shelf'>
          <pose>0 -0.195 0.43 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.88 0.4 0.02</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual6'>
          <pose>0 -0.195 0.43 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.88 0.4 0.02</size>
            </box>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Wood</name>
            </script>
          </material>
        </visual>
        <collision name='high_shelf'>
          <pose>0 -0.195 0.8 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.88 0.4 0.02</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual7'>
          <pose>0 -0.195 0.8 0 -0 0</pose>
          <geometry>
            <box>
              <size>0.88 0.4 0.02</size>
            </box>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Wood</name>
            </script>
          </material>
        </visual>
        <velocity_decay>
          <linear>0</linear>
          <angular>0</angular>
        </velocity_decay>
        <self_collide>0</self_collide>
        <kinematic>0</kinematic>
        <gravity>1</gravity>
      </link>
      <pose>0 1.53026 0 0 -0 0</pose>
    </model>
    <model name='jersey_barrier'>
      <static>1</static>
      <link name='link'>
        <visual name='visual'>
          <geometry>
            <mesh>
              <uri>model://jersey_barrier/meshes/jersey_barrier.dae</uri>
            </mesh>
          </geometry>
        </visual>
        <collision name='upright'>
          <pose>0 0 0.5715 0 -0 0</pose>
          <geometry>
            <box>
              <size>4.06542 0.3063 1.143</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <collision name='base'>
          <pose>0 0 0.032258 0 -0 0</pose>
          <geometry>
            <box>
              <size>4.06542 0.8107 0.064516</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <collision name='base2'>
          <pose>0 0 0.1 0 -0 0</pose>
          <geometry>
            <box>
              <size>4.06542 0.65 0.1</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <collision name='base3'>
          <pose>0 0 0.2 0 -0 0</pose>
          <geometry>
            <box>
              <size>4.06542 0.5 0.1</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <collision name='left-angle'>
          <pose>0 -0.224 0.2401 0.9 -0 0</pose>
          <geometry>
            <box>
              <size>4.06542 0.5 0.064516</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <collision name='right-angle'>
          <pose>0 0.224 0.2401 -0.9 0 0</pose>
          <geometry>
            <box>
              <size>4.06542 0.5 0.064516</size>
            </box>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <velocity_decay>
          <linear>0</linear>
          <angular>0</angular>
        </velocity_decay>
        <self_collide>0</self_collide>
        <kinematic>0</kinematic>
        <gravity>1</gravity>
      </link>
      <pose>-4 -1 0 0 -0 -0.7</pose>
    </model>
    <model name='ground_plane_0'>
      <static>1</static>
      <link name='link'>
        <collision name='collision'>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <surface>
            <friction>
              <ode>
                <mu>100</mu>
                <mu2>50</mu2>
              </ode>
            </friction>
            <bounce/>
            <contact>
              <ode/>
            </contact>
          </surface>
          <max_contacts>10</max_contacts>
        </collision>
        <visual name='visual'>
          <cast_shadows>0</cast_shadows>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Grey</name>
            </script>
          </material>
        </visual>
        <velocity_decay>
          <linear>0</linear>
          <angular>0</angular>
        </velocity_decay>
        <self_collide>0</self_collide>
        <kinematic>0</kinematic>
        <gravity>1</gravity>
      </link>
      <pose>0.497681 0 0 0 -0 0</pose>
    </model>
    <state world_name='default'>
      <sim_time>0 0</sim_time>
      <real_time>0 44986</real_time>
      <wall_time>1377677575 940727583</wall_time>
      <model name='Dumpster'>
        <pose>1 -3.44458 0 0 -0 0</pose>
        <link name='link'>
          <pose>1 -3.44458 0 0 -0 0</pose>
          <velocity>0 0 0 0 -0 0</velocity>
          <acceleration>0 0 0 0 -0 0</acceleration>
          <wrench>0 0 0 0 -0 0</wrench>
        </link>
      </model>
      <model name='cube_20k'>
        <pose>1.41131 -1 0 0 -0 0.9</pose>
        <link name='link'>
          <pose>1.41131 -1 0.5 0 -0 0.9</pose>
          <velocity>0 0 0 0 -0 0</velocity>
          <acceleration>0 0 0 0 -0 0</acceleration>
          <wrench>0 0 0 0 -0 0</wrench>
        </link>
      </model>
      <model name='unit_cylinder_1'>
        <pose>-2 -3.4888 0.5 0 -0 0</pose>
        <link name='link'>
          <pose>-2 -3.4888 0.5 0 -0 0</pose>
          <velocity>0 0 0 0 -0 0</velocity>
          <acceleration>0 0 0 0 -0 0</acceleration>
          <wrench>0 0 0 0 -0 0</wrench>
        </link>
      </model>
    </state>
    <gui fullscreen='0'>
      <camera name='user_camera'>
        <pose>1.33336 -0.422442 27.6101 3e-06 1.5698 3.04015</pose>
        <view_controller>orbit</view_controller>
      </camera>
    </gui>
    <model name='unit_cylinder_1'>
      <pose>-2 -3.4888 0.5 0 -0 0</pose>
      <link name='link'>
        <inertial>
          <mass>1</mass>
          <inertia>
            <ixx>1</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>1</iyy>
            <iyz>0</iyz>
            <izz>1</izz>
          </inertia>
        </inertial>
        <collision name='collision'>
          <geometry>
            <cylinder>
              <radius>0.5</radius>
              <length>1</length>
            </cylinder>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual'>
          <geometry>
            <cylinder>
              <radius>0.5</radius>
              <length>1</length>
            </cylinder>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Grey</name>
            </script>
          </material>
        </visual>
        <velocity_decay>
          <linear>0</linear>
          <angular>0</angular>
        </velocity_decay>
        <self_collide>0</self_collide>
        <kinematic>0</kinematic>
        <gravity>1</gravity>
      </link>
      <static>0</static>
    </model>
    <model name='Dumpster'>
      <link name='link'>
        <collision name='collision'>
          <geometry>
            <mesh>
              <uri>model://dumpster/meshes/dumpster.dae</uri>
            </mesh>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual'>
          <geometry>
            <mesh>
              <uri>model://dumpster/meshes/dumpster.dae</uri>
            </mesh>
          </geometry>
          <material>
            <script>
              <uri>model://dumpster/materials/scripts</uri>
              <uri>model://dumpster/materials/textures</uri>
              <name>Dumpster/Diffuse</name>
            </script>
          </material>
        </visual>
        <velocity_decay>
          <linear>0</linear>
          <angular>0</angular>
        </velocity_decay>
        <self_collide>0</self_collide>
        <inertial>
          <inertia>
            <ixx>1</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>1</iyy>
            <iyz>0</iyz>
            <izz>1</izz>
          </inertia>
          <mass>1</mass>
        </inertial>
        <kinematic>0</kinematic>
        <gravity>1</gravity>
      </link>
      <pose>1 -3.44458 0 0 -0 -0.3</pose>
      <static>0</static>
    </model>
    <model name='cube_20k'>
      <link name='link'>
        <pose>0 0 0.5 0 -0 0</pose>
        <collision name='collision'>
          <geometry>
            <mesh>
              <uri>model://cube_20k/meshes/cube_20k.stl</uri>
              <scale>0.5 0.5 0.5</scale>
            </mesh>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <bounce/>
            <friction>
              <ode/>
            </friction>
            <contact>
              <ode/>
            </contact>
          </surface>
        </collision>
        <visual name='visual'>
          <geometry>
            <mesh>
              <uri>model://cube_20k/meshes/cube_20k.stl</uri>
              <scale>0.5 0.5 0.5</scale>
            </mesh>
          </geometry>
        </visual>
        <velocity_decay>
          <linear>0</linear>
          <angular>0</angular>
        </velocity_decay>
        <self_collide>0</self_collide>
        <inertial>
          <inertia>
            <ixx>1</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>1</iyy>
            <iyz>0</iyz>
            <izz>1</izz>
          </inertia>
          <mass>1</mass>
        </inertial>
        <kinematic>0</kinematic>
        <gravity>1</gravity>
      </link>
      <pose>1.41131 -1 0 0 -0 0.9</pose>
      <static>0</static>
    </model>
  </world>
</sdf>

 

3)车体urdf建模与控制程序

非常建议阅读该篇文章后再阅读下面内容

ROS ArbotiX控制+xacro机器人仿真模型设计 实现初级建模与车体控制

或下载

urdf描述包:https://gitee.com/alen2020/mbot_description.git

车体控制包:https://gitee.com/alen2020/mbot_teleop.git

 

4)launch文件

在加载机器人模型描述参数这里引入了功能包,若没有该功能包需要看上一节给出的链接文件,里面介绍到xacro文件的编写,或有自己的一套车体模型,则引入自己的,注意命名。

<launch>

    <!-- 设置launch文件的参数 -->
    <arg name="world_name" value="$(find mbot_gazebo)/worlds/playground.world"/>
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>

    <!-- 运行gazebo仿真环境 -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(arg world_name)" />
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

    <!-- 加载机器人模型描述参数 -->
    <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_camera_gazebo.xacro'" /> 

    <!-- 运行joint_state_publisher节点,发布机器人的关节状态  -->
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> 

    <!-- 运行robot_state_publisher节点,发布tf  -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
        <param name="publish_frequency" type="double" value="50.0" />
    </node>

    <!-- 在gazebo中加载机器人模型-->
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -model mrobot -param robot_description"/> 

</launch>



5)执行launch文件运行程序

开启三个终端,执行下三条指令

$ roslaunch test1 view_mbot_with_camera_gazebo.launch
$ roslaunch mbot_teleop mbot_teleop.launch
$ rqt_image_view

 在rqt_image_view中选择订阅/camera/image_raw话题,移动车体,即可看到实时视图

 

使用Gazepo 实现雷达仿真

1)Launch文件

使用雷达仿真修改launch文件即可,前提是有车体urdf建模这个包,我在上一节给出

与摄像头不同的是xacro的引入文件

 <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_laser_gazebo.xacro'" />

<launch>

    <!-- 设置launch文件的参数 -->
    <arg name="world_name" value="$(find mbot_gazebo)/worlds/playground.world"/>
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>

    <!-- 运行gazebo仿真环境 -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(arg world_name)" />
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

    <!-- 加载机器人模型描述参数 -->
    <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_laser_gazebo.xacro'" /> 

    <!-- 运行joint_state_publisher节点,发布机器人的关节状态  -->
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> 

    <!-- 运行robot_state_publisher节点,发布tf  -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
        <param name="publish_frequency" type="double" value="50.0" />
    </node>

    <!-- 在gazebo中加载机器人模型-->
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -model mrobot -param robot_description"/> 

</launch>

2) 执行

开启三个终端,执行下三条指令

$ roslaunch test1 view_mbot_with_laser_gazebo.launch
$ roslaunch mbot_teleop mbot_teleop.launch
$ rviz

可以看到单线激光雷达的点云数据,控制车体移动,点云数据实时变动

 

使用Gazepo 实现Kinect仿真

1)launch文件

使用Kinect仿真修改launch文件即可,前提是有车体urdf建模这个包,我在第一节给出

与摄像头和激光雷达不同的是xacro的引入文件

<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_kinect_gazebo.xacro'" />

<launch>

    <!-- 设置launch文件的参数 -->
    <arg name="world_name" value="$(find mbot_gazebo)/worlds/playground.world"/>
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>

    <!-- 运行gazebo仿真环境 -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(arg world_name)" />
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

    <!-- 加载机器人模型描述参数 -->
    <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_kinect_gazebo.xacro'" /> 

    <!-- 运行joint_state_publisher节点,发布机器人的关节状态  -->
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> 

    <!-- 运行robot_state_publisher节点,发布tf  -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
        <param name="publish_frequency" type="double" value="50.0" />
    </node>

    <!-- 在gazebo中加载机器人模型-->
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -model mrobot -param robot_description"/> 

</launch>

2)执行

$ roslaunch test1 view_mbot_with_laser_gazebo.launch
$ roslaunch mbot_teleop mbot_teleop.launch
$ rqt_image_view
$ rviz

kinect既可以看到点云数据,也可以看到摄像头信息,相对于激光雷达来说,Kinect的点云扫射访问很窄(通常不超过180度)

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐