Robot Operating System (ROS)学习笔记2---使用smartcar进行仿真

Posted 林先森_007

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Robot Operating System (ROS)学习笔记2---使用smartcar进行仿真相关的知识,希望对你有一定的参考价值。

搭建环境:XMWare  Ubuntu14.04  ROS(indigo)

转载自古月居  转载连接:http://www.guyuehome.com/248

 

一、模型完善

  文件夹urdf下,创建gazebo.urdf.xacro、smartcar.urdf.xacro、smartcar_body.urdf.xacro三个文件

1、机器人主体smartcar_body.urdf.xacro文件

 

  1 <?xml version="1.0"?>  
  2 <robot name="smartcar" xmlns:xacro="http://ros.org/wiki/xacro">  
  3   <property name="M_PI" value="3.14159"/>  
  4  
  5   <!-- Macro for SmartCar body. Including Gazebo extensions, but does not include Kinect -->  
  6   <include filename="$(find smartcar_description)/urdf/gazebo.urdf.xacro"/>  
  7  
  8   <property name="base_x" value="0.33" />  
  9   <property name="base_y" value="0.33" />  
 10  
 11   <xacro:macro name="smartcar_body">  
 12  
 13  
 14     <link name="base_link">  
 15     <inertial>  
 16       <origin xyz="0 0 0.055"/>  
 17       <mass value="1.0" />  
 18       <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>  
 19     </inertial>  
 20     <visual>  
 21       <geometry>  
 22         <box size="0.25 .16 .05"/>  
 23       </geometry>  
 24       <origin rpy="0 0 0" xyz="0 0 0.055"/>  
 25       <material name="blue">  
 26       <color rgba="0 0 .8 1"/>  
 27       </material>  
 28    </visual>  
 29    <collision>  
 30       <origin rpy="0 0 0" xyz="0 0 0.055"/>  
 31       <geometry>  
 32         <box size="0.25 .16 .05" />  
 33       </geometry>  
 34     </collision>  
 35   </link>  
 36  
 37  
 38  <link name="left_front_wheel">  
 39     <inertial>  
 40       <origin  xyz="0.08 0.08 0.025"/>  
 41       <mass value="0.1" />  
 42        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>  
 43     </inertial>  
 44     <visual>  
 45       <geometry>  
 46         <cylinder length=".02" radius="0.025"/>  
 47       </geometry>  
 48       <material name="black">  
 49         <color rgba="0 0 0 1"/>  
 50       </material>  
 51     </visual>  
 52     <collision>  
 53       <origin rpy="0 1.57075 1.57075" xyz="0.08 0.08 0.025"/>  
 54       <geometry>  
 55          <cylinder length=".02" radius="0.025"/>  
 56       </geometry>  
 57     </collision>  
 58   </link>  
 59  
 60   <joint name="left_front_wheel_joint" type="continuous">  
 61     <axis xyz="0 0 1"/>  
 62     <parent link="base_link"/>  
 63     <child link="left_front_wheel"/>  
 64     <origin rpy="0 1.57075 1.57075" xyz="0.08 0.08 0.025"/>  
 65     <limit effort="100" velocity="100"/>  
 66     <joint_properties damping="0.0" friction="0.0"/>  
 67   </joint>  
 68  
 69   <link name="right_front_wheel">  
 70     <inertial>  
 71       <origin xyz="0.08 -0.08 0.025"/>  
 72       <mass value="0.1" />  
 73        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>  
 74     </inertial>  
 75     <visual>  
 76       <geometry>  
 77         <cylinder length=".02" radius="0.025"/>  
 78       </geometry>  
 79       <material name="black">  
 80         <color rgba="0 0 0 1"/>  
 81       </material>  
 82     </visual>  
 83     <collision>  
 84       <origin rpy="0 1.57075 1.57075" xyz="0.08 -0.08 0.025"/>  
 85       <geometry>  
 86          <cylinder length=".02" radius="0.025"/>  
 87       </geometry>  
 88     </collision>  
 89   </link>  
 90  
 91   <joint name="right_front_wheel_joint" type="continuous">  
 92     <axis xyz="0 0 1"/>  
 93     <parent link="base_link"/>  
 94     <child link="right_front_wheel"/>  
 95     <origin rpy="0 1.57075 1.57075" xyz="0.08 -0.08 0.025"/>  
 96     <limit effort="100" velocity="100"/>  
 97     <joint_properties damping="0.0" friction="0.0"/>  
 98  </joint>  
 99  
100  <link name="left_back_wheel">  
101     <inertial>  
102       <origin xyz="-0.08 0.08 0.025"/>  
103       <mass value="0.1" />  
104        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>  
105     </inertial>  
106     <visual>  
107       <geometry>  
108         <cylinder length=".02" radius="0.025"/>  
109       </geometry>  
110       <material name="black">  
111         <color rgba="0 0 0 1"/>  
112       </material>  
113    </visual>  
114    <collision>  
115        <origin rpy="0 1.57075 1.57075" xyz="-0.08 0.08 0.025"/>  
116       <geometry>  
117          <cylinder length=".02" radius="0.025"/>  
118       </geometry>  
119     </collision>  
120   </link>  
121  
122   <joint name="left_back_wheel_joint" type="continuous">  
123     <axis xyz="0 0 1"/>  
124     <parent link="base_link"/>  
125     <child link="left_back_wheel"/>  
126     <origin rpy="0 1.57075 1.57075" xyz="-0.08 0.08 0.025"/>  
127     <limit effort="100" velocity="100"/>  
128     <joint_properties damping="0.0" friction="0.0"/>  
129   </joint>  
130  
131   <link name="right_back_wheel">  
132     <inertial>  
133        <origin xyz="-0.08 -0.08 0.025"/>  
134        <mass value="0.1" />  
135        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>  
136     </inertial>  
137     <visual>  
138       <geometry>  
139         <cylinder length=".02" radius="0.025"/>  
140       </geometry>  
141       <material name="black">  
142         <color rgba="0 0 0 1"/>  
143       </material>  
144    </visual>  
145    <collision>  
146       <origin rpy="0 1.57075 1.57075" xyz="-0.08 -0.08 0.025"/>  
147       <geometry>  
148          <cylinder length=".02" radius="0.025"/>  
149       </geometry>  
150     </collision>  
151   </link>  
152  
153  
154   <joint name="right_back_wheel_joint" type="continuous">  
155     <axis xyz="0 0 1"/>  
156     <parent link="base_link"/>  
157     <child link="right_back_wheel"/>  
158     <origin rpy="0 1.57075 1.57075" xyz="-0.08 -0.08 0.025"/>  
159     <limit effort="100" velocity="100"/>  
160     <joint_properties damping="0.0" friction="0.0"/>  
161   </joint>  
162  
163   <link name="head">  
164     <inertial>  
165       <origin xyz="0.08 0 0.08"/>  
166       <mass value="0.1" />  
167       <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>  
168     </inertial>  
169     <visual>  
170       <geometry>  
171         <box size=".02 .03 .03"/>  
172       </geometry>  
173       <material name="white">  
174         <color rgba="1 1 1 1"/>  
175       </material>  
176      </visual>  
177      <collision>  
178       <origin xyz="0.08 0 0.08"/>  
179       <geometry>  
180          <cylinder length=".02" radius="0.025"/>  
181       </geometry>  
182     </collision>  
183   </link>  
184  
185   <joint name="tobox" type="fixed">  
186     <parent link="base_link"/>  
187     <child link="head"/>  
188     <origin xyz="0.08 0 0.08"/>  
189   </joint>  
190   </xacro:macro>  
191  
192 </robot>

 

2、gazebo属性部分gazebo.urdf.xacro

 1 <?xml version="1.0"?>  
 2  
 3 <robot xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"   
 4     xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"   
 5     xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"   
 6     xmlns:xacro="http://ros.org/wiki/xacro"   
 7     name="smartcar_gazebo">  
 8  
 9 <!-- ASUS Xtion PRO camera for simulation -->  
10 <!-- gazebo_ros_wge100 plugin is in kt2_gazebo_plugins package -->  
11 <xacro:macro name="smartcar_sim">  
12     <gazebo reference="base_link">  
13         <material>Gazebo/Blue</material>  
14     </gazebo>  
15  
16     <gazebo reference="right_front_wheel">  
17         <material>Gazebo/FlatBlack</material>  
18     </gazebo>  
19  
20     <gazebo reference="right_back_wheel">  
21         <material>Gazebo/FlatBlack</material>  
22     </gazebo>  
23  
24     <gazebo reference="left_front_wheel">  
25         <material>Gazebo/FlatBlack</material>  
26     </gazebo>  
27  
28     <gazebo reference="left_back_wheel">  
29         <material>Gazebo/FlatBlack</material>  
30     </gazebo>  
31  
32     <gazebo reference="head">  
33         <material>Gazebo/White</Robot Operating System (ROS)学习笔记4---语音控制

如何更加便捷的调试ROS(Robot Operating System)

Robot Operating System (ROS)学习笔记2---使用smartcar进行仿真

Robot Operating System (ROS)学习笔记---创建简单的机器人模型smartcar

ROS1/2最强学术科研参考书-Springer Book Robot Operating System (ROS) The Complete Reference (Volume 7)

Microsoft Windows Operating System是啥程序可以关掉吗?